本文整理汇总了PHP中Magento\Framework\Session\SessionManagerInterface::getVisitorData方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManagerInterface::getVisitorData方法的具体用法?PHP SessionManagerInterface::getVisitorData怎么用?PHP SessionManagerInterface::getVisitorData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Session\SessionManagerInterface
的用法示例。
在下文中一共展示了SessionManagerInterface::getVisitorData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initByRequest
/**
* Initialization visitor by request
*
* Used in event "controller_action_predispatch"
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Customer\Model\Visitor
*/
public function initByRequest($observer)
{
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
return $this;
}
if ($this->session->getVisitorData()) {
$this->setData($this->session->getVisitorData());
}
if (!$this->getId()) {
$this->setSessionId($this->session->getSessionId());
$this->save();
$this->_eventManager->dispatch('visitor_init', array('visitor' => $this));
$this->session->setVisitorData($this->getData());
}
return $this;
}
示例2: initByRequest
/**
* Initialization visitor by request
*
* Used in event "controller_action_predispatch"
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\Customer\Model\Visitor
*/
public function initByRequest($observer)
{
if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) {
return $this;
}
if ($this->session->getVisitorData()) {
$this->setData($this->session->getVisitorData());
}
$this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
if (!$this->getId()) {
$this->setSessionId($this->session->getSessionId());
$this->save();
$this->_eventManager->dispatch('visitor_init', ['visitor' => $this]);
$this->session->setVisitorData($this->getData());
}
return $this;
}