Magento - non eav collection sort order
magento
Solution
Both Magento collection superclasses (`Mage_Core_Model_Resource_Db_Collection_Abstract` and `Mage_Eav_Model_Entity_Collection_Abstract`) inherit three public convenience methods from the collection superclass `Varien_Data_Collection_Db`:
- `setOrder()`
- `addOrder()`, an alias for `setOrder()`
- `unshiftOrder()`, for moving a sort parameter to the first position
The EAV collection superclass provides another method, `addAttributeToSort()`, which ensures that the attribute is joined on to the collection for sorting.
As Vinai has pointed out on his tumblr, there are some considerations in how and when these methods will behave.
Problem
In Magento, when using non eav collections what is the best way to add sort orders? With eav collections i believe there are convenience methods for doing this but with non eav there dont appear to be the same facilities.