I'm struggling with CMS page view counter.
I'm add new function to classes/controller/FrontController.php like below
public static function getCMSViewed($id_cms){
$viewcms = Db::getInstance()->getRow('SELECT SUM(pv.counter) AS total
FROM '._DB_PREFIX_.'page_viewed pv
LEFT JOIN '._DB_PREFIX_.'cms c ON pv.id_page = c.id_cms
LEFT JOIN '._DB_PREFIX_.'page p ON pv.id_page = p.id_page
LEFT JOIN '._DB_PREFIX_.'page_type pt ON p.id_page_type = pt.id_page_type
WHERE pt.name = \'cms\'');
return isset($viewcms['total']) ? $viewcms['total'] : 0;
}
and in cms.tpl file i have add {FrontController::getCMSViewed(Tools::getValue('id_cms'))}
For now the counter is "working" but showing on all Prestashop CMS pages the same increased value of one of the pages with ID=15
