Changing default category sort order in Magento

11 Comments 27th FEB 2009 | Posted by Tomislav Bilic in Magento

Changing default category sort order 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.
Magento Category Product List Position

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.

If you like what you read, please share it.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Yahoo! Bookmarks
  • Reddit
  • Technorati
  • Twitter
  • StumbleUpon
  • LinkedIn
  • Netvibes
  • FriendFeed
  • NewsVine
  • Sphinn
  • Tumblr

There are 11 comments (Add Yours +)

  • 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:
    [code]


    name

    [/code]
    This 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

  • Andres Galindo Says

    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 ???

Leave a Comment

Magento Design and Development | Magento SEO | iPhone Application Development Web Application Development with ZEND | WordPress Ecommerce | WordPress development
Sitemap

Inchoo - webappsolutions | 2009