Error filtering template: The entity that was requested doesn't exist. Verify the entity and try again

magento.stackexchange https://magento.stackexchange.com/questions/316653

Question

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

Was it helpful?

Solution

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 ...

OTHER TIPS

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top