How to add “Order By” when loading a Magento Model

后端 未结 2 1819
醉话见心
醉话见心 2020-12-30 10:37

I am trying to load a list of items from a Magento model. What I want to do is get the items in order by their created date so that I have the newest first.

Anyone k

相关标签:
2条回答
  • 2020-12-30 11:13

    I was able to find the answer on my own. This is what I had to do:

    $model = Mage::getModel('testimonials/testimonials')
    ->getCollection()
    ->setOrder('created_time', 'DESC');
    
    0 讨论(0)
  • 2020-12-30 11:22

    another method that can work too:

    $model = Mage::getModel('package/module');
    
    $model->getCollection()
          ->getSelect()->order();
    
    0 讨论(0)
提交回复
热议问题