44 private $reportStatus;
55 \
Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory,
56 \
Magento\Customer\Model\Session $customerSession,
57 \
Magento\Customer\Model\Visitor $customerVisitor,
59 \
Magento\Reports\Model\ReportStatus $reportStatus
62 $this->_productIndxFactory = $productIndxFactory;
63 $this->_customerSession = $customerSession;
64 $this->_customerVisitor = $customerVisitor;
66 $this->reportStatus = $reportStatus;
84 $viewData[
'store_id'] = $this->_storeManager->getStore()->getId();
85 if ($this->_customerSession->isLoggedIn()) {
86 $viewData[
'customer_id'] = $this->_customerSession->getCustomerId();
88 $viewData[
'visitor_id'] = $this->_customerVisitor->getId();
91 $this->_productIndxFactory->create()->setData($viewData)->save()->calculate();
execute(\Magento\Framework\Event\Observer $observer)
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Reports\Model\Product\Index\ViewedFactory $productIndxFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Visitor $customerVisitor, EventSaver $eventSaver, \Magento\Reports\Model\ReportStatus $reportStatus)