i have made a new attribute called Best sellers (attribute code: search_order) so I can sort my products showing the best sellers at the top when someone searches for products. However when someone searches at the moment it is sorted by relevance and they have to select Best sellers. Is there a way i can change it so by default it is sorted by best sellers?
I tries to change the function setListOrder in result.php to
public function setListOrders()
{
$category = Mage::getSingleton('catalog/layer')
->getCurrentCategory();
/* @var $category Mage_Catalog_Model_Category */
$availableOrders = $category->getAvailableSortByOptions();
unset($availableOrders['position']);
$availableOrders = array_merge(array(
'search_order' => $this->__('Best sellers'),
'relevance' => $this->__('Relevance')
), $availableOrders);
$this->getListBlock()
->setAvailableOrders($availableOrders)
->setDefaultDirection('desc')
->setSortBy('search_order');
return $this;
}
but that just put Best sellers at the top of the sort by list but didnt actually sort the results
Thank you if you can help
Best Answer
I found the answer after some intense searching on Stack Overflow all i had to do was add these lines to my layout.xml