Reputation: 7882
how can I change the sort/order in the suggestions of the Autocomplete search form.
I use Magento version 1.4.1.1
Thanks for help.
Upvotes: 1
Views: 1693
Reputation: 9100
To make it quick, copy /app/code/core/Mage/CatalogSearch/Model/Mysql4/Query/Collection.php into /app/code/local/Mage/CatalogSearch/Model/Mysql4/Query/Collection.php in local scope file find this line:
->order('popularity desc');
and replace it with this:
->order('query_text asc');
This is enough to make it work.
If you are interested in how does it work here you go.
suggestAction
function of Mage_CatalogSearch_AjaxController
though the following url: http://www.yourdomain.com/catalogsearch/ajax/suggest?q=query
(may be quite useful for debugging).Mage_CatalogSearch_Block_Autocomplete
makes a query to database catalogsearch_query
table through getSuggestCollection
function call.setOrder
function to it so I had to dug one step deeper.Hope it helped.
Upvotes: 3