41 \
Magento\Reports\Model\EventFactory $event,
42 \
Magento\Customer\Model\Session $customerSession,
43 \
Magento\Customer\Model\Visitor $customerVisitor
46 $this->_eventFactory = $event;
47 $this->_customerSession = $customerSession;
48 $this->_customerVisitor = $customerVisitor;
60 public function save($eventTypeId, $objectId, $subjectId =
null, $subtype = 0)
62 if ($subjectId ===
null) {
63 if ($this->_customerSession->isLoggedIn()) {
64 $subjectId = $this->_customerSession->getCustomerId();
66 $subjectId = $this->_customerVisitor->getId();
72 $eventModel = $this->_eventFactory->create();
73 $storeId = $this->_storeManager->getStore()->getId();
74 $eventModel->setData([
75 'event_type_id' => $eventTypeId,
76 'object_id' => $objectId,
77 'subject_id' => $subjectId,
78 'subtype' => $subtype,
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Reports\Model\EventFactory $event, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Visitor $customerVisitor)