![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-persistent/Observer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Persistent\Observer; use Magento\Framework\Event\ObserverInterface; /** * Observer for setting "is_persistent" value to quote * * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class SetQuotePersistentDataObserver implements ObserverInterface { /** * Customer session * * @var \Magento\Customer\Model\Session */ protected $_customerSession; /** * Persistent session * * @var \Magento\Persistent\Helper\Session */ protected $_persistentSession = null; /** * Persistent data * * @var \Magento\Persistent\Helper\Data */ protected $_persistentData = null; /** * @var \Magento\Persistent\Model\QuoteManager */ protected $quoteManager; /** * @param \Magento\Persistent\Helper\Session $persistentSession * @param \Magento\Persistent\Helper\Data $persistentData * @param \Magento\Persistent\Model\QuoteManager $quoteManager * @param \Magento\Customer\Model\Session $customerSession */ public function __construct( \Magento\Persistent\Helper\Session $persistentSession, \Magento\Persistent\Helper\Data $persistentData, \Magento\Persistent\Model\QuoteManager $quoteManager, \Magento\Customer\Model\Session $customerSession ) { $this->_persistentSession = $persistentSession; $this->quoteManager = $quoteManager; $this->_customerSession = $customerSession; $this->_persistentData = $persistentData; } /** * Set persistent data into quote * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { if (!$this->_persistentSession->isPersistent()) { return; } /** @var $quote \Magento\Quote\Model\Quote */ $quote = $observer->getEvent()->getQuote(); if (!$quote) { return; } if (( ($this->_persistentSession->isPersistent()) && $this->_persistentData->isShoppingCartPersist() ) && $this->quoteManager->isPersistent() ) { //Quote is not actual customer's quote, just persistent $quote->setIsPersistent(true); } } }