4

How can I add Layered Navigation in Advance Search result page(2 Column Left layout)?

How can I dot it?

2 Answers 2

3

Override catalogsearch_advanced_index.xml in your theme

From

vendor/magento/module-catalog-search/view/frontend/layout/catalogsearch_advanced_index.xml

To

app/design/frontend/Vendor/theme/Magento_CatalogSearch/layout/catalogsearch_advanced_index.xml

Now change layout 1column to 2columns-left

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

Now add container sidebar.main with left navigation block

Your final catalogsearch_advanced_index.xml like this

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>Advanced Search</title>
    </head>
    <update handle="page_calendar"/>
    <body>
        <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>
        <referenceContainer name="content">
            <block class="Magento\CatalogSearch\Block\Advanced\Form" name="catalogsearch_advanced_form" template="advanced/form.phtml"/>
            <block class="Magento\Framework\View\Element\Html\Calendar" name="html_calendar" as="html_calendar" template="Magento_Theme::js/calendar.phtml"/>
        </referenceContainer>
    </body>
</page>

Same way you need to override

1) catalogsearch_advanced_result.xml and

2) catalogsearch_result_index.xml

2
  • For me this shows the filters however they show all the filters and are not restricted to available options for the current collection. Is this normal?
    – harri
    Oct 6, 2017 at 9:56
  • Also for me, it show all the filters. Aug 22, 2019 at 10:47
1

Create new file catalogsearch_advanced_result.xml at path

app/design/frontend/Vendor/theme/Magento_LayeredNavigation/layout/

and add following code in file

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.main">
            <block class="Magento\LayeredNavigation\Block\Navigation\Search" name="catalogsearch.advanced.leftnav" before="-" template="layer/view.phtml">
                <block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalogsearch.advanced.navigation.state" as="state" />
                <block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalogsearch.advanced.navigation.renderer" as="renderer" template="layer/filter.phtml"/>
            </block>
        </referenceContainer>
    </body>
</page>
1
  • I've tried all of the suggestions but I'm unable to display Layered Navigation on the advanced search index Magento 2.4.0 Aug 28, 2020 at 14:22

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.