如何添加“订购依据"加载Magento模型时 [英] How to add "Order By" when loading a Magento Model

查看:46
本文介绍了如何添加“订购依据"加载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?

这是我到目前为止所拥有的:

Here is what I have so far:

$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');

这篇关于如何添加“订购依据"加载Magento模型时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆