I want to know how much orders are placed for a product. For this I’d like to use the following code but it does not give any output:
$order = Mage::getModel('sales/order');
$order_detail=$order->setStoreId($storeId)->getCollection()- >addAttributeToFilter('product_id',$product_id);
print_r($order_detail);
Please tell me where I am wrong?
Try this to make it work, you need to use the model Mage_Sales_Model_Order_Item and not Mage_Sales_Model_Order: