15/08/2022
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
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;
}
}