3

I am working on a Magento 2.1.7 shop.

The products are organized into categories and subcategories.

Whenever a customer visits a category, filters (links to its subcategories) are displayed. I want to disable the filters.

The path to the file responsible with the filters is

vendor/magento/module-catalog/view/frontend/templates/navigation/left.phtml

I want to overwrite it from app/design/frontend/myCompany/myTheme/.

  1. How do I disable filters by coding?
  2. Can the filters be disabled from Magento admin?
  • Do you want to remove all filters or just Subcategory type? – Vlad Patru Jan 9 '18 at 11:51
  • Can you tell me which filter options you want to remove? Or remove entire filteration part from category page? – Dhiren Vasoya Jan 9 '18 at 11:57
  • I want to remove the links to the subcategories from the category pages. – Razvan Zamfir Jan 9 '18 at 12:00
1

In your theme directory create ( if the file is not existing already ) Magento_Catalog/layout/catalog_category_view.xml and remove the block by adding the following line <referenceBlock name="catalog.leftnav" remove="true" /> do not forget to add the xml needed nodes. Your code should look something like the below example.

<?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">
    <body>
        <referenceBlock name="catalog.leftnav" remove="true"/>
    </body>
</page>
1

Try to replace code under app/design/frontend/{Vendor}}/{themename}}/Magento_LayeredNavigation/templates/layer/view.phtml

From

<?php foreach ($block->getFilters() as $filter): ?>
    <?php if (!$wrapOptions): ?>
        <strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?= /* @escapeNotVerified */ __('Shopping Options') ?></strong>
        <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"><?= /* @escapeNotVerified */ $block->getChildBlock('renderer')->render($filter) ?></dd>
        <?php endif; ?>
<?php endforeach; ?>

To

<?php foreach ($block->getFilters() as $filter): ?>
    <?php if (!$wrapOptions): ?>
        <strong role="heading" aria-level="2" class="block-subtitle filter-subtitle"><?php /* @escapeNotVerified */ echo __('Shopping Options') ?></strong>
        <dl class="filter-options" id="narrow-by-list">
    <?php $wrapOptions = true; endif; ?>
    <?php  if($filter->getName() != __('Category')): ?>
        <?php if ($filter->getItemsCount()): ?>
            <dt role="heading" aria-level="3" class="filter-options-title"><?php echo $block->escapeHtml(__($filter->getName())) ?></dt>
            <dd class="filter-options-content"><?php /* @escapeNotVerified */ echo $block->getChildBlock('renderer')->render($filter); ?></dd>
        <?php endif; ?>
        <?php endif; ?>
<?php endforeach; ?>
0

You can try configure:

Store > Configuration > CATALOG > Catalog > Categories > select category that you want > select tab Display Settings > select No > Save

  • It will remove all products on the child category – PY Yick Jun 7 '18 at 7:38

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.