Jump to content
tashkas

Display in product page how many times item have been viewed

Recommended Posts

Can somebody tell me how to make display in product page how many times item have been viewed by customers, there is module best products but it just for backend, I want it in main page.

Share this post


Link to post
Share on other sites

there is no solution in that link that you gave me Vekia, can somebody please share a solution how to do that?

Share this post


Link to post
Share on other sites

in Product.php class add function
 

    public static 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;
	}

then in product.tpl file you can use:

{Product::getTotalViewed1(Tools::getValue('id_product'))}

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More