本文整理匯總了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;
}