How to change default sort order/dir in Magento search results?

Introduction

Today we will be discussing how to change the default sort order/dir in Magento search results (simple & advanced).

Regarding solution, some say you need to change the /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php file in order to change the default sort order field and dir. But you don’t need to do so as there is an extremely easy way to do so.

Suppose say we are changing the default sort order field to ‘name’ and default sort direction to ‘asc’. Here goes the solution:

Changing default sort order / dir in simple search results:

1> Copy the following file to your custom theme folder
app/design/frontend/*/*/template/catalogsearch/form.mini.phtml
2> and insert the following two lines of code in between the

<form></form>

element of form.mini.phtml:

<input type="hidden" name="order" value="name" />
<input type="hidden" name="dir" value="asc" />

3> You’re done

Changing default sort order / dir in advanced search results:

1> Copy the following file to your custom theme folder
app/design/frontend/*/*/template/catalogsearch/advanced/form.phtml
2> and insert the following two lines of code in between the

<form></form>

element of form.phtml:

<input type="hidden" name="order" value="name" />
<input type="hidden" name="dir" value="asc" />

3> You’re done

Sort By Field: ‘name’, Dir: ‘asc’

Hopefully this artice was useful.
Thanks for reading guys.