1

I need to list out categories and child categories in the left nav of the category page and I'm trying to use this extension:

https://github.com/Sebwite/magento2-category-sidebar

As of now all that it is doing is showing the to root category and not pulling in any of the child categories:
enter image description here

Is there another solution to this? Or does someone have experience with this particular extension and would know what is going on?

  • 1
    Is all parent categories have Is Anchor value yes if not make it yes and re-index and try. – Aman Alam Jun 22 '16 at 21:42
  • You welcome always – Aman Alam Jun 23 '16 at 5:33
  • I also encountered the same problem, please tell me how to do? I have run the command: php bin / magento indexer: reindex However, no change – user41664 Jul 1 '16 at 13:46
  • I followed Aman's instructions and made sure all of my parent categories has Is Anchor set to yes and then I ran php bin/magento indexer:reindex at the root install of magento 2. Also, make sure you have caching turned off or clear your cache after running the command. – Paul Jul 1 '16 at 14:38
  • I also have the same issue and I fix this using Is Anchor . I want to remove the "Default category " from left side bar , Its working fine in local server , but on dev server the left sidebar start with "Default Category" . I did check all the settings and everything is same. – Pravin May 12 '17 at 7:34
0

After reindexing my data, it worked. I just ran this at the webroot of my magento install:

php bin/magento indexer:reindex
0

In my case, I installed this extension with composer. And it also has this bug. I downloaded zip package and reinstall it. And now it works. The package with composer was out of date.

0

We can get categories and subcategories by below code at anywhere

<?php
$objectManagerr = \Magento\Framework\App\ObjectManager::getInstance();
                    $categoryFactory = $objectManagerr->create('Magento\Catalog\Model\ResourceModel\Category\CollectionFactory');

                    $categories = $categoryFactory->create()                              
                                ->addAttributeToSelect('*');

foreach ($categories as $category){  
$catId = $category->getId();
echo $category->getName();
$subcategory = $objectManagerr->create('Magento\Catalog\Model\Category')->load($catId);
$subcats = $subcategory->getChildrenCategories();
    foreach ($subcats as $subcat) {
        $_category = $objectManagerr->create('Magento\Catalog\Model\Category')->load($subcat->getId());
        echo $_category->getName();
    }
} 
?>
  • As per the magento 2 concept Object manager is not standard way to do. you need to use factory method. Many of the developers are recommending standard solutions that will definately help someone to follow the standard solution. – jack Oct 28 '17 at 12:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.