How can i add a custom sort to sort products in a category using the name and price both?

1 Answer 1


As you want multiple sort then you need to rewrite class Mage_Catalog_Block_Product_List_Toolbar bcoz magento set it's product listing page sort order from setCollection() function.

So add this code:


Rewrite class

  class [ModuleNameSpace]_[ModuleName]_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
     public function setCollection($collection)
  $this->_collection = $collection;


  // we need to set pagination only if passed value integer and more that 0
  $limit = (int)$this->getLimit();
  if ($limit) {
  if ($this->getCurrentOrder()) {
  $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
        // add this 
  return $this;

Rewrite code at config.xml

  • Thanks for the answer i will try this out and mark this answer as correct. Commented Jun 9, 2016 at 11:26
  • Sorry this method doesn't work. I tried with ->setOrder('name','DESC')->setOrder('price','DESC') still what it will do is first it will sort according to name and then again it will sort the list according to price which the final result will be sort only according to the price. Commented Jun 12, 2016 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.