如何添加“Order By"加载 Magento 模型时 [英] How to add "Order By" when loading a Magento Model
本文介绍了如何添加“Order By"加载 Magento 模型时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从 Magento 模型加载项目列表.我想要做的是按创建日期顺序排列项目,以便我首先拥有最新的.
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 know how I can do that?
这是我目前所拥有的:
$model = Mage::getModel('testimonials/testimonials')
->getCollection();
推荐答案
我能够自己找到答案.这就是我必须做的:
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');
这篇关于如何添加“Order By"加载 Magento 模型时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文