How to Set and Get Admin Session Quote in Magento 2
This post includes the method to set and get admin session quote in Magento 2 store.
If you want to retrieve the quote data from the admin panel, you can use the below solution. Also you can sometimes while Magento 2 module customization or Magento 2 module development, you may need to get set and unset custom session variable in Magento 2.
Or you may even set quote in admin side session using quote ID.
Get the items that are present in the quote of admin order
Method to Set and Get Admin Session Quote in Magento 2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php namespace Vendor\Extension\Helper; use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\Helper\Context; use Magento\Backend\Model\Session\Quote as BackendModelSession; class Data extends AbstractHelper { protected $backendModelSession; public function __construct( Context $context, BackendModelSession $backendModelSession ) { $this->backendModelSession = $backendModelSession; parent::__construct($context); } public function setBackendQuote(){ $customerId = 5; $quoteId = 111; $this->backendModelSession->setCustomerId($customerId); $this->backendModelSession->setQuoteId($quoteId); $this->backendModelSession->setStoreId(1); } public function getBackendQuote(){ $quote = $this->backendModelSession->getQuote(); return $quote; } } |
Any doubts can be mentioned in the Comments section below. I’d be glad to help you out.
Do share the solution with the Magento Community via social media.
Thank you.
Chandresh Chauhan
He has been with Meetanshi for more than three years now as a certified Magento developer. A silent guy whom you can always find solving clients' issues, is an avid reader too.
Prev
How to Get All Stores’ List by Website ID in Magento 2
How to Get Customer Collection in Magento 2
Next