Get order id in DECN order print name and image....

Get order place product.First of all get order id and sort in descending order. After this store in an array. One another variable get collection and with the help foreach loop print name, sku etc.

Here is full code.....

$orders = Mage::getModel('sales/order')->getCollection()
          ->addAttributeToSelect('*')
  ->addAttributeToSort('increment_id', 'DESC')
  ->setPage(0, 10);
$total=0;
foreach($orders as $order)
{
echo $order->getIncrementId() . "<br>";
$abc[] = $order->getIncrementId();
`}

for($i=0; $i<=count($abc); $i++)
{
$order = Mage::getModel('sales/order')->loadByIncrementId($abc[$i]);
$orderItems = $order->getItemsCollection();

foreach ($orderItems as $item)
{
$product_id = $item->product_id;
$product_sku = $item->sku;
$product_name = $item->getName();
$_product = Mage::getModel('catalog/product')->load($product_id);
 
echo "ORDER_NUMBER=".$abc[$i]."<br/>";
echo "product_name=".$product_name."<br/>";
// echo "product_sku=".$product_sku."<br/>";
?>
   <!--<img src="<?php //echo $_product->getImageUrl(); ?>" />-->
<?php
$total++;
}
}
echo $total;

Labels: