We have a bit of code that looks like this:

$products = Mage::getModel('catalog/product')->getCollection();

This has been working fine, but after enabling flat product data the items are no longer sorted. I have reindexed but there is no change.

Should I be using a different function?


2 Answers 2


The function is correct and checks to see if the catalog is in flat mode. So do not worry about that. Make sure that your attribute is set correctly so that there is a column for it on the flat table.

I think setting used_in_product_listing to yes via a set-up script or via the admin, then preform a reindex should solve this problem.


Because you are using flat tables you should use setOrder()/addOrder() instead of addAttributeToSort().
Take a look here : http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento

  • Thanks for the reply. Unfortunately I can't find a solution from that link. I have tried addSort/setSort and also unshiftSort and none of them change anything. Am I missing something obvious? Commented Feb 27, 2014 at 1:31
  • stackoverflow.com/questions/11352128/… ( MagePsycho ) Commented Feb 27, 2014 at 9:19

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.