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

@@ 936-944 (lines=9) @@
933
                        ]);
934
                        $this->addErrors($message);
935
                    } else {
936
                        foreach ($Category->getPath() as $ParentCategory) {
937
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
938
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
939
                                $this->entityManager->persist($ProductCategory);
940
                                $sortNo++;
941
942
                                $Product->addProductCategory($ProductCategory);
943
                                $categoriesIdList[$ParentCategory->getId()] = true;
944
                            }
945
                        }
946
                        if (!isset($categoriesIdList[$Category->getId()])) {
947
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);