39 private $reportStatus;
49 \
Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory,
50 \
Magento\Customer\Model\Session $customerSession,
51 \
Magento\Customer\Model\Visitor $customerVisitor,
53 \
Magento\Reports\Model\ReportStatus $reportStatus
55 $this->_productCompFactory = $productCompFactory;
56 $this->_customerSession = $customerSession;
57 $this->_customerVisitor = $customerVisitor;
59 $this->reportStatus = $reportStatus;
77 if ($this->_customerSession->isLoggedIn()) {
78 $viewData[
'customer_id'] = $this->_customerSession->getCustomerId();
80 $viewData[
'visitor_id'] = $this->_customerVisitor->getId();
82 $this->_productCompFactory->create()->setData($viewData)->save()->calculate();
__construct(\Magento\Reports\Model\Product\Index\ComparedFactory $productCompFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Visitor $customerVisitor, EventSaver $eventSaver, \Magento\Reports\Model\ReportStatus $reportStatus)
execute(\Magento\Framework\Event\Observer $observer)
const EVENT_PRODUCT_COMPARE