Code Duplication    Length = 9-10 lines in 2 locations

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

@@ 863-871 (lines=9) @@
860
                        ]);
861
                        $this->addErrors($message);
862
                    } else {
863
                        foreach ($Category->getPath() as $ParentCategory) {
864
                            if (!isset($categoriesIdList[$ParentCategory->getId()])) {
865
                                $ProductCategory = $this->makeProductCategory($Product, $ParentCategory, $sortNo);
866
                                $this->entityManager->persist($ProductCategory);
867
                                $sortNo++;
868
869
                                $Product->addProductCategory($ProductCategory);
870
                                $categoriesIdList[$ParentCategory->getId()] = true;
871
                            }
872
                        }
873
                        if (!isset($categoriesIdList[$Category->getId()])) {
874
                            $ProductCategory = $this->makeProductCategory($Product, $Category, $sortNo);

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