Changing default category sort order in Magento
17 Comments 27th FEB 2009 | Posted by Tomislav Bilic in Magento

Category toolbar has many options. By default is shows how many items are in the category, you can choose how many products you wish to be displayed per page, you can change the listing type (List or Grid) and you may choose Sort Order. This “Sort Order” can be confusing. The default “Sort Order” is “Best Value”. What does it mean? How is the Best value determined? Can we change the default sort order?
What is “Best Value” filed?
When you go to Category page in Magento administration, you will see “Category Products” tab. From there, you will see the list of products that are associated to this category. The last column in “Position”. That is how “Best Value” is determined. So, best value is not something that is dynamically calculated. You can tailor it to your likings.

How to change default Sort Order
The file you need to look at is: /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php Since we’ll modify it, make a copy to /app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
One there, you will notice this code at the beginning of the file:
$this->_availableOrder = array(
'position' => $this->__('Best Value'),
'name' => $this->__('Name'),
'price' => $this->__('Price')
);
Default order takes the first value available. So, all you have to do is to either:
- reorder it if you want to have a selection in the Toolbar or
- set only one value of choice if you will remove the selection from the toolbar
I hope this will help somebody.
To post code in comments, place your code inside [code] and [/code] tags.


















March 1st, 2009 at 15:48
yes, that helped. thanks!
March 26th, 2009 at 12:37
I want the same but for Search Result. When I search anything in Search box, it return the Product List with Sort By option “Relevance”. I want to make “Name” as a default sort option instead of “Relevance”. Please suggest me..
April 18th, 2009 at 12:31
does not work with 1.3.x
there was an option embedded in the configuration menu for changing the sort order. in 1.3.0 there is a bug, so the sort order is alwas “best value”. updating to 1.3.1 will fix this problem.
July 15th, 2009 at 18:53
For those of you who don’t want to alter the core code, adding this to the /app/design/frontend/default/[theme]/layout/catalog.xml file seems to work:
<!-- Add this line -->
name
This would make your code “upgrade-proof”. Feel free to correct this if it’s wrong.
October 2nd, 2009 at 8:59
Thanks very very much…!!!
its helped me so much.
thanks i’m delight
December 2nd, 2009 at 1:18
Just wanted yo let you know – it helped. Thanks.
December 16th, 2009 at 22:50
That was great! Just changing the position number in the category products tab works perfect. This way I don’t have to be messing around with coding.
Thanks a lot!
January 21st, 2010 at 13:43
Well that doesn’t seem to work for latest Magento version.
My toolbar.php doesn’t have any of that sort of code
February 4th, 2010 at 20:48
@Daniel: Yep, changed again.
February 16th, 2010 at 16:50
This is bugging me as well. I can’t seem to get it to work by price.
It’s all messed up – http://www.scalesmart.co.uk/bench-scales/counting-scales?order=price&dir=asc
This this a Magento problem or an Andrew problem?!
February 17th, 2010 at 20:57
in the last version we can set the default sort order between 3 deicded attribute best value name and price … that’s ok thank to the system config menu….. if we want to change the same about search result which is the best solution ??? which is exactly relevance ???
March 24th, 2010 at 17:30
The code for $this->_availableOrder isn’t there in 1.3.2.4. Instead, it sets it to simply ‘array()’, and $this->_availableOrder is set in the construct, by calling $this->_getConfig()->getAttributeUsedForSortByArray(); This hits the database for all attributes that are considered sortable, then builds a list based on that. It’s also not possible to override it as $this->_availableOrder is also ‘reset’ when Mage_Catalog_Block_Product_List kicks in (around line 150, there’s a $toolbar->setAvailableOrders). *sigh*
Any clues how to get around this?
Thanks
May 20th, 2010 at 23:06
please try to comment this in app/code/core/Mage/Catalog/Model/Config.php:
public function getAttributeUsedForSortByArray()
{
$options = array(
// ‘position’ => Mage::helper(‘catalog’)->__(‘Position’)
);
foreach ($this->getAttributesUsedForSortBy() as $attribute) {
/* @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */
$options[$attribute->getAttributeCode()] = $attribute->getStoreLabel();
}
return $options;
}
June 1st, 2010 at 19:05
For magento 1.4 chage line 119 ( /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php )to:
protected $_direction = ‘desc’;
June 2nd, 2010 at 8:30
the tip is to avoid Position order (almost not be default)
regards!
June 2nd, 2010 at 12:01
Well if you want to change the Default “order by” field, without coding you can in v1.4! Just from the Admin Settings.
For individual categories go to: Catalog>Manage Categories>(Pick the Category you want to change)>Display Settings>Default Product Listing Sort by> And Select some of the available fields
For the Global setting go to: System>Settings>Catalog>Frontend>Product listing sort by
Also, you can use custom fields to use as “order by”. In your Attribute creation there is the option “Used for sorting in product listing”. Set this to YES, and you will be able to sort your products by your custom Field (Attribute).
August 26th, 2010 at 8:07
Thanx a lot….