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();

Comment Form

Leave a Reply

Your email address will not be published. Required fields are marked *



Latest comments

    Fatal error: Uncaught Error: Call to undefined function split() in /home4/nos/public_html/ Stack trace: #0 /home4/nos/public_html/ mdv_recent_comments() #1 /home4/nos/public_html/ include('/home4/nos/publ...') #2 /home4/nos/public_html/ include('/home4/nos/publ...') #3 /home4/nos/public_html/ require_once('/home4/nos/publ...') #4 /home4/nos/public_html/ require('/home4/nos/publ...') #5 {main} thrown in /home4/nos/public_html/ on line 72