Get Order Details From Order Id In Magento

In this tutorial, we will see how to retrieve order detail by order id in Magento. Order details can be retrieving from either by increment id or entity id. In Magento(CMS) we often require to get order detail by order id and that is why we are discussing about it. Let us see how is it possible to get order detail. We can get real order id from order increment ID . Two ways you can get order details which are mentioned below:

Get Order Details From Order Id In Magento
Get Order Details From Order Id In Magento
  • Order – Load by increment id of order
  • Order – Load by entity id of order

Get order ID from order increment ID
Here we have used a dummy value(#10001115) for order increment id to get real order id. So at this place you have to get right order increment id.

$orderincrementid = 10001115; 
$orderid = Mage::getModel('sales/order')
             ->loadByIncrementId($orderIncrementId)
             ->getEntityId();

Get order details by order increment ID

$order = Mage::getModel('sales/order')->loadByIncrementId($orderid);

Get Collection of order item

$orderitem=$order->getItemsCollection();
foreach($orderitem as $item)
{
    echo $product_id = $item->product_id;
    echo $product_sku = $item->sku;
    echo $product_price = $item->getPrice();
    echo $product_name = $item->getName();
   $product = Mage::getModel('catalog/product')->load($product_id);
    $cats = $product->getCategoryIds();
    $category_id = $cats[0]; // just get the first id from $cats
    $category = Mage::getModel('catalog/category')->load($category_id);
    echo $category_name = $category->getName();

    $shipping_address = $orders->getShippingAddress();
   echo $shipping_address->getTelephone()."<br>"; 
   echo $shipping_address->getPostcode()."<br>";

   $shipping_address = $orders->getBillingAddress();
   echo $shipping_address->getTelephone()."<br>"; 
   echo $shipping_address->getPostcode()."<br>";
   echo   $shipping_method = $order->getShippingMethod(); 
         }

Leave a Reply

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