Skip to main content
2 of 5
answer updated
Sushivam
  • 2.6k
  • 3
  • 36
  • 88

function displaying the number of found products in layered navigation filters in magento2

Which function is responsible for displaying the total count of products in the filters in the layered navigation.

ie) i need to get the count (eg 50 ) in my custom filterable attributes as well.

enter image description here

This is how i have overridden filter.phtml in my

\Vendor\LayeredNavigation\view\frontend\layout\catalogsearch_result_index.xml

<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock class="Vendor\LayeredNavigation\Block\Navigation" before="-" name="catalogsearch.leftnav">
      <action method="setTemplate">
        <argument name="template" xsi:type="string">Vendor_LayeredNavigation::layer/view.phtml</argument>
      </action>
    </referenceBlock>
    
    <referenceContainer name="content">
        <block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalogsearch.navigation.renderer" as="renderer" template="layer/filter.phtml"/>
    </referenceContainer>
</body>
Sushivam
  • 2.6k
  • 3
  • 36
  • 88