Code Duplication    Length = 9-10 lines in 2 locations

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

@@ 499-508 (lines=10) @@
496
                $Categories = $form->get('Category')->getData();
497
                $categoriesIdList = [];
498
                foreach ($Categories as $Category) {
499
                    foreach ($Category->getPath() as $ParentCategory) {
500
                        if (!isset($categoriesIdList[$ParentCategory->getId()])) {
501
                            $ProductCategory = $this->createProductCategory($Product, $ParentCategory, $count);
502
                            $this->entityManager->persist($ProductCategory);
503
                            $count++;
504
                            /* @var $Product \Eccube\Entity\Product */
505
                            $Product->addProductCategory($ProductCategory);
506
                            $categoriesIdList[$ParentCategory->getId()] = true;
507
                        }
508
                    }
509
                    if (!isset($categoriesIdList[$Category->getId()])) {
510
                        $ProductCategory = $this->createProductCategory($Product, $Category, $count);
511
                        $this->entityManager->persist($ProductCategory);

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

@@ 739-747 (lines=9) @@
736
                        ]);
737
                        $this->addErrors($message);
738
                    } else {
739
                        foreach ($Category->getPath() as $ParentCategory) {
740
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
741
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
742
                                $this->entityManager->persist($ProductCategory);
743
                                $sortNo++;
744
745
                                $Product->addProductCategory($ProductCategory);
746
                                $categoriesIdList[$ParentCategory->getId()] = true;
747
                            }
748
                        }
749
                        if (!isset($categoriesIdList[$Category->getId()])) {
750
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);