Magento 2.1.0, own theme based on Luma
Hello everybody,
I configured product attributes correctly and was surprised that the attribute filters were only displayed on the category pages in the sidebar, but not on the home page. I then found a solution and placed the following code in the file default.xml (/Magento_Theme/layout/default.xml) within the folder structure of my theme:
<referenceContainer name = "sidebar.additional"> <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>
Since then I have had the attribute filter on the home page, but when you click a filter, the products are not filtered even though the URL appears to be correct: /index.php/?cpu_units=13.
On the category pages, where it works, the URL is, for example /index.php/server.html?cpu_units=13.
Does anyone have a tip where I would have to change something so that the filters work?
Thank you for any feedback!
Solved! Go to Solution.
I found a solution by adding this code to my default.xml:
<referenceContainer name="content"> <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml"> <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\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>
I found a solution by adding this code to my default.xml:
<referenceContainer name="content"> <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml"> <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\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>