How to Add Sort Order For Collection in magento .?

Magento Sort Order of Collection

With a sorted collection you can display list of objects like products in a specific order. The below code will sort the collection in descending order by id.

$collection = Mage::getModel('tutorials/tutorials')
->setOrder('id', 'DESC');

You can also use product attributes in place of their product id but it is the most recommended way for sorting order for Collection in Magento.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *