Multiple fields to sort a magento collection

If you want to sort a collection on multiple field like that :

select * from toto order by field1 asc, field2 desc

You just have to have some setOrder() call on your collection like that :

$myCollection->getCollection()
             ->setOrder('field1', 'asc')
             ->setOrder('field2', 'desc')
             ;

That’s all folk…

Leave a Reply