如何在 prestashop 中获取产品查看次数。
我的代码是
\主题\默认\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}
当我使用上面的代码时,页面显示空白屏幕。
什么问题?
谢谢,卡西克