How can we write the below code lines in Magento 2.2.5 controller and model?

$order = Mage::getModel('sales/order')
            ->addFieldToFilter('quote_id', $quote->getId())

1 Answer 1


Try the below code in your controller or Model:

protected $_orderInterface;
public function __construct(
    \Magento\Sales\Api\Data\OrderInterface $orderInterface,
    $this->_orderInterface = $orderInterface;

public function getOrder($quoteId){
    return $this->_orderInterface->load($quoteId, 'quote_id');

Then run di compile and other required commands and test.

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.