0

I want layered navigation on CMS page with selected cateogry. I am following this link

It is showing all category and attribute. But I don't know how to set selected category. For example on Clothing CMS page want to show attributes of Shirt category in layered navigation.

2 Answers 2

2

This link might help you: https://swissuplabs.com/blog/practical-guide-magento-and-magento-2-layered-navigation/

XML to show layered navigation on home:

<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>

XML to show products:

<referenceContainer name="content">
    <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
        <container name="category.product.list.additional" as="additional" />
        <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
            <block class="Magento\Framework\View\Element\Template" as="default"/>
        </block>
        <block class="Magento\Catalog\Block\Product\ProductList\Item\Container" name="category.product.addto" as="addto">
            <block class="Magento\Catalog\Block\Product\ProductList\Item\AddTo\Compare"
                   name="category.product.addto.compare" as="compare"
                   template="Magento_Catalog::product/list/addto/compare.phtml"/>
        </block>
        <block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="Magento_Catalog::product/list/toolbar.phtml">
            <block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
        </block>
        <action method="setToolbarBlockName">
            <argument name="name" xsi:type="string">product_list_toolbar</argument>
        </action>
    </block>
</referenceContainer>
0

Is it possible to add attribute selection via layout update as well? I only found the category filter, but not for the attributes

<arguments>
        <argument name="category_id" xsi:type="string">83</argument>
</arguments>

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.