I am trying to retrieve information about an order to display a custom success page. I have a custom module setup extending


and it is working perfectly fine. Below is my code used to call the order information.

    public function orderListings($ID)
                echo $ID;
                $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
                $order = $objectManager->create('Magento\Sales\Model\Order')->load($ID);
                $class_methods = get_class_methods($order);
                $totall = $order->getGrandTotal();
                echo "Order Total:".$totall."<br/>";

I am calling this method in my custom success.phtml template, where I can access the getOrderId() method of the $block object:

$ID = $block->getOrderId();

However, whenever I call my custom method orderListings and pass in the order ID, the method fails to function properly and won't retrieve the correct order information. No errors are thrown, the $totall variable just simply is empty. If I call the same method and statically enter an order Id,

$order = $objectManager->create('Magento\Sales\Model\Order')->load(000000146);

then it functions properly and outputs the grand total.

When I echo the $ID variable, it is the exact same as the number I entered manually. What could possibly be causing this issue?

1 Answer 1


load method loads data by primary_key by default. So you always try to load by order entity_id not increment_id. So you need to change by :

$id = 1;
$order = $objectManager->create('Magento\Sales\Model\Order')->load($id);

For your case you should go following way :

$order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId(000000146);
  • I love you so much. Works as expected. This was the final piece of making my module work. Yay.
    – opqr549
    Jul 26, 2016 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.