0

How to find order exists using SKU in Magento 1.9.

SKU is "ABC";

I want to check how many orders are available for the particular product using SKU.

1
-1

Use the below code to get the orders for a particular SKU

$sku = "ABC";
 $orders = Mage::getModel('sales/order')
           ->getCollection()
           ->join(array('order_item' => 'sales/order_item'),'main_table.entity_id = order_item.order_id');

 $orders->addFieldToFilter('order_item.sku', array(array('like' => '%'.$sku.'%')));
1
  • Manashvi Birla : Thank you I will check it. But can you give me any other solutions instead of like query. (gt or et). Dec 19 '17 at 7:18

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.