How to get ordered Items and their detail for an order ID in Magento?

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 '
'; echo $item->getPrice(); echo '
'; echo $item->getQtyToInvoice(); echo '
'; echo $item->getQtyOrdered(); } }

Comments

Leave a Reply

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

*