php - Get a list of orders in magento extension that have a certain product -
how list of orders in magento have product on order?
i have built extension , need know orders contain product.
this not duplicate question per se, here solution might work you:
$productid = {product_id}; $orders = array(); $collection = mage::getresourcemodel('sales/order_item_collection') ->addattributetofilter('product_id', array('eq' => $productid)) ->load(); foreach($collection $orderitem) { $orders[$orderitem->getorder()->getincrementid()] = $orderitem->getorder(); } you'll end array of orders contain orderitem given {product_id}.
Comments
Post a Comment