0

How do I remove the sorting and positioning tools from the category page in frontend? Can I remove them in a way that I only disable them from one category?

Nikolas
  • 2,281
  • 11
  • 17
Kaki Sami
  • 327
  • 2
  • 13

1 Answers1

3

You can remove it by overriding the following template

/vendor/magento/module-catalog/view/frontend/templates/product/list/toolbar.phtml

and comment out the following code

app/design/frontend/vendor/myname/Magento_Catalog/templates/product/list/toolbar.phtml.

   <?php if ($block->isExpanded()): ?>
            <?php include ($block->getTemplateFile('Magento_Catalog::product/list/toolbar/sorter.phtml')) ?>
   <?php endif; ?>

This will affect all categories.

To do it for a specific category. Create in your theme a custom_toolbar.phtml file like the original but with commented out the above code. Then go to the specific category in Magento admin, click on the tab Design and on the Layout Update XML add the following code

<referenceBlock name='product_list_toolbar'>
    <action method='setTemplate'>
        <argument name='template' xsi:type='string'>Magento_Catalog::product/list/custom_toolbar.phtml</argument>
    </action>
</referenceBlock>
junaidh
  • 63
  • 10
Nikolas
  • 2,281
  • 11
  • 17