Code Duplication    Length = 9-10 lines in 2 locations

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);

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

@@ 558-567 (lines=10) @@
555
                $Categories = $form->get('Category')->getData();
556
                $categoriesIdList = [];
557
                foreach ($Categories as $Category) {
558
                    foreach ($Category->getPath() as $ParentCategory) {
559
                        if (!isset($categoriesIdList[$ParentCategory->getId()])) {
560
                            $ProductCategory = $this->createProductCategory($Product, $ParentCategory, $count);
561
                            $this->entityManager->persist($ProductCategory);
562
                            $count++;
563
                            /* @var $Product \Eccube\Entity\Product */
564
                            $Product->addProductCategory($ProductCategory);
565
                            $categoriesIdList[$ParentCategory->getId()] = true;
566
                        }
567
                    }
568
                    if (!isset($categoriesIdList[$Category->getId()])) {
569
                        $ProductCategory = $this->createProductCategory($Product, $Category, $count);
570
                        $this->entityManager->persist($ProductCategory);