How to Remove Categories Filter from the Sidebar












1















in Magento 2.1, I would like to have the Category filter removed from the sidebar when in the shop category page, leaving the price filter untouched.



So far I have tried unsetting the category as anchor, which doesn't change anything. I am able to remove the whole sidebar with XML, but that's not ideal because I want to keep using the price filter.










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    in Magento 2.1, I would like to have the Category filter removed from the sidebar when in the shop category page, leaving the price filter untouched.



    So far I have tried unsetting the category as anchor, which doesn't change anything. I am able to remove the whole sidebar with XML, but that's not ideal because I want to keep using the price filter.










    share|improve this question
















    bumped to the homepage by Community 6 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      in Magento 2.1, I would like to have the Category filter removed from the sidebar when in the shop category page, leaving the price filter untouched.



      So far I have tried unsetting the category as anchor, which doesn't change anything. I am able to remove the whole sidebar with XML, but that's not ideal because I want to keep using the price filter.










      share|improve this question
















      in Magento 2.1, I would like to have the Category filter removed from the sidebar when in the shop category page, leaving the price filter untouched.



      So far I have tried unsetting the category as anchor, which doesn't change anything. I am able to remove the whole sidebar with XML, but that's not ideal because I want to keep using the price filter.







      magento2 magento-2.1 filter sidebar






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 4 '18 at 22:50







      Martijnr

















      asked Jun 1 '18 at 4:20









      MartijnrMartijnr

      64




      64





      bumped to the homepage by Community 6 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 6 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Override view.phtml file in your theme



          From




          vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml




          To




          app/design/frontend/{Vendor}/{theme}/Magento_LayeredNavigation/templates/layer/view.phtml




          Now set condition for category before $filter->getItemsCount(),



          <?php  

          if($filter->getName() != __('Category')) {
          ...
          ...
          }

          ?>


          Final code looks like this



          ...
          ...
          <?php $wrapOptions = false; ?>
          <?php foreach ($block->getFilters() as $filter): ?>
          ...
          <?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; ?>
          ...
          ...





          share|improve this answer
























          • This unfortunately did not work for me.

            – Martijnr
            Jun 4 '18 at 1:45











          • @Martijnr face any issue?

            – Prince Patel
            Jun 4 '18 at 5:02











          • This did not change anything. Any other suggestions Prince?

            – Martijnr
            Jun 4 '18 at 23:47



















          0














          I am assuming you are referring cart page as shopping page.



          In your theme, checkout_cart_index.xml add <referenceBlock name="catalog.leftnav" remove="true" /> as follows



          <page layout="1column" 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>


          Default Magento doesn't have layered navigation on cart page.



          To remove it from every where you can use above in your theme default.xml or in catalog_category_view_type_default.xml






          share|improve this answer
























          • I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

            – Martijnr
            Jun 4 '18 at 23:49











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f228271%2fhow-to-remove-categories-filter-from-the-sidebar%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Override view.phtml file in your theme



          From




          vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml




          To




          app/design/frontend/{Vendor}/{theme}/Magento_LayeredNavigation/templates/layer/view.phtml




          Now set condition for category before $filter->getItemsCount(),



          <?php  

          if($filter->getName() != __('Category')) {
          ...
          ...
          }

          ?>


          Final code looks like this



          ...
          ...
          <?php $wrapOptions = false; ?>
          <?php foreach ($block->getFilters() as $filter): ?>
          ...
          <?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; ?>
          ...
          ...





          share|improve this answer
























          • This unfortunately did not work for me.

            – Martijnr
            Jun 4 '18 at 1:45











          • @Martijnr face any issue?

            – Prince Patel
            Jun 4 '18 at 5:02











          • This did not change anything. Any other suggestions Prince?

            – Martijnr
            Jun 4 '18 at 23:47
















          0














          Override view.phtml file in your theme



          From




          vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml




          To




          app/design/frontend/{Vendor}/{theme}/Magento_LayeredNavigation/templates/layer/view.phtml




          Now set condition for category before $filter->getItemsCount(),



          <?php  

          if($filter->getName() != __('Category')) {
          ...
          ...
          }

          ?>


          Final code looks like this



          ...
          ...
          <?php $wrapOptions = false; ?>
          <?php foreach ($block->getFilters() as $filter): ?>
          ...
          <?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; ?>
          ...
          ...





          share|improve this answer
























          • This unfortunately did not work for me.

            – Martijnr
            Jun 4 '18 at 1:45











          • @Martijnr face any issue?

            – Prince Patel
            Jun 4 '18 at 5:02











          • This did not change anything. Any other suggestions Prince?

            – Martijnr
            Jun 4 '18 at 23:47














          0












          0








          0







          Override view.phtml file in your theme



          From




          vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml




          To




          app/design/frontend/{Vendor}/{theme}/Magento_LayeredNavigation/templates/layer/view.phtml




          Now set condition for category before $filter->getItemsCount(),



          <?php  

          if($filter->getName() != __('Category')) {
          ...
          ...
          }

          ?>


          Final code looks like this



          ...
          ...
          <?php $wrapOptions = false; ?>
          <?php foreach ($block->getFilters() as $filter): ?>
          ...
          <?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; ?>
          ...
          ...





          share|improve this answer













          Override view.phtml file in your theme



          From




          vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml




          To




          app/design/frontend/{Vendor}/{theme}/Magento_LayeredNavigation/templates/layer/view.phtml




          Now set condition for category before $filter->getItemsCount(),



          <?php  

          if($filter->getName() != __('Category')) {
          ...
          ...
          }

          ?>


          Final code looks like this



          ...
          ...
          <?php $wrapOptions = false; ?>
          <?php foreach ($block->getFilters() as $filter): ?>
          ...
          <?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; ?>
          ...
          ...






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 1 '18 at 5:16









          Prince PatelPrince Patel

          13.6k55179




          13.6k55179













          • This unfortunately did not work for me.

            – Martijnr
            Jun 4 '18 at 1:45











          • @Martijnr face any issue?

            – Prince Patel
            Jun 4 '18 at 5:02











          • This did not change anything. Any other suggestions Prince?

            – Martijnr
            Jun 4 '18 at 23:47



















          • This unfortunately did not work for me.

            – Martijnr
            Jun 4 '18 at 1:45











          • @Martijnr face any issue?

            – Prince Patel
            Jun 4 '18 at 5:02











          • This did not change anything. Any other suggestions Prince?

            – Martijnr
            Jun 4 '18 at 23:47

















          This unfortunately did not work for me.

          – Martijnr
          Jun 4 '18 at 1:45





          This unfortunately did not work for me.

          – Martijnr
          Jun 4 '18 at 1:45













          @Martijnr face any issue?

          – Prince Patel
          Jun 4 '18 at 5:02





          @Martijnr face any issue?

          – Prince Patel
          Jun 4 '18 at 5:02













          This did not change anything. Any other suggestions Prince?

          – Martijnr
          Jun 4 '18 at 23:47





          This did not change anything. Any other suggestions Prince?

          – Martijnr
          Jun 4 '18 at 23:47













          0














          I am assuming you are referring cart page as shopping page.



          In your theme, checkout_cart_index.xml add <referenceBlock name="catalog.leftnav" remove="true" /> as follows



          <page layout="1column" 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>


          Default Magento doesn't have layered navigation on cart page.



          To remove it from every where you can use above in your theme default.xml or in catalog_category_view_type_default.xml






          share|improve this answer
























          • I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

            – Martijnr
            Jun 4 '18 at 23:49
















          0














          I am assuming you are referring cart page as shopping page.



          In your theme, checkout_cart_index.xml add <referenceBlock name="catalog.leftnav" remove="true" /> as follows



          <page layout="1column" 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>


          Default Magento doesn't have layered navigation on cart page.



          To remove it from every where you can use above in your theme default.xml or in catalog_category_view_type_default.xml






          share|improve this answer
























          • I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

            – Martijnr
            Jun 4 '18 at 23:49














          0












          0








          0







          I am assuming you are referring cart page as shopping page.



          In your theme, checkout_cart_index.xml add <referenceBlock name="catalog.leftnav" remove="true" /> as follows



          <page layout="1column" 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>


          Default Magento doesn't have layered navigation on cart page.



          To remove it from every where you can use above in your theme default.xml or in catalog_category_view_type_default.xml






          share|improve this answer













          I am assuming you are referring cart page as shopping page.



          In your theme, checkout_cart_index.xml add <referenceBlock name="catalog.leftnav" remove="true" /> as follows



          <page layout="1column" 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>


          Default Magento doesn't have layered navigation on cart page.



          To remove it from every where you can use above in your theme default.xml or in catalog_category_view_type_default.xml







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 4 '18 at 8:08









          Anshu MishraAnshu Mishra

          5,21552659




          5,21552659













          • I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

            – Martijnr
            Jun 4 '18 at 23:49



















          • I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

            – Martijnr
            Jun 4 '18 at 23:49

















          I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

          – Martijnr
          Jun 4 '18 at 23:49





          I edited my post, what I mean is the shop category page. When I use your XML code, it removes the complete sidebar including the price filter. I only want the category filter to be removed.

          – Martijnr
          Jun 4 '18 at 23:49


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f228271%2fhow-to-remove-categories-filter-from-the-sidebar%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Polycentropodidae

          Magento 2 Error message: Invalid state change requested

          Paulmy