2

When I click on the parent category 'shoes' I am able to filter by sub categories within the parent category ('shoes') only. I would like to see all categories and sub-categories in the sidebar.

Can anyone please assist with a solution to displaying all categories in the sidebar of my Magento store?

2 Answers 2

1

Add the below code in your theme’s catalog XML file like this:

<reference name="left">
    <block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/my_left_nav.phtml" />
</refrence>

It should be placed inside the reference name “left“, to show it in the left sidebar. I hope you know all these stuffs. Let’s get to the point. Just copy and paste the code in the my_left_nav.phtml, which should be in your theme’s catalog/navigation folder.

<!-- List all categories and their second level subcategories -->
<div class="block block-list block-categories">
    <div id="block-categories" class="block-title active">
        <strong><span>Categories </span></strong>
    </div>

<div id="leftnav" class="block-content" style="display:block">
    <?php $helper = $this->helper('catalog/category') ?>
    <?php $categories = $this->getStoreCategories() ?>
    <?php if (count($categories) > 0): ?>
        <ul id="leftnav-tree" class="level0">
            <?php foreach($categories as $category): ?>
                <li class="level0<?php if ($this->isCategoryActive($category)): ?> active<?php endif; ?>">
                    <a href="<?php echo $helper->getCategoryUrl($category) ?>"><span><?php echo $this->escapeHtml($category->getName()) ?></span></a>
                    <?php //if ($this->isCategoryActive($category)): ?>
                        <?php $subcategories = $category->getChildren() ?>
                        <?php if (count($subcategories) > 0): ?>
                            <ul id="leftnav-tree-<?php echo $category->getId() ?>" class="level1">
                                <?php foreach($subcategories as $subcategory): ?>
                                    <li class="level1<?php if ($this->isCategoryActive($subcategory)): ?> active<?php endif; ?>">
                                        <a href="<?php echo $helper->getCategoryUrl($subcategory) ?>"><?php echo $this->escapeHtml(trim($subcategory->getName(), '- ')) ?></a>
                                         <?php $secondLevelSubcategories = $subcategory->getChildren() ?>
                                         <?php if (count($secondLevelSubcategories ) > 0): ?>
                            <ul id="leftnav-tree-<?php echo $subcategory->getId() ?>" class="level2">
                                <?php foreach($secondLevelSubcategories as $secondLevelSubcategory ): ?>
                                    <li class="level2<?php if ($this->isCategoryActive($secondLevelSubcategory )): ?> active<?php endif; ?>">
                                        <a href="<?php echo $helper->getCategoryUrl($secondLevelSubcategory ) ?>"><?php echo $this->escapeHtml(trim($secondLevelSubcategory ->getName(), '- ')) ?></a>
                                    </li>
                                    <?php endforeach; ?>
                            </ul>
                            <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
                        <?php endif; ?>
                                <?php endforeach; ?>
                            </ul>
                            <script type="text/javascript">decorateList('leftnav-tree-<?php echo $category->getId() ?>', 'recursive')</script>
                        <?php endif; ?>
                    <?php //endif; ?>
                </li>
            <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('leftnav-tree', 'recursive')</script>
    <?php endif; ?>
</div>
</div>

Hope it will help you.

1
  • Thank you for the response Aruendra. However, this still only shows category options for the children of the parent category I am in. I want to show all categories in the left sidebar, regardless of the category the user is in. Mar 8, 2016 at 14:14
-1

proxiblue's link doesn't work anymore. Still free here: https://www.magecloud.net/marketplace/extension/sidebar-navigation-menu-professional/

Just tested with 1.9 and it still works. Except the original left navigation menu is still there. I'm trying to figure out how to get rid of that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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