quoteManager = $quoteManager; $this->_persistentSession = $persistentSession; $this->_persistentData = $persistentData; $this->_customerSession = $customerSession; } /** * Unset persistent cookie and make customer's quote as a guest * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { if (!$this->_persistentData->canProcess($observer) || !$this->_persistentSession->isPersistent()) { return; } $this->_persistentSession->getSession()->removePersistentCookie(); if (!$this->_customerSession->isLoggedIn()) { $this->_customerSession->setCustomerId(null)->setCustomerGroupId(null); } $this->quoteManager->setGuest(); } }