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 *

*

Categories

Latest comments


    Fatal error: Uncaught Error: Call to undefined function split() in /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/functions.php:72 Stack trace: #0 /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/sidebar.php(11): mdv_recent_comments() #1 /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/single.php(47): include('/home4/nos/publ...') #2 /home4/nos/public_html/naveenos.com/wp-includes/template-loader.php(74): include('/home4/nos/publ...') #3 /home4/nos/public_html/naveenos.com/wp-blog-header.php(19): require_once('/home4/nos/publ...') #4 /home4/nos/public_html/naveenos.com/index.php(17): require('/home4/nos/publ...') #5 {main} thrown in /home4/nos/public_html/naveenos.com/wp-content/themes/smoker/functions.php on line 72