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?
Asked
Active
Viewed 1,982 times
0
-
For Magento 1 or Magento 2? – Nikolas Aug 27 '17 at 19:50
1 Answers
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>
-
-
I put the file in app/design/frontend/vendor/myname/Magento_Catalog/templates/product/list/toolbar/toolbar.phtml. Right? – Kaki Sami Aug 27 '17 at 21:50
-
Yes.Check how to override a template https://magento.stackexchange.com/questions/116389/how-to-override-phtml-files-in-magento-2 – Nikolas Aug 28 '17 at 07:59