0

Pretty much self-explanatory.

I create a category model using category factory and then use the ->save method to save the category. I can see some data created, along with catalog_category_entity, but the category is not visible in admin. This is the code that I use:

public function createCategory($categoryName="", $categoryDescription="", $parentCategoryId=2, $position=1) {

        /// Add a new sub category under root category
        $categoryTmp = $this->cf->create();
        $categoryTmp->setName($categoryName);
        $categoryTmp->setIsActive(true);
        $categoryTmp->setUrlKey("cat-" . $categoryName);
        $categoryTmp->setData("description", $categoryDescription);
        $categoryTmp->setParentId($parentCategoryId);
        $categoryTmp->setStoreId(0);
        $categoryTmp->setPath("2");

        $categoryTmp->save(); //Using this save method, because the perfion import procedure is not time-demanding 
        return $categoryTmp;
    }

What am I missing here?

  • My guess would be 1) Not assigned inside Root Category which is Default category. 2) Store not assigned. – Kingshuk Deb Apr 11 '17 at 13:05
  • I assign it under an existing category. StoreId is also assigned. – Vladimir Despotovic Apr 11 '17 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.