// Code cleaning
This commit is contained in:
@@ -406,6 +406,7 @@ class Dashproducts extends Module
|
||||
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||
{
|
||||
$products = array();
|
||||
// Only works with the default product URL pattern at this time
|
||||
if ($result = $gapi->requestReportData('ga:pagePath', 'ga:visits', $date_from, $date_to, '-ga:visits', 'ga:pagePath=~/([a-z]{2}/)?([a-z]+/)?[0-9][0-9]*\-.*\.html$', 1, 10))
|
||||
foreach ($result as $row)
|
||||
{
|
||||
@@ -416,30 +417,27 @@ class Dashproducts extends Module
|
||||
return $products;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT p.id_object, pv.counter
|
||||
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\'
|
||||
'.Shop::addSqlRestriction(false, 'pv').'
|
||||
AND dr.`time_start` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"
|
||||
AND dr.`time_end` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"';
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT p.id_object, pv.counter
|
||||
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\'
|
||||
'.Shop::addSqlRestriction(false, 'pv').'
|
||||
AND dr.`time_start` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"
|
||||
AND dr.`time_end` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"');
|
||||
}
|
||||
|
||||
public function getMostSearchTerms($date_from, $date_to, $limit = 10)
|
||||
{
|
||||
$sql = 'SELECT `keywords`, count(`id_statssearch`) as count_keywords, `results`
|
||||
FROM `'._DB_PREFIX_.'statssearch` ss
|
||||
WHERE ss.`date_add` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"
|
||||
'.Shop::addSqlRestriction(false, 'ss').'
|
||||
GROUP BY ss.`keywords`
|
||||
ORDER BY `count_keywords` DESC
|
||||
LIMIT 0, '.(int)$limit;
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT `keywords`, count(`id_statssearch`) as count_keywords, `results`
|
||||
FROM `'._DB_PREFIX_.'statssearch` ss
|
||||
WHERE ss.`date_add` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"
|
||||
'.Shop::addSqlRestriction(false, 'ss').'
|
||||
GROUP BY ss.`keywords`
|
||||
ORDER BY `count_keywords` DESC
|
||||
LIMIT '.(int)$limit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user