Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MakePersistentQuoteGuestObserver.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
18  protected $_customerSession;
19 
25  protected $_persistentSession = null;
26 
32  protected $_persistentData = null;
33 
37  protected $quoteManager;
38 
45  public function __construct(
46  \Magento\Persistent\Helper\Session $persistentSession,
47  \Magento\Persistent\Helper\Data $persistentData,
48  \Magento\Customer\Model\Session $customerSession,
49  \Magento\Persistent\Model\QuoteManager $quoteManager
50  ) {
51  $this->_persistentSession = $persistentSession;
52  $this->_persistentData = $persistentData;
53  $this->_customerSession = $customerSession;
54  $this->quoteManager = $quoteManager;
55  }
56 
63  public function execute(\Magento\Framework\Event\Observer $observer)
64  {
66  $action = $observer->getEvent()->getControllerAction();
67  if ($action instanceof \Magento\Persistent\Controller\Index) {
68  if ((($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn())
69  || $this->_persistentData->isShoppingCartPersist())
70  ) {
71  $this->quoteManager->setGuest(true);
72  }
73  }
74  }
75 }
$persistentSession
Definition: persistent.php:11
__construct(\Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Helper\Data $persistentData, \Magento\Customer\Model\Session $customerSession, \Magento\Persistent\Model\QuoteManager $quoteManager)