128 \
Magento\Framework\
App\Config\ScopeConfigInterface $coreConfig,
130 \
Magento\Persistent\Helper\Data $persistentData,
131 \
Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
132 \
Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
137 \
Magento\Framework\Data\Collection\AbstractDb $resourceCollection =
null,
141 $this->_persistentData = $persistentData;
142 $this->_coreConfig = $coreConfig;
143 $this->_cookieManager = $cookieManager;
144 $this->_cookieMetadataFactory = $cookieMetadataFactory;
171 $this->_loadExpired = $loadExpired;
195 return gmdate(
'Y-m-d H:i:s',
time() - $this->_persistentData->getLifeTime(
$store));
206 parent::beforeSave();
211 if (!in_array(
$index, $this->_unserializableFields)) {
215 $this->setInfo($this->jsonHelper->jsonEncode(
$info));
218 $this->setWebsiteId($this->_storeManager->getStore()->getWebsiteId());
221 $this->setKey($this->mathRandom->getRandomString(self::KEY_LENGTH));
222 }
while (!$this->
getResource()->isKeyAllowed($this->getKey()));
235 parent::_afterLoad();
237 if ($this->getInfo()) {
238 $info = $this->jsonHelper->jsonDecode($this->getInfo());
240 if (is_array(
$info)) {
257 $key = $this->_cookieManager->getCookie(self::COOKIE_NAME);
260 $this->
load($key,
'key');
275 return $this->
load(
$id,
'customer_id');
302 $cookieMetadata = $this->_cookieMetadataFactory->createSensitiveCookieMetadata()
303 ->setPath($this->sessionConfig->getCookiePath());
304 $this->_cookieManager->deleteCookie(self::COOKIE_NAME, $cookieMetadata);
332 if ($duration ===
null) {
335 $value = $this->_cookieManager->getCookie(self::COOKIE_NAME);
351 $websiteId = $this->_storeManager->getStore()->getWebsiteId();
354 $lifetime = $this->_coreConfig->getValue(
355 \
Magento\Persistent\Helper\Data::XML_PATH_LIFE_TIME,
376 return parent::afterDeleteCommit();
387 private function setCookie(
$value, $duration,
$path)
389 $publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata()
390 ->setDuration($duration)
392 ->setSecure($this->getRequest()->isSecure())
394 $this->_cookieManager->setPublicCookie(
397 $publicCookieMetadata
407 private function getRequest()
409 if ($this->request ==
null) {
411 ->get(\
Magento\Framework\
App\Request\Http::class);
413 return $this->request;
424 $this->setUpdatedAt(
gmdate(
'Y-m-d H:i:s'));
425 return parent::save();
setData($key, $value=null)
getData($key='', $index=null)
load($modelId, $field=null)
deleteByCustomerId($customerId, $clearCookie=true)
getExpiredBefore($store=null)
deleteExpired($websiteId=null)
setLoadExpired($loadExpired=true)
renewPersistentCookie($duration, $path)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\Persistent\Helper\Data $persistentData, \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager, \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
setPersistentCookie($duration, $path)
foreach( $_productCollection as $_product)() ?>" class $info
loadByCookieKey($key=null)