Im working on a filter module using Magento_LayeredNavigation module. I installed sample data to check my filter i works it doesnt work on someplaces and it works on someplaces.

enter image description here

In the picture above it doesnt show but in pic below it shows

enter image description here

here is catalog_category_view_type_layered.xml

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <script src="Prevaj_QuickFilter::js/QuickFilter.js"/>
        <attribute name="class" value="page-with-filter"/>
        <referenceContainer name="sidebar.main">
            <block class="Magento\LayeredNavigation\Block\Navigation\Category" name="catalog.leftnav" before="-" template="Prevaj_QuickFilter::layer/view.phtml">
                <block class="Magento\LayeredNavigation\Block\Navigation\State" name="catalog.navigation.state" as="state" template="Prevaj_QuickFilter::layer/state.phtml"/>
                <block class="Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalog.navigation.renderer" as="renderer" template="Prevaj_QuickFilter::layer/filter.phtml"/>

here is view.phtml

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 * Category layered navigation
 * @var $block \Magento\LayeredNavigation\Block\Navigation

<?php if ($block->canShowBlock()) : ?>
    <div class="block filter">
        <div class="block-title filter-title" style="display:block">
            <strong><?= $block->escapeHtml(__('Shop By')) ?></strong>

        <div class="block-content filter-content">
            <?= $block->getChildHtml('state') ?>

            <?php if ($block->getLayer()->getState()->getFilters()) : ?>
                <div class="block-actions filter-actions" style="display:block">
                    <a href="<?= $block->escapeUrl($block->getClearUrl()) ?>" class="action clear filter-clear" style="display:block"><span><?= $block->escapeHtml(__('Clear All')) ?></span></a>
            <?php endif; ?>
            <?php $wrapOptions = false; ?>
            <?php foreach ($block->getFilters() as $filter) : ?>
                <?php if (!$wrapOptions) : ?>
                    <dl class="filter-options" id="narrow-by-list">
                    <?php $wrapOptions = true;
                endif; ?>
                    <?php if ($filter->getItemsCount()) : ?>
                        <dt role="heading" aria-level="3" class="filter-options-title"><?= $block->escapeHtml(__($filter->getName())) ?></dt>
                        <dd class="filter-options-content"><?= /* @noEscape */ $block->getChildBlock('renderer')->render($filter) ?></dd>
                    <?php endif; ?>
            <?php endforeach; ?>
            <?php if ($wrapOptions) : ?>
            <?php endif; ?>
            <div class="filter-action">
                <button class="action cancel" onclick = 'QuickFilter.cancelFilter()'>Cancel</button>
                <button class="action apply" onclick = 'QuickFilter.applyFilter()'>Apply Filters</button>
<?php endif; ?>

Your Answer

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

Browse other questions tagged or ask your own question.