Magento 2 – How to Remove Sorting and Positioning Tools from Category Page

categorycategory-productsmagento2toolbar

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?

Best Answer

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

   <?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>
Related Topic