How to Set and Get Admin Session Quote in Magento 2 Programmatically

Add the following code to set and get admin session qoute in magento 2 store.

<?php
namespace VendorName\ModuleName\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;
}
}

 

 

If you are looking for Magento Developers, visit Magento Developer Agency.
Related Products