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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both Magento collection superclasses (
Mage_Core_Model_Resource_Db_Collection_AbstractandMage_Eav_Model_Entity_Collection_Abstract) inherit three public convenience methods from the collection superclassVarien_Data_Collection_Db:setOrder()addOrder(), an alias forsetOrder()unshiftOrder(), for moving a sort parameter to the first positionThe 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.