How to load Quote by Quote id In Magento2

May 4, 2020 0 Comments

By Using Object Manager you can inject the instace of \Magento\Quote\Model\QuoteFactory

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$quoteFactory = $objectManager->create('\Magento\Quote\Model\QuoteFactory');
$q = $quoteFactory->create()->load($quoteId);

he other and recommended way, you can load the quote id by injecting the instance of

\Magento\Quote\Model\QuoteFactory
......
protected $quoteFactory;
public function __construct(
  .....
  \Magento\Quote\Model\QuoteFactory $quoteFactory
  ......
){
   $this -> quoteFactory = $quoteFactory;
}
To use it you can write: $q = $this->quoteFactory->create()->load($quoteId);

 

Leave A Comment

To Top