Reputation: 101
I am trying to display Layered Navigation Block on custom page with custom product list.
For now i have custom controller, xml layout and template for product list.
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
Upvotes: 10
Views: 3685
Reputation: 681
The XML you need can be found in Magento/LayeredNavigation/view/frontend/layout/catalog_category_view_type_layered.xml
The snippet you'll need to add to your referenceContainer is:
<block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="Magento_LayeredNavigation::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="Magento_LayeredNavigation::layer/filter.phtml"/>
</block>
I would suggest using a plugin to modify the render method of "Magento\LayeredNavigation\Block\Navigation\FilterRenderer" if you want to set a default filter.
Upvotes: 1