{"id":1918,"date":"2021-10-13T06:09:59","date_gmt":"2021-10-13T06:09:59","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/set-and-get-admin-session-quote-in-magento-2\/"},"modified":"2025-05-22T09:55:02","modified_gmt":"2025-05-22T04:25:02","slug":"set-and-get-admin-session-quote-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/set-and-get-admin-session-quote-in-magento-2\/","title":{"rendered":"How to Set and Get Admin Session Quote in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This post includes the method to&nbsp;<em><strong>set and get admin session quote in Magento 2<\/strong><\/em>&nbsp;store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/get-set-and-unset-custom-session-variable-in-magento-2\/\">get set and unset custom session variable in Magento 2<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or you may even set quote in admin side session using quote ID.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Get the items that are present in the quote of admin order<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Set and Get Admin Session Quote in Magento 2:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Vendor\\Extension\\Helper;\n\nuse Magento\\Framework\\App\\Helper\\AbstractHelper;\nuse Magento\\Framework\\App\\Helper\\Context;\nuse Magento\\Backend\\Model\\Session\\Quote as BackendModelSession;\n\nclass Data extends AbstractHelper\n{\n        protected $backendModelSession;\n    \n    public function __construct(\n        Context $context,\n        BackendModelSession $backendModelSession\n    )\n    {\n        $this->backendModelSession = $backendModelSession;\n        parent::__construct($context);\n    }\n    \n    public function setBackendQuote(){\n        $customerId = 5;\n        $quoteId = 111;\n        \n        $this->backendModelSession->setCustomerId($customerId);\n        $this->backendModelSession->setQuoteId($quoteId);\n        $this->backendModelSession->setStoreId(1);\n    }\n    \n    public function getBackendQuote(){\n        $quote = $this->backendModelSession->getQuote();\n        return $quote;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the solution with the Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post includes the method to&nbsp;set and get admin session quote in Magento 2&nbsp;store. If you want to retrieve the quote data from the admin&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1918","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1918"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1918\/revisions"}],"predecessor-version":[{"id":14207,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1918\/revisions\/14207"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}