cancel
Showing results for 
Search instead for 
Did you mean: 

Alter core observer functionality

Alter core observer functionality

I am trying to add a new value "merchant_id" in

\module-reports\Observer\CatalogProductViewObserver.php
How i can override `save` by add new data to save to it

public function execute(\Magento\Framework\Event\Observer $observer)
{
$productId = $observer->getEvent()->getProduct()->getId();

$viewData['product_id'] = $productId;
$viewData['store_id'] = $this->_storeManager->getStore()->getId();
if ($this->_customerSession->isLoggedIn()) {
$viewData['customer_id'] = $this->_customerSession->getCustomerId();
} else {
$viewData['visitor_id'] = $this->_customerVisitor->getId();
}

$this->_productIndxFactory->create()->setData($viewData)->save()->calculate();

$this->eventSaver->save(\Magento\Reports\Model\Event::EVENT_PRODUCT_VIEW, $productId);
}

I Need to add `$viewData['merchant_id']` and assign value to it .