Code Duplication    Length = 9-10 lines in 2 locations

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

@@ 367-376 (lines=10) @@
364
                $Categories = $form->get('Category')->getData();
365
                $categoriesIdList = array();
366
                foreach ($Categories as $Category) {
367
                    foreach($Category->getPath() as $ParentCategory){
368
                        if (!isset($categoriesIdList[$ParentCategory->getId()])){
369
                            $ProductCategory = $this->createProductCategory($Product, $ParentCategory, $count);
370
                            $app['orm.em']->persist($ProductCategory);
371
                            $count++;
372
                            /* @var $Product \Eccube\Entity\Product */
373
                            $Product->addProductCategory($ProductCategory);
374
                            $categoriesIdList[$ParentCategory->getId()] = true;
375
                        }
376
                    }
377
                    if (!isset($categoriesIdList[$Category->getId()])){
378
                        $ProductCategory = $this->createProductCategory($Product, $Category, $count);
379
                        $app['orm.em']->persist($ProductCategory);

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

@@ 750-758 (lines=9) @@
747
                if (!$Category) {
748
                    $this->addErrors(($data->key() + 1).'行目の商品カテゴリ(ID)「'.$category.'」が存在しません。');
749
                } else {
750
                    foreach($Category->getPath() as $ParentCategory){
751
                        if (!isset($categoriesIdList[$ParentCategory->getId()])){
752
                            $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $rank);
753
                            $app['orm.em']->persist($ProductCategory);
754
                            $rank++;
755
                            $Product->addProductCategory($ProductCategory);
756
                            $categoriesIdList[$ParentCategory->getId()] = true;
757
                        }
758
                    }
759
                    if (!isset($categoriesIdList[$Category->getId()])){
760
                        $ProductCategory = $this->makeProductCategory($Product, $Category, $rank);
761
                        $rank++;