I need to export magento orders per product ( I want to get all the orders for a specific product) How could I do it?
- what is your magento version?Prashant Valanda– Prashant Valanda2018-06-05 06:45:42 +00:00Commented Jun 5, 2018 at 6:45
- 1.9.31 this is the versionuser1619177– user16191772018-06-05 07:01:34 +00:00Commented Jun 5, 2018 at 7:01
- reference extension link : marketplace.magento.com/…user68116– user681162018-06-05 07:05:01 +00:00Commented Jun 5, 2018 at 7:05
- Thank you but I am not sure how to use it to filter order per productuser1619177– user16191772018-06-05 07:18:09 +00:00Commented Jun 5, 2018 at 7:18
Add a comment |
1 Answer
You can get the order collection which contains specific products in the order by following code:
$collection = Mage::getModel('sales/order')->getCollection(); if($sku = $_product->getSku()){ $collection->getSelect()->join(array('order_item' => 'sales_flat_order_item'),'main_table.entity_id = order_item.order_id',array('sku')); $collection->getSelect()->where("order_item.sku like ?", "%$sku%")->group('main_table.entity_id'); } After that you can export it according to your requirement. This is not for export but for filter the order collection by sku or product.
Hope this help!