diff --git a/Console/Command/CategoriesCommand.php b/Console/Command/CategoriesCommand.php index 567dfd2..712cf81 100644 --- a/Console/Command/CategoriesCommand.php +++ b/Console/Command/CategoriesCommand.php @@ -142,7 +142,7 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new LocalizedException(__('Please specify path to file! (eg. "var/import/categories.csv")')); } $additionalHeadersDefinedByUser = explode(',', $input->getOption('additional')); - $this->additionalHeaders = array_merge($this->additionalHeaders, $additionalHeadersDefinedByUser); + $this->additionalHeaders = array_filter(array_merge($this->additionalHeaders, $additionalHeadersDefinedByUser)); $file = $this->directoryList->getRoot() . '/' . $path; @@ -264,7 +264,8 @@ protected function addOrUpdateCategory($data, $isParent = false) $category->setIsActive($this->getOptionalAttributeValue($data, 'is_active', true)); $category->setIncludeInMenu($this->getOptionalAttributeValue($data, 'include_in_menu', true)); if ($isParent) { - $category->setParentId(2); + $rootCategoryId = $this->storeManager->getStore(1)->getRootCategoryId(); + $category->setParentId($rootCategoryId); } else { $categoryCollection = $this->getCategoryFromCollectionByOldId($categoryFactory, $data, 'parent_id'); if ($categoryCollection->getSize()) {