Code Duplication    Length = 9-10 lines in 2 locations

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

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

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

@@ 947-955 (lines=9) @@
944
                        ]);
945
                        $this->addErrors($message);
946
                    } else {
947
                        foreach ($Category->getPath() as $ParentCategory) {
948
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
949
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
950
                                $this->entityManager->persist($ProductCategory);
951
                                $sortNo++;
952
953
                                $Product->addProductCategory($ProductCategory);
954
                                $categoriesIdList[$ParentCategory->getId()] = true;
955
                            }
956
                        }
957
                        if (!isset($categoriesIdList[$Category->getId()])) {
958
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);