// Fix stats queries
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7537 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -382,12 +382,13 @@ class BlockLayered extends Module
|
|||||||
|
|
||||||
$n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
|
$n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
|
||||||
|
|
||||||
$sql = 'SELECT p.id_product, p.out_of_stock, p.available_for_order, p.quantity, p.minimal_quantity, p.id_category_default, p.customizable, p.show_price, p.`weight`,
|
$sql = 'SELECT p.id_product, p.out_of_stock, p.available_for_order, p.minimal_quantity, p.id_category_default, p.customizable, p.show_price, p.`weight`,
|
||||||
p.ean13, pl.available_later, pl.description_short, pl.link_rewrite, pl.name, i.id_image, il.legend, m.name manufacturer_name, p.condition, p.id_manufacturer,
|
p.ean13, pl.available_later, pl.description_short, pl.link_rewrite, pl.name, i.id_image, il.legend, m.name manufacturer_name, p.condition, p.id_manufacturer, s.quantity,
|
||||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||||
FROM '._DB_PREFIX_.'product p
|
FROM '._DB_PREFIX_.'product p
|
||||||
LEFT JOIN '._DB_PREFIX_.'product_shop ps ON ps.id_product = p.id_product
|
LEFT JOIN '._DB_PREFIX_.'product_shop ps ON ps.id_product = p.id_product
|
||||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product AND pl.id_shop = '.Shop::getCurrentShop(true).')
|
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product AND pl.id_shop = '.Shop::getCurrentShop(true).')
|
||||||
|
LEFT JOIN '._DB_PREFIX_.'stock s ON s.id_product = p.id_product AND s.id_product_attribute = 0 '.Shop::sqlSharedStock('s').'
|
||||||
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
|
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
|
||||||
LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
|
LEFT JOIN '._DB_PREFIX_.'image_lang il ON (i.id_image = il.id_image AND il.id_lang = '.(int)($cookie->id_lang).')
|
||||||
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class StatsBestManufacturers extends ModuleGrid
|
|||||||
LEFT JOIN '._DB_PREFIX_.'currency c ON (c.id_currency = o.id_currency)
|
LEFT JOIN '._DB_PREFIX_.'currency c ON (c.id_currency = o.id_currency)
|
||||||
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
|
||||||
WHERE '.$this->sqlShopRestriction(false, 'o').'
|
WHERE '.$this->sqlShopRestriction(false, 'o').'
|
||||||
o.invoice_date BETWEEN '.$this->getDate().'
|
AND o.invoice_date BETWEEN '.$this->getDate().'
|
||||||
AND o.valid = 1
|
AND o.valid = 1
|
||||||
AND m.id_manufacturer IS NOT NULL
|
AND m.id_manufacturer IS NOT NULL
|
||||||
GROUP BY p.id_manufacturer';
|
GROUP BY p.id_manufacturer';
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class StatsEquipment extends ModuleGraph
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(false, 'c').'
|
'.$this->sqlShopRestriction(false, 'c').'
|
||||||
c.`date_add` BETWEEN ';
|
AND c.`date_add` BETWEEN ';
|
||||||
$this->_query2 = ' GROUP BY g.`id_web_browser`';
|
$this->_query2 = ' GROUP BY g.`id_web_browser`';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ class StatsEquipment extends ModuleGraph
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(false, 'c').'
|
'.$this->sqlShopRestriction(false, 'c').'
|
||||||
c.`date_add` BETWEEN ';
|
AND c.`date_add` BETWEEN ';
|
||||||
$this->_query2 = ' GROUP BY g.`id_operating_system`';
|
$this->_query2 = ' GROUP BY g.`id_operating_system`';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ class StatsNewsletter extends ModuleGraph
|
|||||||
FROM `'._DB_PREFIX_.'customer`
|
FROM `'._DB_PREFIX_.'customer`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(true).'
|
'.$this->sqlShopRestriction(true).'
|
||||||
`newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
|
AND `newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
|
||||||
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(*) as visitors
|
$sql = 'SELECT COUNT(*) as visitors
|
||||||
FROM '._DB_PREFIX_.'newsletter
|
FROM '._DB_PREFIX_.'newsletter
|
||||||
WHERE '.$this->sqlShopRestriction().'
|
WHERE '.$this->sqlShopRestriction().'
|
||||||
`newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
|
AND `newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
|
||||||
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||||
return array('customers' => $result1['customers'], 'visitors' => $result2['visitors'], 'both' => $result1['customers'] + $result2['visitors']);
|
return array('customers' => $result1['customers'], 'visitors' => $result2['visitors'], 'both' => $result1['customers'] + $result2['visitors']);
|
||||||
}
|
}
|
||||||
@@ -104,13 +104,13 @@ class StatsNewsletter extends ModuleGraph
|
|||||||
FROM `'._DB_PREFIX_.'customer`
|
FROM `'._DB_PREFIX_.'customer`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(true).'
|
'.$this->sqlShopRestriction(true).'
|
||||||
`newsletter_date_add` BETWEEN ';
|
AND `newsletter_date_add` BETWEEN ';
|
||||||
|
|
||||||
$this->_query2 = 'SELECT newsletter_date_add
|
$this->_query2 = 'SELECT newsletter_date_add
|
||||||
FROM '._DB_PREFIX_.'newsletter
|
FROM '._DB_PREFIX_.'newsletter
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(true).'
|
'.$this->sqlShopRestriction(true).'
|
||||||
`newsletter_date_add` BETWEEN ';
|
AND `newsletter_date_add` BETWEEN ';
|
||||||
$this->setDateGraph($layers, true);
|
$this->setDateGraph($layers, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class StatsOrigin extends ModuleGraph
|
|||||||
FROM '._DB_PREFIX_.'connections
|
FROM '._DB_PREFIX_.'connections
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction().'
|
'.$this->sqlShopRestriction().'
|
||||||
date_add BETWEEN '.$dateBetween;
|
AND date_add BETWEEN '.$dateBetween;
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql, false);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql, false);
|
||||||
$websites = array($directLink => 0);
|
$websites = array($directLink => 0);
|
||||||
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class StatsRegistrations extends ModuleGraph
|
|||||||
FROM `'._DB_PREFIX_.'customer`
|
FROM `'._DB_PREFIX_.'customer`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction(true).'
|
'.$this->sqlShopRestriction(true).'
|
||||||
`date_add` BETWEEN';
|
AND `date_add` BETWEEN';
|
||||||
$this->_titles['main'] = $this->l('Number of customer accounts created');
|
$this->_titles['main'] = $this->l('Number of customer accounts created');
|
||||||
$this->setDateGraph($layers, true);
|
$this->setDateGraph($layers, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class StatsSearch extends ModuleGraph
|
|||||||
FROM `'._DB_PREFIX_.'statssearch`
|
FROM `'._DB_PREFIX_.'statssearch`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction().'
|
'.$this->sqlShopRestriction().'
|
||||||
`date_add` BETWEEN ';
|
AND `date_add` BETWEEN ';
|
||||||
|
|
||||||
$this->_query2 = 'GROUP BY `keywords`
|
$this->_query2 = 'GROUP BY `keywords`
|
||||||
HAVING occurences > 1
|
HAVING occurences > 1
|
||||||
|
|||||||
@@ -123,12 +123,12 @@ class StatsVisits extends ModuleGraph
|
|||||||
FROM `'._DB_PREFIX_.'connections`
|
FROM `'._DB_PREFIX_.'connections`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction().'
|
'.$this->sqlShopRestriction().'
|
||||||
`date_add` BETWEEN ';
|
AND `date_add` BETWEEN ';
|
||||||
$this->_query[1] = 'SELECT date_add, COUNT(DISTINCT `id_guest`) as total
|
$this->_query[1] = 'SELECT date_add, COUNT(DISTINCT `id_guest`) as total
|
||||||
FROM `'._DB_PREFIX_.'connections`
|
FROM `'._DB_PREFIX_.'connections`
|
||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction().'
|
'.$this->sqlShopRestriction().'
|
||||||
`date_add` BETWEEN ';
|
AND `date_add` BETWEEN ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user