Code Duplication    Length = 9-10 lines in 2 locations

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

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

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

@@ 760-768 (lines=9) @@
757
                        ]);
758
                        $this->addErrors($message);
759
                    } else {
760
                        foreach ($Category->getPath() as $ParentCategory) {
761
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
762
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
763
                                $this->entityManager->persist($ProductCategory);
764
                                $sortNo++;
765
766
                                $Product->addProductCategory($ProductCategory);
767
                                $categoriesIdList[$ParentCategory->getId()] = true;
768
                            }
769
                        }
770
                        if (!isset($categoriesIdList[$Category->getId()])) {
771
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);