2

I am trying to fetch the order details $order = $objectManager->create('\Magento\Sales\Model\OrderRepository')->get($orderId); Order id is correct 000000020. In var log main.CRITICAL: The entity that was requested doesn't exist. Verify the entity and try again at vendor/magento/module-sales/Model/OrderRepository.php:139 This is working fine for some order but for some, the above errors show. I am unable to locate what is the problem in actual. I did deploy indexing everything. Magento version is 2.3.4

1
  • you fetch the order details using object manager ??? Jul 6, 2020 at 9:51

2 Answers 2

1

Get Order Information From Order ID

<?php
$orderid = your_id;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch whole order information
print_r($order->getData());
 
//Or fetch specific information
echo $order->getIncrementId();
echo $order->getGrandTotal();
echo $order->getSubtotal();
?>

Get Order Items Information

<?php
$orderid = your_id;
 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//Loop through each item and fetch data
foreach ($order->getAllItems() as $item)
{
   //fetch whole item information
   print_r($item->getData());
 
   //Or fetch specific item information
   echo $item->getId();
   echo $item->getProductType();
   echo $item->getQtyOrdered();
   echo $item->getPrice(); 
     
}
?>

NOTE:- Object manager is not right way and not suggest magento.

So you want get order information other check this link :-

https://www.codextblog.com/code-snippet/get-order-information-from-order-id-in-magento-2/

Thanks ...

1

Hi you can try it like this

<?php
$orderid = 2; //enter your order id here 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\Data\OrderInterface')->load($orderid);
 
//fetch whole order information
print_r($order->getData());
 
//Or fetch specific information
echo $order->getIncrementId();
echo $order->getGrandTotal();
echo $order->getSubtotal();
?>

Please note that the use of object manager is not suggested in magento. Hope this helps!

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.