Kennedy5020 Posted June 1, 2013 Share Posted June 1, 2013 (edited) How to get product view count in prestashop my code is \themes\default\product.tpl {php} function getTotalViewed1($id_product) { $view1 = Db::getInstance()->getRow(' SELECT SUM(pv.`counter`) AS total FROM `'._DB_PREFIX_.'page_viewed` pv LEFT JOIN `'._DB_PREFIX_.'date_range` dr ON pv.`id_date_range` = dr.`id_date_range` LEFT JOIN `'._DB_PREFIX_.'page` p ON pv.`id_page` = p.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type` WHERE pt.`name` = \'product.php\' AND p.`id_object` = '.intval($id_product).''); return isset($view1['total']) ? $view1['total'] : 0; } if ($id_product = intval(Tools::getValue('id_product'))) { $product = new Product($id_product, false, intval($cookie->id_lang)); $totalViewed1 = getTotalViewed1($product->id); echo $totalViewed1; } {/php} when i use above code , page shows empty screen. what is the issue ? Edited June 28, 2013 by karthick (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 1, 2013 Share Posted June 1, 2013 i've noticed that you use {php} {/php} tags, so my question is: where you use this code? in the .tpl file? Link to comment Share on other sites More sharing options...
Kennedy5020 Posted June 1, 2013 Author Share Posted June 1, 2013 Hi vekia, I changed some code. i have added getTotalViewed function in calsses/product.php in product.tpl file i am using {$product->getTotalViewed($product->id|intval)} but i am getting 0 as result. Link to comment Share on other sites More sharing options...
tashkas Posted November 26, 2013 Share Posted November 26, 2013 can somebody give working code please? Link to comment Share on other sites More sharing options...
vahidafshari Posted December 14, 2013 Share Posted December 14, 2013 why this topic marked as solved?where is the answer mr vekia Link to comment Share on other sites More sharing options...
vekia Posted December 14, 2013 Share Posted December 14, 2013 i have no idea why, maybe author of this thread solved it and marked it as solved without sharing solution. Link to comment Share on other sites More sharing options...
vekia Posted March 18, 2014 Share Posted March 18, 2014 new working feature for prestashop 1.5.x and 1.6.x free tutorial product page views counter Link to comment Share on other sites More sharing options...
Recommended Posts