Magento Quick Search Default Sorting
Magento Quick Search functionality by default orders the results based on relevance. Sometimes we may need to change the search results to be ordered alphabatically or any custom order based on product attribute. We can achieve this by adding a simple code snippet in our themes layout file.
Make Sure the Product Name Attribute is Searchable
In Order to Sort the search results by product name, the name attribute should be configured properly in Magento Admin Panel. Navigate to Catalog -> Manage Attributes and search by the attribute code. For Product name the attribute code is name. The Attribute configuration must be changed to use in the Product Listing and Sorting.
Finally in your current theme create a file name local.xml to override the default behaviour and add the below code snippet.
1 2 3 4 5 6 7 8 |
<catalogsearch_result_index translate="label"> <label>Quick Search Form</label> <reference name="search_result_list"> <action method="setDefaultDirection"><param>asc</param></action> <action method="setSortBy"><param>name</param></action> <!– Add your custom attribute code above for sorting–> </reference> </catalogsearch_result_index> |
Compatability :- Magento 1.8,1.9
0 Comments Leave a comment