0

I want to do something like this to add a filter: http://demo-acm2.bird.eu/gear/bags.html

How and where to add that ? I've overrided catalog_category_view.xml to have a custom layout:

EDIT : to be more clear, I want to show ALL the layered-filter-block part, I have only "Wishlist" and "Compare", but I don't have the block on top of them (on the link it is called "Shopping Option")

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="columns.top">
            <container name="category.view.container" htmlTag="div" htmlClass="category-view" after="-">
                <!--<block class="Magento\Catalog\Block\Category\View" name="category.image" template="Magento_Catalog::category/image.phtml"/>-->
                <block class="Magento\Catalog\Block\Category\View" name="category.description" template="Magento_Catalog::category/description.phtml"/>
                <block class="Magento\Catalog\Block\Category\View" name="category.cms" template="Magento_Catalog::category/cms.phtml"/>
            </container>
        </referenceContainer>
        <referenceContainer name="content">
            <block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml">
                <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" name="category.product.type.details.renderers.default" 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>
            </block>
            <block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml">
                <arguments>
                    <argument name="triggers" xsi:type="array">
                        <item name="compareProductLink" xsi:type="string">.action.tocompare</item>
                    </argument>
                </arguments>
            </block>
        </referenceContainer>
        <referenceBlock name="page.main.title">
            <!--<arguments>-->
                <!--<argument name="id" xsi:type="string">page-title-heading</argument>-->
                <!--<argument name="add_base_attribute_aria" xsi:type="string">page-title-heading toolbar-amount</argument>-->
            <!--</arguments>-->
            <block class="Magento\Catalog\Block\Category\Rss\Link" name="rss.link" template="Magento_Catalog::category/rss.phtml"/>
        </referenceBlock>

        <!--<referenceBlock name="catalog.compare.sidebar" remove="true"/>-->
        <!--<referenceBlock name="product_list_toolbar" remove="true"/>-->
    </body>
</page>
0

There is no need to write code for it. Magento by default provides the option to show attributes under filters.

To do so:

  • Go to Stores > Attributes (Product).
  • Click on existing attribute which you want to show under frontend filters.
  • Change the value of Use in Layered Navigation from No to either Filterable (with results) or Filterable (no results).
  • Save the attribute and do the reindexing.

That's all.

  • I already have some product with Filterable. In my browser, on the left side I have only "Compare" and "Wishlist", I don't have any filter – Morgan Tartreau Jun 26 '18 at 14:00
  • @MorganTartreau, Have you followed the process mentioned in the answer? – Mohit Kumar Arora Jun 26 '18 at 14:04
  • Yes I have done that – Morgan Tartreau Jun 26 '18 at 14:06
0

Solution : don't forget to add attributs to products, otherwise the filter layer won't showing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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