_persistentSession = $persistentSession; $this->_persistentData = $persistentData; $this->_customerSession = $customerSession; } /** * Prevent clear checkout session * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var $action \Magento\Persistent\Controller\Index */ $action = $observer->getEvent()->getControllerAction(); if ($action instanceof \Magento\Persistent\Controller\Index) { if (($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) || !$this->_persistentData->isShoppingCartPersist() ) { $action->setClearCheckoutSession(false); } } } }