Code Duplication    Length = 29-31 lines in 2 locations

Controllers/Backend/ConnectConfig.php 2 locations

@@ 324-352 (lines=29) @@
321
            $data['priceFieldForPurchasePriceExport'] = 'detailPurchasePrice';
322
        }
323
324
        if ($priceType == \Shopware\Connect\SDK::PRICE_TYPE_BOTH
325
            || $priceType == \Shopware\Connect\SDK::PRICE_TYPE_RETAIL
326
        ) {
327
            /** @var \Shopware\Models\Customer\Group $groupPrice */
328
            $groupPrice = $this->getCustomerGroupRepository()->findOneBy(['key' => $data['priceGroupForPriceExport']]);
329
            if (!$groupPrice) {
330
                $this->View()->assign([
331
                    'success' => false,
332
                    'message' => Shopware()->Snippets()->getNamespace('backend/connect/view/main')->get(
333
                        'config/export/invalid_customer_group',
334
                        'Ungültige Kundengruppe',
335
                        true
336
                    )
337
                ]);
338
339
                return;
340
            }
341
342
            if ($this->getPriceGateway()->countProductsWithConfiguredPrice($groupPrice, $data['priceFieldForPriceExport']) === 0) {
343
                $this->View()->assign([
344
                    'success' => false,
345
                    'message' => Shopware()->Snippets()->getNamespace('backend/connect/view/main')->get(
346
                        'config/export/priceFieldIsNotSupported',
347
                        'Price field is not maintained. Some of the products have price = 0',
348
                        true
349
                    )
350
                ]);
351
352
                return;
353
            }
354
        }
355
@@ 356-386 (lines=31) @@
353
            }
354
        }
355
356
        if ($priceType == \Shopware\Connect\SDK::PRICE_TYPE_BOTH
357
            || $priceType == \Shopware\Connect\SDK::PRICE_TYPE_PURCHASE
358
        ) {
359
            /** @var \Shopware\Models\Customer\Group $groupPurchasePrice */
360
            $groupPurchasePrice = $this->getCustomerGroupRepository()->findOneBy([
361
                'key' => $data['priceGroupForPurchasePriceExport']
362
            ]);
363
            if (!$groupPurchasePrice && !$detailPurchasePrice) {
364
                $this->View()->assign([
365
                    'success' => false,
366
                    'message' => Shopware()->Snippets()->getNamespace('backend/connect/view/main')->get(
367
                        'config/export/invalid_customer_group',
368
                        'Ungültige Kundengruppe',
369
                        true
370
                    )
371
                ]);
372
373
                return;
374
            }
375
376
            if ($this->getPriceGateway()->countProductsWithConfiguredPrice($groupPurchasePrice, $data['priceFieldForPurchasePriceExport']) === 0) {
377
                $this->View()->assign([
378
                    'success' => false,
379
                    'message' => Shopware()->Snippets()->getNamespace('backend/connect/view/main')->get(
380
                        'config/export/priceFieldIsNotSupported',
381
                        'Price field is not maintained. Some of the products have price = 0',
382
                        true
383
                    )
384
                ]);
385
386
                return;
387
            }
388
        }
389