获取具有特定产品的magento扩展中的订单列表 [英] Get a list of orders in magento extension that have a certain product
本文介绍了获取具有特定产品的magento扩展中的订单列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何获得Magento中订单上有特定产品的所有订单的列表?
How would I get a list of all orders in Magento that have a certain product on the order?
我已经建立了扩展程序,需要知道包含特定产品的所有订单.
I have built an extension and need to know all orders which contain a certain product.
推荐答案
这本身并不是一个重复的问题,因此,这里的解决方案可能对您有用:
This is not a duplicate question per se, so here a solution that might work for you:
$productId = {PRODUCT_ID};
$orders = array();
$collection = Mage::getResourceModel('sales/order_item_collection')
->addAttributeToFilter('product_id', array('eq' => $productId))
->load();
foreach($collection as $orderItem) {
$orders[$orderItem->getOrder()->getIncrementId()] = $orderItem->getOrder();
}
您最终将获得一系列订单,其中包含给定{PRODUCT_ID}的订单项.
You'll end up with an array of orders which contain an orderitem for the given {PRODUCT_ID}.
这篇关于获取具有特定产品的magento扩展中的订单列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文