Jump to content

Edit History

cvb_asturias

cvb_asturias

Hello.

This trick didn't work for me (PS 1.7.5).

This is my solution, in function 'getTableMostViewed' below line if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) {

/* if you pick 50 rows, when grupped results in 8-10 products so I comment the original call and I substitute for an enough high number like 400, when groupped, it results in 50-60 products */

//$products = $this->getTotalViewed($date_from, $date_to, (int)Configuration::get('DASHPRODUCT_NBR_SHOW_MOST_VIEWED'));

$products = $this->getTotalViewed($date_from, $date_to, 400);
            
$body = array();
            
/* ADD THIS IF */
            if (is_array($products) && count($products)) {
                $p = array();
                foreach ($products as $key => $product) {
                    if ($p[$product['id_object']] != 0) {
                        $p[$product['id_object']] += $product['counter'];
                    } else $p[$product['id_object']] = $product['counter'];
                }
                arsort($p);
                $products = array();
                foreach ($p as $clave => $valor) {
                    $products[] = array(
                        'id_object' => $clave,
                        'counter' => $valor
                    );
                }
              }

and below if (is_array($products) && count($products)) {............

 

 

cvb_asturias

cvb_asturias

Hello.

This trick didn't word for me (PS 1.7.5).

This is my solution, in function 'getTableMostViewed' below line if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) {

/* if you pick 50 rows, when grupped results in 8-10 products so I comment the original call and I substitute for an enough high number like 400, when groupped, it results in 50-60 products */

//$products = $this->getTotalViewed($date_from, $date_to, (int)Configuration::get('DASHPRODUCT_NBR_SHOW_MOST_VIEWED'));

$products = $this->getTotalViewed($date_from, $date_to, 400);
            
$body = array();
            
/* ADD THIS IF */
            if (is_array($products) && count($products)) {
                $p = array();
                foreach ($products as $key => $product) {
                    if ($p[$product['id_object']] != 0) {
                        $p[$product['id_object']] += $product['counter'];
                    } else $p[$product['id_object']] = $product['counter'];
                }
                arsort($p);
                $products = array();
                foreach ($p as $clave => $valor) {
                    $products[] = array(
                        'id_object' => $clave,
                        'counter' => $valor
                    );
                }
              }

and below if (is_array($products) && count($products)) {............

 

 

×
×
  • Create New...