Code Duplication    Length = 9-10 lines in 2 locations

src/Eccube/Controller/Admin/Product/CsvImportController.php 1 location

@@ 996-1004 (lines=9) @@
993
                        ]);
994
                        $this->addErrors($message);
995
                    } else {
996
                        foreach ($Category->getPath() as $ParentCategory) {
997
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
998
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
999
                                $this->entityManager->persist($ProductCategory);
1000
                                $sortNo++;
1001
1002
                                $Product->addProductCategory($ProductCategory);
1003
                                $categoriesIdList[$ParentCategory->getId()] = true;
1004
                            }
1005
                        }
1006
                        if (!isset($categoriesIdList[$Category->getId()])) {
1007
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);

src/Eccube/Controller/Admin/Product/ProductController.php 1 location

@@ 557-566 (lines=10) @@
554
                $Categories = $form->get('Category')->getData();
555
                $categoriesIdList = [];
556
                foreach ($Categories as $Category) {
557
                    foreach ($Category->getPath() as $ParentCategory) {
558
                        if (!isset($categoriesIdList[$ParentCategory->getId()])) {
559
                            $ProductCategory = $this->createProductCategory($Product, $ParentCategory, $count);
560
                            $this->entityManager->persist($ProductCategory);
561
                            $count++;
562
                            /* @var $Product \Eccube\Entity\Product */
563
                            $Product->addProductCategory($ProductCategory);
564
                            $categoriesIdList[$ParentCategory->getId()] = true;
565
                        }
566
                    }
567
                    if (!isset($categoriesIdList[$Category->getId()])) {
568
                        $ProductCategory = $this->createProductCategory($Product, $Category, $count);
569
                        $this->entityManager->persist($ProductCategory);