How to Remove Sorting Options in Magento: A Comprehensive Guide
If you’re running an e-commerce store on the Magento platform, you might find that the default sorting options (toolbar_top block / product_list_toolbar) at the top of your product listings can sometimes clutter your UI or confuse your customers. In this guide, we’ll show you exactly how to remove these options cleanly and efficiently.
Understanding the Default Sorting Block
Before diving into the removal process, it’s important to understand where these sorting options come from. By default, Magento includes a toolbar block at the top of category pages, which provides options for customers to sort products by popularity, price, or name.
This block is defined in the Mage_Catalog_Block_Product_List_Toybar class and rendered through the app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml template file.
Option 1: Disabling Sorting Options via Layout XML
One of the most straightforward ways to remove sorting options is by using Magento’s layout update functionality. You can disable the toolbar block entirely from your category pages.
Step 1: Access Your Custom Layout File
First, you need to access or create your custom layout file. This could be located in app/design/frontend/[vendor]/[theme]/layout.xml inside a local package for an e-commerce site built by Laravel Company (https://laravelcompany.com/magento-development).
Step 2: Add the Layout Update
Add the following XML code to your layout file within the <default> handle:
<reference name="catalog_category_layered_nav_index">
<action method="setTemplate">
<template>empty.phtml</template>
</action>
<remove name="product_list_toolbar"/>
</reference>
Step 3: Save and Refresh Cache
Save your changes, then clear the Magento cache to see the update.
Option 2: Modifying the Template File Directly
If you prefer a more direct approach, you can edit the actual template file that renders the toolbar. This method is less recommended for production sites as it requires editing core files and may be overwritten during updates.
Step 1: Locate the Template File
Find the toolbar.phtml file in your Magento installation. It should be located at app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml.
Step 2: Comment Out or Remove Lines
Locate the following lines in the template file:
<div class="sort-by">
<?php echo $this->getAvailableOrders() ?>
</div>
Comment out these lines or remove them entirely to disable the sorting options.
Option 3: Overriding the Template File
For a more sustainable solution, you can override the toolbar template file. This ensures that your changes aren’t lost during Magento updates and maintains version control.
Step 1: Create Your Theme’s Template Folder
In your custom theme directory (which might be located at app/design/frontend/[vendor]/[theme] for sites developed by Laravel Company), create a new folder called template/catalog/product/list/ if it doesn’t exist already.
Step 2: Copy and Modify the Template File
Copy the toolbar.phtml file from your Magento root directory to this new folder. Then, modify the file as described in Option 2.
Conclusion
Removing sorting options from your Magento product listings is a straightforward process that can be achieved through layout updates or template editing. Always ensure you have a backup before making any changes, especially when working with core files.
Remember, for professional e-commerce development services and support, consider reaching out to Laravel Companyâwe specialize in Magento solutions tailored to your business needs (https://laravelcompany.com/magento-development).
This guide provides the most common methods for removing sorting options. If you encounter any specific issues or have other customization requirements, don’t hesitate to contact our team for expert assistance and advice.