Jump to content

Sql: Get Product Views By Language


Recommended Posts

I'm trying to get the views of a product by language. This is my closest attempt:

$result = Db::getInstance()->getRow('
  SELECT
    SUM(pv.counter) AS total
  FROM ' . _DB_PREFIX_ . 'page_viewed pv
  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)
  LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl
    ON (pl.id_product = p.id_object)
  WHERE pt.name = "product"
    AND p.id_object = ' . intval($id_product) . '
    AND pl.id_lang = ' . intval($id_lang) . '
  GROUP BY pv.id_page
'); 

However, I always get the same number of views for each language.

 

Any help is much appreciated.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...