Saturday, July 13, 2013

Magento : Get Product info from Order

Hi guys,
Today i am going to share with you a interesting bit of code that will help you finding the product order info from the order created in the admin.

For version 1.7 :

[php]
$orders = Mage::getResourceModel('sales/order_collection')
->addAttributeToSelect('*')
->addFieldToFilter('status', array("in" => array(
'complete', // If you want to get all orders just remove these filters.
'closed')
))
->addAttributeToFilter('store_id', Mage::app()->getStore()->getId())
->addAttributeToSort('created_at', 'asc')
->load();

foreach($orders as $order){
$items = $order->getAllVisibleItems();
foreach($items as $item){
$orderId = $order->getIncrementId();
$productid = $item->getSku();
$QtyOrdered = $item->getQtyOrdered();
$Price = $item->getPrice();
$Name = $item->getName();

}
}

[/php]

No comments:

Post a Comment