I am trying to get quote data By


I tried this code

protected $_quoteFactory;

public function __construct(
    \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteFactory
) {
    $this->_quoteFactory           = $quoteFactory;

public function execute(Observer $observer)
         $quote = $this->_quoteFactory->create()->addFieldToFilter('reserved_order_id', $orderId);
         $quote = $this->_quoteFactory->create()->addFieldToFilter('entity_id', 12);
        $quote = $this->_quoteFactory->create()->addFieldToFilter('base_subtotal_with_discount', 20.0000);

the first filter is returning null while entity_id and base_subtotal_with_discount is returning me the correct result

I tried all of them separately

1 Answer 1


First of all, check this below collection and make sure that your reserved order should be unique.

If your if condition will be true then, records available othervise, records not available :

protected $quoteFactory;

public function __construct(
    \Magento\Quote\Model\QuoteFactory $quoteFactory
    $this->quoteFactory = $quoteFactory;    
public function execute(Observer $observer){
    $quote = $this->quoteFactory->create()->getCollection()->->addFieldToFilter('reserved_order_id', 'Your Order id')->getFirstItem();
        // quote id found   
    } else {
        // quote id not found

Hope, It will be helpful for you.

  • i checked my database there was a quote with reserved_order_id 0000082 i excuted following code having order_id = 82 i am still getting null
    – Waqar Ali
    Jul 1, 2019 at 10:05
  • 1
    thank you its working fine now
    – Waqar Ali
    Jul 3, 2019 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.