Reputation: 663
Is magento store, user product visit history? If yes then how can I fetch it or if no then how can I do it?
Any web link or resource would be highly appreciated.
Upvotes: 0
Views: 871
Reputation: 1967
You can create an observer using the catalog_product_load_after
event:
<global>
<events>
<catalog_product_load_after>
<observers>
<yournamespace_yourmodulename>
<type>model</type>
<class>yournamespace_yourmodulename/observer</class>
<method>saveProductVisitHistory</method>
</yournamespace_yourmodulename>
</observers>
</catalog_product_load_after>
</events>
</global>
And in the observer get the data which you need and save it somewhere:
public function saveProductVisitHistory(Varien_Event_Observer $observer) {
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
Mage::log('Customer ID: '.$customer->getId(), null, 'custom.log');
$product = $observer->getEvent()->getProduct();
Mage::log('Visited Product ID: '.$product->getId(), null, 'custom.log');
}
}
Upvotes: 1