_eventFactory = $event; $this->_productCompFactory = $productCompFactory; $this->_productIndexFactory = $productIndexFactory; $this->_customerSession = $customerSession; $this->_customerVisitor = $customerVisitor; } /** * Customer login action * * @param \Magento\Framework\Event\Observer $observer * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(\Magento\Framework\Event\Observer $observer) { if (!$this->_customerSession->isLoggedIn()) { return $this; } $visitorId = $this->_customerVisitor->getId(); $customerId = $this->_customerSession->getCustomerId(); $eventModel = $this->_eventFactory->create(); $eventModel->updateCustomerType($visitorId, $customerId); $this->_productCompFactory->create()->updateCustomerFromVisitor()->calculate(); $this->_productIndexFactory->create()->updateCustomerFromVisitor()->calculate(); return $this; } }