How to get ordered Items and their detail for an order ID in Magento?
May 10, 2012 | In: How to do, Magento, php, web development
I tried to wrote this code when I was working on a cron file for all orders. My client wants a cron file that get all orders information including all ordered item and their detail.
First, I searched on google but I didn’t found any exact solution then I tried below code:
By below code I got all orders on site:
$orders = Mage::getModel('sales/order')->getCollection(); |
Now, I am going to fetch all ordered items for each order.
foreach ($orders as $order) { $items = $order->getAllItems(); foreach ($items as $itemId => $item) { echo $item->getName(); echo '<br />'; echo $item->getPrice(); echo '<br />'; echo $item->getQtyToInvoice(); echo '<br />'; echo $item->getQtyOrdered(); } } |