I am trying to get the order information in my custom module from the front store, it is saying Requested entity doesn\'t exist
.
But I have an order and order ID: 000000013.
/**
* @var \Magento\Sales\Api\OrderRepositoryInterface
*/
protected $orderRepository;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
array $data = []
)
{
$this->orderRepository = $orderRepository;
parent::__construct($context, $data);
}
public function getOrder($orderId,$email){
//$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
// $orderInformation = $objectManager->create('Magento\Sales\Model\Order')->load($orderId);
try{
$order = $this->orderRepository->get($orderId);
if(trim($order->getCustomerEmail()) == trim($email)){
return $order;
}else{
return $order;
}
}catch (\Exception $e){
return $order;
}
}
Even though I debugged see below pic.
I tried 2 ways (API and Model Class) but returning the same error.
Any help on this.