Magento advanced search - inconsistent order of results / how to define multiple order-by fields

329 views Asked by At

I'm finding that search results are appearing in an inconsistent order in Magento 1.9.0.1.

In this example below I've specified that the results should order on price, which works, but products of the same price are appearing in a different order each time I perform the search.

Does anyone know how to fix this?

Two possible solutions (that I don't know how to implement) are:

  1. To add a default, base order-by to all advanced searches (on product ID or SKU for instance)
  2. Find a way of specifying multiple order-by fields, just like you would in a direct SQL statement, "...ORDER BY xxx ASC, yyy DESC..."
1

There are 1 answers

0
Jamie G On BEST ANSWER

I believe I've fixed this by applying some extra XML to /app/design/frontend//thk/default/layout/catalogsearch.xml, see the "search_result_list" element below. This seems to have effectively achieved (1) above.

<catalogsearch_advanced_result translate="label">
    ...
    <reference name="search_result_list">
        <action method="setDefaultDirection"><param>ASC</param></action>
        <action method="setSortBy"><param>name</param></action>
    </reference>
   ...
</catalogsearch_advanced_result>

Kudos to Adam-Allen in this stackexchange answer.