/** * Retrieve quote model object * * @return \Magento\Sales\Model\Quote */ public function getQuote() { if (is_null($this->_quote)) { $this->_quote = $this->_quoteFactory->create(); if ($this->getStoreId() && $this->getQuoteId()) { $this->_quote->setStoreId($this->getStoreId())->load($this->getQuoteId()); } elseif ($this->getStoreId() && $this->hasCustomerId()) { $customerGroupId = $this->_scopeConfig->getValue(self::XML_PATH_DEFAULT_CREATEACCOUNT_GROUP, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $this->_quote->setStoreId($this->getStoreId())->setCustomerGroupId($customerGroupId)->setIsActive(false)->save(); $this->setQuoteId($this->_quote->getId()); try { $customerData = $this->_customerService->getCustomer($this->getCustomerId()); $this->_quote->assignCustomer($customerData); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { /** Customer does not exist */ } } $this->_quote->setIgnoreOldQty(true); $this->_quote->setIsSuperMode(true); } return $this->_quote; }