cancel
Showing results for 
Search instead for 
Did you mean: 

Layered navigation on category pages

Layered navigation on category pages

I am trying to get the layered navigation showing on my category pages. I have set the required categories as anchors, I have created and set up the attributes I wish to be filterable in the navigation - this appears to be working fine on the search results page. However I am unable to get the layered navigation to show on the category page.

There is nothing in the theme to suggest the layered nav should show up on the category pages so I added the following to the catalog_category_view.xml

 

<referenceContainer name="sidebar.main">
<block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="layer/view.phtml">
<block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state" as="state" />
<block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalog.navigation.renderer" as="renderer" template="layer/filter.phtml"/>
</block>
</referenceContainer>

 

This appears to have no affect though, with cache clear, reindex, etc. I cannot see anywhere that there is an error, and it's all coming through fine on the search results page.

How would I get the layered navigation to display properly on the category pages? (I know 2.1.3 is not the stablest of versions but currently impossible to run an update)

6 REPLIES 6

Re: Layered navigation on category pages

It appears to as it gets the compare and wishlist on the left hand side as well, catalog_category_view.xml is using:

 

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

Re: Layered navigation on category pages

OK, if wishlist and compare sidebar is coming means, you have 2columns-left sidebar exist,

But By default Layered navigation is coming if your category is an anchor.

 

You don't need to write any custom code for get layered navigation in category page.

 

Could you please share your link so we can debug your issue. Might be you have one product in category page so layered navigation does not display.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Layered navigation on category pages

There are several products in the category and I have set the attribute to show regardless of if there are results (Filterable without results). When debugging is on, I cannot even see an empty red outline for this block.

 

I cannot currently share a link.

Re: Layered navigation on category pages

Kindly check your code with, accidentally you removed the sidebar block for layered navigation using xml or plz check for layered navigation with display none is not set.

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: Layered navigation on category pages

I cannot see any CSS removing sidebar-main and I cannot find any XML removing sidebar.main either.

Re: Layered navigation on category pages - HELP!

Hello, please can you let me know if you managed to fix this problem. I feel like I am doing something very stupid but cannot find a solution!!!