_persistentSession = $persistentSession; $this->_persistentData = $persistentData; $this->_checkoutSession = $checkoutSession; $this->_customerSession = $customerSession; $this->customerRepository = $customerRepository; } /** * Emulate quote by persistent data * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { $stopActions = ['persistent_index_saveMethod', 'customer_account_createpost']; if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent() || $this->_customerSession->isLoggedIn() ) { return; } $actionName = $observer->getEvent()->getRequest()->getFullActionName(); if (in_array($actionName, $stopActions)) { return; } if ($this->_persistentData->isShoppingCartPersist()) { $this->_checkoutSession->setCustomerData( $this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId()) ); if (!$this->_checkoutSession->hasQuote()) { $this->_checkoutSession->getQuote(); } } } }