过滤magento订单集合 [英] Filter magento order collection

查看:52
本文介绍了过滤magento订单集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下行从magento加载订单集合:

I use the following line to load collection of orders from magento:

// Load Order Collection
$order_collection = Mage::getModel('sales/order')->getCollection();

如何过滤此集合以忽略状态为已取消"和完成"的订单?

How do you filter this collection to ignore orders with status "canceled" and "complete"?

更新

发布此内容后,我很无聊,所以我做了一些挖掘工作,这篇文章帮助我找到了正确的代码行:http://www.magentocommerce.com/boards/v/viewthread/201797/#t287235

After posting this, I was bored so I did some digging around and this post helped me find the right lines of code: http://www.magentocommerce.com/boards/v/viewthread/201797/#t287235

这是我解决的方法:

// Load Order Collection
$order_collection = Mage::getModel('sales/order')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('status', array('nin' => array('canceled','complete')));

推荐答案

使用addFieldToFilter方法

$order_collection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('status', array('nin' => array('canceled','complete')));

这篇关于过滤magento订单集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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