Skip to content

Magento 2 Get order from quote id

How would I get a order’s info from a quote id?

if I have quote id of 253 and once I load that quote using..

$quote = $this->quoteFactory->create()->load("253");

How do i get the order which belongs to this?

This would happen after the order has been placed

I’ve tried this but it doesn’t work.

$reserved_order_id = (int)$quote['reserved_order_id']); //01191
$order = $this->orderRepository->get($reserved_order_id);

however i get an error of The entity that was requested doesn't exist. Verify the entity and try again yet i know that order exists. perhaps i shouldn’t use $quote['reserved_order_id']

Update

 $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $collection = $objectManager->create('MagentoSalesModelOrder');
        $orderInfo = $collection->loadByIncrementId($order_id);
        $orderId = $orderInfo ->getId();
        $order = $this->orderRepository->get($orderId);