how can I change the sort/order in the suggestions of the Autocomplete search form.
I use Magento version 188.8.131.52
Thanks for help.
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:
and replace it with this:
This is enough to make it work.
If you are interested in how does it work here you go.
- form.mini.phtml sends request to
Mage_CatalogSearch_AjaxControllerthough the following url:
http://www.yourdomain.com/catalogsearch/ajax/suggest?q=query(may be quite useful for debugging).
- Then instance of
Mage_CatalogSearch_Block_Autocompletemakes a query to database
- Inside this function the actual collection is built but for some reasons I was not able to apply to
setOrderfunction to it so I had to dug one step deeper.
- The clue lies in setQueryFilter function from the file you just copied above. Replacing the ordering method did the trick.
Hope it helped.