If you open the Block that matches your template (catalogsearch\advanced\form.phtml
-> Mage_CatalogSearch_Block_Advanced_Form
), you will see that it's calling the getAttributes
method of Mage_CatalogSearch_Model_Advanced
which in turn is executing:
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
...
->setOrder('main_table.attribute_id', 'asc')
->load();
All of which means that it's sorting by the attribute_id
field in the eav_attribute
table, not a particular useful field.
However, the actual query performs a join on the catalog_eav_attribute
table as additional_table
which means that you could alter the sort portion of the code to be ->setOrder('additional_table.position', 'asc')
and then change the values of the "position" field in that table via phpMyAdmin.
In order to make this alteration in a future-proof manner, take a copy of the Mage_CatalogSearch_Model_Advanced
file and copy it to app/code/local/Mage/CatalogSearch/Model
before making any alterations.
To debug the SQL query, turn on $_debug
and $_logAllQueries
in lib/varien/Db/Adapter/Pdo/Mysql.php
. Don't forget to turn that off in production!!
Hope this helps,
JD