Code Duplication    Length = 29-31 lines in 2 locations

Controllers/Backend/ConnectConfig.php 2 locations

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