Code Duplication    Length = 9-10 lines in 2 locations

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

@@ 815-823 (lines=9) @@
812
                if (!$Category) {
813
                    $this->addErrors(($data->key() + 1).'行目の商品カテゴリ(ID)「'.$category.'」が存在しません。');
814
                } else {
815
                    foreach($Category->getPath() as $ParentCategory){
816
                        if (!isset($categoriesIdList[$ParentCategory->getId()])){
817
                            $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $rank);
818
                            $this->entityManager->persist($ProductCategory);
819
                            $rank++;
820
                            $Product->addProductCategory($ProductCategory);
821
                            $categoriesIdList[$ParentCategory->getId()] = true;
822
                        }
823
                    }
824
                    if (!isset($categoriesIdList[$Category->getId()])){
825
                        $ProductCategory = $this->makeProductCategory($Product, $Category, $rank);
826
                        $rank++;

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

@@ 487-496 (lines=10) @@
484
                $Categories = $form->get('Category')->getData();
485
                $categoriesIdList = array();
486
                foreach ($Categories as $Category) {
487
                    foreach($Category->getPath() as $ParentCategory){
488
                        if (!isset($categoriesIdList[$ParentCategory->getId()])){
489
                            $ProductCategory = $this->createProductCategory($Product, $ParentCategory, $count);
490
                            $this->entityManager->persist($ProductCategory);
491
                            $count++;
492
                            /* @var $Product \Eccube\Entity\Product */
493
                            $Product->addProductCategory($ProductCategory);
494
                            $categoriesIdList[$ParentCategory->getId()] = true;
495
                        }
496
                    }
497
                    if (!isset($categoriesIdList[$Category->getId()])){
498
                        $ProductCategory = $this->createProductCategory($Product, $Category, $count);
499
                        $this->entityManager->persist($ProductCategory);