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.



yes, that helped. thanks!
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..
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.
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 --> nameThis would make your code “upgrade-proof”. Feel free to correct this if it’s wrong.
Thanks very very much…!!!
its helped me so much.
thanks i’m delight
Just wanted yo let you know – it helped. Thanks.
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!
Well that doesn’t seem to work for latest Magento version.
My toolbar.php doesn’t have any of that sort of code
@Daniel: Yep, changed again.
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?!
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 ???
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
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;
}
For magento 1.4 chage line 119 ( /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php )to:
protected $_direction = ‘desc’;
the tip is to avoid Position order (almost not be default)
regards!
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).
Thanx a lot….
hey buddy, for magento 1.4.1.1
in app\code\core\Mage\Catalog\Model\Config.php
just remove
$options = array(
‘position’ => Mage::helper(‘catalog’)->__(‘Position’)
);
and you are done
there will be no sort order like position
Using 1.3.2.3 and can’t get the order to default to price desc. Have set the options globally in config and tried individual categories but the prices are still not either desc or asc.
Have tried once or twice and it has worked but reverts back to almost random order for no apparent reason, or one I can’t fathom.
Is it possible to code the default order to price desc but still keep the other user choices available?
Been going on for months now and can’t seem to sort! Would upgrading to most recent stable help or could it be some other issue?
regards
I found this worked great so long as there are not subcategories below, that contain products not listed in the category your sorting. For some reason these products are getting listed in the main category, ahead of the products your trying to sort! I’m not sure if this is a bug in Magento but its driving me nuts!!
1.5.1 changing the toobar.php line 119 protected direction to ‘desc’ does not change my default ascend on Sort by. Tried two different sites.
Can anyone suggest some code changes for toolbar.php line 397? Perhaps that will work for me. Or some other idea?
line 397
[public function setDefaultOrder($field)
{
if (isset($this->_availableOrder[$field])) {
$this->_orderField = $this->getEntityId();
}
return $this;
}]
Thanks; Bryan.
Great article.
Do u know how we can sort by newly ordered products as default ?
Thanks
Prajosh
Nice, tks for your help!
On my magento 1.4.1.0, it’s doesn’t work, nothing work to list by product position
does not work with 1.5.0.1
Are you aware of any good extensions that provide more options in this area? Something that automatically calculated profitability per item and put the most profitable items first would be fantastic… with both price and cost as variables within the product info, you’d need to combine that info with a calculation of run rate and you’d be away.
Oh, yes, if they could put out-of-stock items at the back then reintroduce them at their previous position when they’re back in stock that would be great!
Might also be helpful to introduce new products at a specific place… so they get views and aren’t buried… and then let them float.
How would I turn this into a module? It should be easy to do this, basically i want to make a module that tells the system to use the local code of Toolbar.php instead of the mage core one.
Also does anyone know how to make it so no matter what products with qty < 1 are put in the back?
Hello,
I am having price option in sort select box.But want to make it into two types .
1.Price:High to low(desc)
2.Price:Low to high (asc)
and also i would like to add my whishlist option in select list
Any suggestion . please
I have 2 questions, we are just about to launch a new site and we did a bulk upload of products.
1. I see on my category pages items are listed on pages 1,2 3 etc.. that I would like to switch with items on pages 12, 13, 14– does one need code for this or is this simple to do and how?
2. How can one add in show ALL?
Thanks you!
Is there a way to import product position using a CSV import?
every product will have a position # within a category.
Thanks
add below code below sort by foreach in toolbar.phtml
<option value="getOrderUrl(‘price’, ‘asc’) ?>”isOrderCurrent(‘price’) && $this->getCurrentDirection() == ‘asc’): ?> selected=”selected”>
Lowest Price
<option value="getOrderUrl(‘price’, ‘desc’) ?>”isOrderCurrent(‘price’) && $this->getCurrentDirection() == ‘desc’): ?> selected=”selected”>
Highest Price
how do I retrieve the the position for a category? Tried getting a product collection it doesn’t appear to be an attribute.
Doesn anybody know how to change to sort option from a drop down into simple words you can click. can’t seem to find the answer to this anywhere.
Cheers,
Tom.
Wow really? There’s a field right there and you can’t just put a number in there and sort by the number? Did anyone at Magento ever actually run a store? Apparently not.
As far as changing the oh-so-flexible sort values for the person above me, you OBVIOUSLY have to uncheck that box near the items so you can then select which one. Isn’t that totally obvious?
Obvioulsy and apparently no one is able to answer how do you IMPORT that And NOT fix it from the backend.!!!
Cheers
I would like to order by position. Problem is that I cannot select this at the category config (only best value, name, price).
When I view the page, it displays like it is being sorted by position by default, but in fact the “out of stock” items are at the end of the list. Since this is a “top 10 list” kind of list, I just want the position 1 at the top, no matter what the stock status is.
When I explicitly set order=position&dir=asc to the URL, the sorting is fine. How to make this default?
Can you IMPORT the order of positions via a CSV file ?
is it possible to add new options on the drop down and make it work?