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 Jun 5 '18 at 6:45
  • 1.9.31 this is the version – user1619177 Jun 5 '18 at 7:01
  • reference extension link : marketplace.magento.com/… – user68116 Jun 5 '18 at 7:05
  • Thank you but I am not sure how to use it to filter order per product – user1619177 Jun 5 '18 at 7:18

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.