Jump to content

[solved]How to get product view count in prestashop


Recommended Posts

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 by karthick (see edit history)
Link to comment
Share on other sites

  • 5 months later...
  • 3 weeks later...
  • 3 months later...
×
×
  • Create New...