Magento get order details


Magento get order details : If you are working with magento order and looking for order details you can load order in two ways –

  • Order – Load By Increment Id
  • Order – Load By Entity Id

You can use either method to load order in magento. We are going to explain the magento order details with example.

Note : For Magento 2.x version Order Details Click here – https://www.tutorialsplane.com/magento-2-get-order-details/


Magento get order details

We will explain both methods to load order detials. Let us start one by one. First let us go with entity id ie. real order id –

Magento load order detail by Order Id (Entity id)

If you know real order id ie. entity id you can load order detail as below-

Load Order by Order Id :

 $orderId = 111;
 // this is entity id
 $order = Mage::getModel('sales/order')->load($orderId);

Magento load order detail by Order Increment Id

If you know real order increment id you can load order detail as below-

Load Order by Increment Id :

 $orderIncrementId = 223;
 // this is entity id
 $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
Tip : You can get real order id from order increment id.

Magento get order items collection

Let us get order items collection from above order details-

Get Order Items Detail:

 $orderItemsCollection = $order->getItemsCollection();
 foreach $orderItemsCollection as $item){ 
    $productId = $item->Id();
    $productSku = $item->sku();
    $productName = $item->getName();
 }

Magento get Order Id From Increment Id

You can get magento real order id from increment id as below-

Get Real Order Id From Increment Id:

//real order id ie. entity id
$orderId = Mage::getModel('sales/order')
             ->loadByIncrementId($incrementId)
             ->getEntityId();

-More Details From Order-

Let us have a look on other details from magento order –


Magento get Order Status

You can get order status in magento as below –

Get Order Status :

 $orderId = 111;
 // this is entity id
 $order = Mage::getModel('sales/order')->load($orderId);
 $status = $order->getStatusLabel();

Magento get Shipping And Billing Address From Order

You can get Shipping And Billing Address From Order in magento as below –

Get Shipping And Billing Address From Order :

 $orderId = 111;
 // this is entity id
 $order = Mage::getModel('sales/order')->load($orderId);
 $shippingAddress = $order->getShippingAddress();
 $billingAddress = $order->getBillingAddress();

Magento get Shipping Method From Order

You can get Shipping Method from order in magento as below –

Get Shipping Method from Order:

 $orderId = 111;
 // this is entity id
 $order = Mage::getModel('sales/order')->load($orderId);
 $shippingMethod = $order->getShippingMethod();

Magento get Payment Method From Order

You can get Payment Method from order in magento as below –

Get Payment Method from Order:

 $orderId = 111;
 // this is entity id
 $order = Mage::getModel('sales/order')->load($orderId);
 $paymentMethod = $order->getPayment()->getMethodInstance()->getTitle();
Note : The above method will return payment method title. To get payment method code use $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();

Advertisements

Add Comment

📖 Read More