I can remove all filters in category with this line:

<referenceContainer name="catalog.leftnav" remove="true" />

But, I need to remove only price filter for specific category. Can I do this with "Layout Update XML"?

This is a filter block structure:

enter image description here

I can use JS to find and remove price filter title or use css to remove last two elements for filter-options. But maybe there is another way to remove it completely via XML?



The easiest way to achieve this is to add a custom class on the body tag for that category via layout update XML, and then hide the price filter when that class exists:

First, depending on your theme and if you have a custom layered navigation module installed, you need to add a CSS class name to identify the price filter. If you're using standard Magento layered navigation, you need to add the filter view file inside your theme (copy from parent theme): app/design/frontend/[PACKAGE]/[THEME]/Magento_LayeredNavigation/templates/layer/view.phtml

And around line 38, add the filter code in class attribute:

<?php foreach ($block->getFilters() as $filter): ?>
    <?php if ($filter->getItemsCount()): ?>
        <div data-role="collapsible" class="filter-options-item filter-<?= /* @escapeNotVerified */ $filter->getCode() ?>">
    <?php endif; ?>
<?php endforeach; ?>

Then, add category layout update xml:

    <attribute name="class" value="hide-price-filter"/>

And finally a CSS rule:

body.hide-price-filter {
    .filter-price {
        display: none;

Of course, there are other methods too, which can completely remove the filter from the category, if proposed solution is not acceptable, but you would have to extend the Magento_LayeredNavigation module via plugins and add the desired functionality

  • Hi. Thank's for the reply. I already have a class on the body tag. And I can remove price-slider-wrap. But, what about filter-options-title and filter-options-content? Watch the screen in my question. I can use JS, to find a price filter title and remove it or use css, for hiding the last elements. But, maybe there someone know a better way to remove it completely via xml? Feb 2 '19 at 13:21
  • You can't via XML without making a module. Based on your updated answer, you can add the filter specific class to both dt and dd tags
    – Alex Dinca
    Feb 4 '19 at 8:48

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.