// Replace shop->addSqlRestriction() and shop->addSqlRestrictionOnLang() by static versions

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13618 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2012-02-27 12:15:30 +00:00
parent 2caf013a0f
commit c2cef61a5a
58 changed files with 210 additions and 241 deletions
+2 -2
View File
@@ -264,7 +264,7 @@ if (Tools::isSubmit('ajaxProductPackItems'))
FROM `'._DB_PREFIX_.'product` p
NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
WHERE pl.`id_lang` = '.(int)(Tools::getValue('id_lang')).'
'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
'.Shop::addSqlRestrictionOnLang('pl').'
AND p.`id_product` NOT IN (SELECT DISTINCT id_product_pack FROM `'._DB_PREFIX_.'pack`)
AND p.`id_product` != '.(int)(Tools::getValue('id_product')));
@@ -866,7 +866,7 @@ if (Tools::isSubmit('searchCategory'))
$results = Db::getInstance()->executeS(
'SELECT c.`id_category`, cl.`name`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.$context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE cl.`id_lang` = '.(int)$context->language->id.' AND c.`level_depth` <> 0
AND cl.`name` LIKE \'%'.pSQL($q).'%\'
GROUP BY c.id_category
+1 -1
View File
@@ -55,7 +55,7 @@ $excludeVirtuals = (bool)Tools::getValue('excludeVirtuals', false);
$sql = 'SELECT p.`id_product`, `reference`, pl.name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.id_lang = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.id_lang = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\')'.
(!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' ').
($excludeVirtuals ? 'AND p.id_product NOT IN (SELECT pd.id_product FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : '');
+1 -1
View File
@@ -147,7 +147,7 @@ function getPath($urlBase, $id_category, $path = '', $highlight = '', $categoryT
{
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.(int)$category['nleft'].'
AND c.nright >= '.(int)$category['nright'].'
AND cl.id_lang = '.(int)$context->language->id.
+1 -1
View File
@@ -1306,7 +1306,7 @@ abstract class AdminTabCore
$selectShop = ', shop.name as shop_name ';
$joinShop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop
ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType;
$whereShop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
$whereShop = Shop::addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
}
$assos = Shop::getAssoTables();
+1 -1
View File
@@ -157,7 +157,7 @@ class AttachmentCore extends ObjectModel
$ids_attachements[] = $attachement['id_attachment'];
$sql = 'SELECT * FROM `'._DB_PREFIX_.'product_attachment` pa
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pa.`id_product` = pl.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pa.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
WHERE `id_attachment` IN ('.implode(',', array_map('intval', $ids_attachements)).')
AND pl.`id_lang` = '.(int)$id_lang;
$tmp = Db::getInstance()->executeS($sql);
+1 -1
View File
@@ -410,7 +410,7 @@ class CarrierCore extends ObjectModel
$sql = 'SELECT c.*, cl.delay
FROM `'._DB_PREFIX_.'carrier` c
LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'carrier_zone` cz ON (cz.`id_carrier` = c.`id_carrier`)'.
($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)$id_zone.')' : '').'
WHERE c.`deleted` = '.($delete ? '1' : '0').
+3 -3
View File
@@ -390,7 +390,7 @@ class CartCore extends ObjectModel
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl')
AND pl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('pl')
);
$sql->leftJoin('product_tax_rules_group_shop', 'ptrgs',
'p.`id_product` = ptrgs.`id_product` AND cp.`id_shop` = ptrgs.`id_shop`');
@@ -408,7 +408,7 @@ class CartCore extends ObjectModel
);
$sql->leftJoin('category_lang', 'cl', '
p.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$this->id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl')
AND cl.`id_lang` = '.(int)$this->id_lang.Shop::addSqlRestrictionOnLang('cl')
);
// @todo test if everything is ok, then refactorise call of this method
@@ -2531,7 +2531,7 @@ class CartCore extends ObjectModel
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
WHERE c.`id_customer` = '.(int)$id_customer.'
AND o.`id_cart` IS NULL
'.Context::getContext()->shop->addSqlRestriction(Shop::SHARE_ORDER, 'c').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c').'
ORDER BY c.`date_upd` DESC';
if (!$id_cart = Db::getInstance()->getValue($sql))
+15 -18
View File
@@ -493,7 +493,7 @@ class CategoryCore extends ObjectModel
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').'
'.($active ? 'AND `active` = 1' : '').'
'.(!$id_lang ? 'GROUP BY c.id_category' : '').'
@@ -516,7 +516,7 @@ class CategoryCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_category`, cl.`name`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE cl.`id_lang` = '.(int)$id_lang.'
GROUP BY c.id_category
ORDER BY c.`position`');
@@ -542,7 +542,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg
ON (cg.`id_category` = c.`id_category`)
WHERE `id_parent` = '.(int)$this->id.'
@@ -639,10 +639,10 @@ class CategoryCore extends ObjectModel
'.Product::sqlStock('p', 'pa', false, $context->shop).'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (p.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').')
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'image` i
ON (i.`id_product` = p.`id_product`
AND i.`cover` = 1)
@@ -733,13 +733,11 @@ class CategoryCore extends ObjectModel
if (!Validate::isBool($active))
die(Tools::displayError());
$id = Context::getContext()->shop->id;
$id_shop = $id ? $id: Configuration::get('PS_SHOP_DEFAULT');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
'.Context::getContext()->shop->addSqlAssociation('category', 'c').'
WHERE `id_lang` = '.(int)$id_lang.'
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND c.`id_parent` = '.(int)$id_parent.'
@@ -777,8 +775,7 @@ class CategoryCore extends ObjectModel
if (!$shop)
$shop = Context::getContext()->shop;
$id = $shop->id;
$id_shop = $id ? $id: Configuration::get('PS_SHOP_DEFAULT');
$id_shop = Configuration::get('PS_SHOP_DEFAULT');
$selected_cat = explode(',', str_replace(' ', '', $selected_cat));
$sql = 'SELECT c.`id_category`, c.`level_depth`, cl.`name`, IF((
SELECT COUNT(*)
@@ -792,7 +789,7 @@ class CategoryCore extends ObjectModel
AND c3.`id_category` IN ('.implode(',', array_map('intval', $selected_cat)).')
)' : '0').' AS nbSelectedSubCat
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.$shop->addSqlRestrictionOnLang('cl');
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl');
if (Shop::getContext() == Shop::CONTEXT_SHOP && $use_shop_context)
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')';
@@ -872,7 +869,7 @@ class CategoryCore extends ObjectModel
$result = Db::getInstance()->getRow('
SELECT cl.`link_rewrite`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').'
WHERE `id_lang` = '.(int)$id_lang.'
AND c.`id_category` = '.(int)$id_category);
self::$_links[$id_category.'-'.$id_lang] = $result['link_rewrite'];
@@ -913,7 +910,7 @@ class CategoryCore extends ObjectModel
SELECT c.*, cl.*
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE `name` LIKE \''.pSQL($query).'\'
');
else
@@ -922,7 +919,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
WHERE `name` LIKE \'%'.pSQL($query).'%\'
AND c.`id_category` != 1
');
@@ -943,7 +940,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
WHERE `name` LIKE \''.pSQL($category_name).'\'
AND c.`id_category` != 1
AND c.`id_parent` = '.(int)$id_parent_category
@@ -976,7 +973,7 @@ class CategoryCore extends ObjectModel
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON (c.`id_category` = cl.`id_category`
AND `id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').')';
AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')';
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)
$sql .= '
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
@@ -1327,7 +1324,7 @@ class CategoryCore extends ObjectModel
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, cl.`id_lang`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE cl.`id_lang` = '.(int)$id_lang.'
AND c.`id_category` IN ('.implode(',', array_map('intval', $ids_category)).')
');
+3 -6
View File
@@ -105,11 +105,8 @@ class ConnectionCore extends ObjectModel
'time_start' => $time_start);
}
public static function setNewConnection($cookie, Shop $shop = null)
public static function setNewConnection($cookie)
{
if (!$shop)
$shop = Context::getContext()->shop;
if (isset($_SERVER['HTTP_USER_AGENT'])
&& preg_match('/BotLink|ahoy|AlkalineBOT|anthill|appie|arale|araneo|AraybOt|ariadne|arks|ATN_Worldwide|Atomz|bbot|Bjaaland|Ukonline|borg\-bot\/0\.9|boxseabot|bspider|calif|christcrawler|CMC\/0\.01|combine|confuzzledbot|CoolBot|cosmos|Internet Cruiser Robot|cusco|cyberspyder|cydralspider|desertrealm, desert realm|digger|DIIbot|grabber|downloadexpress|DragonBot|dwcp|ecollector|ebiness|elfinbot|esculapio|esther|fastcrawler|FDSE|FELIX IDE|ESI|fido|Hmhkki|KIT\-Fireball|fouineur|Freecrawl|gammaSpider|gazz|gcreep|golem|googlebot|griffon|Gromit|gulliver|gulper|hambot|havIndex|hotwired|htdig|iajabot|INGRID\/0\.1|Informant|InfoSpiders|inspectorwww|irobot|Iron33|JBot|jcrawler|Teoma|Jeeves|jobo|image\.kapsi\.net|KDD\-Explorer|ko_yappo_robot|label\-grabber|larbin|legs|Linkidator|linkwalker|Lockon|logo_gif_crawler|marvin|mattie|mediafox|MerzScope|NEC\-MeshExplorer|MindCrawler|udmsearch|moget|Motor|msnbot|muncher|muninn|MuscatFerret|MwdSearch|sharp\-info\-agent|WebMechanic|NetScoop|newscan\-online|ObjectsSearch|Occam|Orbsearch\/1\.0|packrat|pageboy|ParaSite|patric|pegasus|perlcrawler|phpdig|piltdownman|Pimptrain|pjspider|PlumtreeWebAccessor|PortalBSpider|psbot|Getterrobo\-Plus|Raven|RHCS|RixBot|roadrunner|Robbie|robi|RoboCrawl|robofox|Scooter|Search\-AU|searchprocess|Senrigan|Shagseeker|sift|SimBot|Site Valet|skymob|SLCrawler\/2\.0|slurp|ESI|snooper|solbot|speedy|spider_monkey|SpiderBot\/1\.0|spiderline|nil|suke|http:\/\/www\.sygol\.com|tach_bw|TechBOT|templeton|titin|topiclink|UdmSearch|urlck|Valkyrie libwww\-perl|verticrawl|Victoria|void\-bot|Voyager|VWbot_K|crawlpaper|wapspider|WebBandit\/1\.0|webcatcher|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|WebMoose|webquest|webreaper|webs|webspider|WebWalker|wget|winona|whowhere|wlm|WOLP|WWWC|none|XGET|Nederland\.zoek/i', $_SERVER['HTTP_USER_AGENT']))
{
@@ -117,7 +114,7 @@ class ConnectionCore extends ObjectModel
$sql = 'SELECT `id_connections` FROM `'._DB_PREFIX_.'connections`
WHERE ip_address = '.ip2long(Tools::getRemoteAddr()).'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC';
if ($id_connections = Db::getInstance()->getValue($sql))
{
@@ -131,7 +128,7 @@ class ConnectionCore extends ObjectModel
FROM `'._DB_PREFIX_.'connections`
WHERE `id_guest` = '.(int)$cookie->id_guest.'
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC';
$result = Db::getInstance()->getRow($sql);
if (!$result['id_guest'] && (int)$cookie->id_guest)
+8 -20
View File
@@ -240,14 +240,11 @@ class CustomerCore extends ObjectModel
*
* @return array Customers
*/
public static function getCustomers(Shop $shop = null)
public static function getCustomers()
{
if (!$shop)
$shop = Context::getContext()->shop;
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
FROM `'._DB_PREFIX_.'customer`
WHERE 1 '.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `id_customer` ASC';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
@@ -259,19 +256,16 @@ class CustomerCore extends ObjectModel
* @param string $passwd Password is also checked if specified
* @return Customer instance
*/
public function getByEmail($email, $passwd = null, Shop $shop = null)
public function getByEmail($email, $passwd = null)
{
if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd)))
die (Tools::displayError());
if (!$shop)
$shop = Context::getContext()->shop;
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'customer`
WHERE `active` = 1
AND `email` = \''.pSQL($email).'\'
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
'.(isset($passwd) ? 'AND `passwd` = \''.Tools::encrypt($passwd).'\'' : '').'
AND `deleted` = 0
AND `is_guest` = 0';
@@ -315,18 +309,15 @@ class CustomerCore extends ObjectModel
* @param $ignore_guest boolean, to exclude guest customer
* @return Customer ID if found, false otherwise
*/
public static function customerExists($email, $return_id = false, $ignore_guest = true, Shop $shop = null)
public static function customerExists($email, $return_id = false, $ignore_guest = true)
{
if (!Validate::isEmail($email))
die (Tools::displayError());
if (!$shop)
$shop = Context::getContext()->shop;
$sql = 'SELECT `id_customer`
FROM `'._DB_PREFIX_.'customer`
WHERE `email` = \''.pSQL($email).'\'
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER).
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).
($ignore_guest ? ' AND `is_guest` = 0' : '');
$result = Db::getInstance()->getRow($sql);
@@ -419,11 +410,8 @@ class CustomerCore extends ObjectModel
* @param string $query Searched string
* @return array Corresponding customers
*/
public static function searchByName($query, Shop $shop = null)
public static function searchByName($query)
{
if (!$shop)
$shop = Context::getContext()->shop;
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'customer`
WHERE (
@@ -431,7 +419,7 @@ class CustomerCore extends ObjectModel
OR `id_customer` LIKE \'%'.pSQL($query).'%\'
OR `lastname` LIKE \'%'.pSQL($query).'%\'
OR `firstname` LIKE \'%'.pSQL($query).'%\'
)'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER);
)'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
+1 -1
View File
@@ -350,7 +350,7 @@ class DispatcherCore
// Load routes from meta table
$sql = 'SELECT m.page, ml.url_rewrite
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.$context->shop->addSqlRestrictionOnLang('ml').')
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
WHERE id_lang = '.(int)$context->language->id.'
ORDER BY LENGTH(ml.url_rewrite) DESC';
if ($results = Db::getInstance()->executeS($sql))
+1 -1
View File
@@ -122,7 +122,7 @@ class GroupReductionCore extends ObjectModel
public static function getGroupReductions($id_group, $id_lang)
{
$lang = $id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl');
$lang = $id_lang.Shop::addSqlRestrictionOnLang('cl');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT gr.`id_group_reduction`, gr.`id_group`, gr.`id_category`, gr.`reduction`, cl.`name` AS category_name
FROM `'._DB_PREFIX_.'group_reduction` gr
+2 -2
View File
@@ -331,7 +331,7 @@ class ManufacturerCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
ON (p.`id_product` = pa.`id_product` AND default_on = 1)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').')
ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'image` i
ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
LEFT JOIN `'._DB_PREFIX_.'image_lang` il
@@ -380,7 +380,7 @@ class ManufacturerCore extends ObjectModel
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
WHERE p.`id_manufacturer` = '.(int)$this->id;
+3 -6
View File
@@ -93,16 +93,13 @@ class MetaCore extends ObjectModel
ORDER BY page ASC');
}
public static function getMetasByIdLang($id_lang, Shop $shop = null)
public static function getMetasByIdLang($id_lang)
{
if (!$shop)
$shop = Context::getContext()->shop;
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON m.`id_meta` = ml.`id_meta`
WHERE ml.`id_lang` = '.(int)$id_lang
.$shop->addSqlRestrictionOnLang('ml').
.Shop::addSqlRestrictionOnLang('ml').
'ORDER BY page ASC';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -118,7 +115,7 @@ class MetaCore extends ObjectModel
LEFT JOIN '._DB_PREFIX_.'meta_lang ml on (m.id_meta = ml.id_meta)
WHERE m.page = \''.pSQL($page).'\'
AND ml.id_lang = '.(int)$id_lang
.$context->shop->addSqlRestrictionOnLang('ml');
.Shop::addSqlRestrictionOnLang('ml');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
}
-8
View File
@@ -170,14 +170,6 @@ abstract class ModuleCore
}
}
/**
* Get SQL modules restriction by shop
*/
protected function sqlShopRestriction($share = false, $alias = null)
{
return $this->context->shop->addSqlRestriction($share, $alias, 'shop');
}
/**
* Insert module into datable
*/
+3 -3
View File
@@ -114,12 +114,12 @@ class PackCore extends Product
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON p.id_product = pl.id_product
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
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)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON p.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
LEFT JOIN `'._DB_PREFIX_.'product_tax_rules_group_shop` ptrgs ON (p.`id_product` = ptrgs.`id_product`
AND ptrgs.id_shop='.(int)Context::getContext()->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (ptrgs.`id_tax_rules_group` = tr.`id_tax_rules_group`
@@ -166,7 +166,7 @@ class PackCore extends Product
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.(int)$id_lang.')
WHERE pl.`id_lang` = '.(int)$id_lang.'
'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
'.Shop::addSqlRestrictionOnLang('pl').'
AND p.`id_product` IN ('.$packs.')';
if ($limit)
$sql .= ' LIMIT '.(int)$limit;
+14 -14
View File
@@ -935,7 +935,7 @@ class ProductCore extends ObjectModel
$sql = 'SELECT p.*, pl.* , t.`rate` AS tax_rate, m.`name` AS manufacturer_name, s.`name` AS supplier_name
FROM `'._DB_PREFIX_.'product` p
'.$context->shop->addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_tax_rules_group_shop` ptrgs ON (p.`id_product` = ptrgs.`id_product`
AND ptrgs.id_shop='.(int)$context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (ptrgs.`id_tax_rules_group` = tr.`id_tax_rules_group`
@@ -964,7 +964,7 @@ class ProductCore extends ObjectModel
$sql = 'SELECT p.`id_product`, pl.`name`
FROM `'._DB_PREFIX_.'product` p
'.$context->shop->addSqlAssociation('product', 'p', false).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.$context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '.Shop::addSqlRestrictionOnLang('pl').')
WHERE pl.`id_lang` = '.(int)$id_lang.'
ORDER BY pl.`name`';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -1827,7 +1827,7 @@ class ProductCore extends ObjectModel
$sql->join($context->shop->addSqlAssociation('product', 'p'));
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
);
$sql->leftJoin('image', 'i', 'i.`id_product` = p.`id_product` AND i.`cover` = 1');
$sql->leftJoin('image_lang', 'il', 'i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang);
@@ -1945,7 +1945,7 @@ class ProductCore extends ObjectModel
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
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)$id_lang.')
@@ -2031,7 +2031,7 @@ class ProductCore extends ObjectModel
'.Product::sqlStock('p', 0, false, $context->shop).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
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)$id_lang.')
@@ -2095,7 +2095,7 @@ class ProductCore extends ObjectModel
$ret = array();
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT cp.`id_category`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE cp.`id_product` = '.(int)$id_product.'
AND cl.`id_lang` = '.(int)$id_lang
);
@@ -2895,7 +2895,7 @@ class ProductCore extends ObjectModel
'.$context->shop->addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
WHERE `id_product_1` = '.(int)$id_product;
@@ -2928,11 +2928,11 @@ class ProductCore extends ObjectModel
'.$context->shop->addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (
p.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
)
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)$id_lang.')
@@ -3096,7 +3096,7 @@ class ProductCore extends ObjectModel
$sql->join($context->shop->addSqlAssociation('product', 'p'));
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl')
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
);
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
@@ -4008,7 +4008,7 @@ class ProductCore extends ObjectModel
FROM `'._DB_PREFIX_.'stock_mvt` sm
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
sm.id_product = pl.id_product
AND pl.id_lang = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (
sm.id_stock_mvt_reason = mrl.id_stock_mvt_reason
@@ -4034,9 +4034,9 @@ class ProductCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT pl.`id_lang`, pl.`link_rewrite`, p.`ean13`, cl.`link_rewrite` AS category_rewrite
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'lang` l ON (pl.`id_lang` = l.`id_lang`)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = p.`id_category_default` AND cl.`id_lang` = pl.`id_lang`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cl.`id_category` = p.`id_category_default` AND cl.`id_lang` = pl.`id_lang`'.Shop::addSqlRestrictionOnLang('cl').')
WHERE p.`id_product` = '.(int)$id_product.'
AND l.`active` = 1
');
@@ -4777,7 +4777,7 @@ class ProductCore extends ObjectModel
$interval = Category::getInterval($this->id_category_default);
$sql = new DbQuery();
$sql->from('category', 'c');
$sql->leftJoin('category_lang', 'cl', 'c.id_category = cl.id_category AND id_lang = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl'));
$sql->leftJoin('category_lang', 'cl', 'c.id_category = cl.id_category AND id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl'));
$sql->where('c.nleft <= '.(int)$interval['nleft'].' AND c.nright >= '.(int)$interval['nright']);
$sql->orderBy('c.nleft');
+3 -3
View File
@@ -92,7 +92,7 @@ class ProductSaleCore
'.$context->shop->addSqlAssociation('product', 'p', false).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
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)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
@@ -147,12 +147,12 @@ class ProductSaleCore
'.$context->shop->addSqlAssociation('product', 'p').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
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)$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
ON cl.`id_category` = p.`id_category_default`
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
WHERE p.`active` = 1
AND p.`id_product` IN (
SELECT cp.`id_product`
+18 -19
View File
@@ -128,7 +128,7 @@ class ReferrerCore extends ObjectModel
* @param int $employee
* @param Context $context
*/
public function getStatsVisits($id_product, $employee, Shop $shop)
public function getStatsVisits($id_product, $employee)
{
$join = $where = '';
if ($id_product)
@@ -151,8 +151,8 @@ class ReferrerCore extends ObjectModel
LEFT JOIN '._DB_PREFIX_.'connections_page cp ON cp.id_connections = c.id_connections
'.$join.'
WHERE cs.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
'.$shop->addSqlRestriction(false, 'rs').'
'.$shop->addSqlRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'rs').'
'.Shop::addSqlRestriction(false, 'c').'
AND rc.id_referrer = '.(int)$this->id
.$where;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -165,7 +165,7 @@ class ReferrerCore extends ObjectModel
* @param int $employee
* @param Context $context
*/
public function getRegistrations($id_product, $employee, Shop $shop)
public function getRegistrations($id_product, $employee)
{
$join = $where = '';
if ($id_product)
@@ -186,9 +186,9 @@ class ReferrerCore extends ObjectModel
LEFT JOIN '._DB_PREFIX_.'customer cu ON cu.id_customer = g.id_customer
'.$join.'
WHERE cu.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
'.$shop->addSqlRestriction(false, 'rs').'
'.$shop->addSqlRestriction(false, 'c').'
'.$shop->addSqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
'.Shop::addSqlRestriction(false, 'rs').'
'.Shop::addSqlRestriction(false, 'c').'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
AND cu.date_add > cs.date_add
AND rc.id_referrer = '.(int)$this->id
.$where;
@@ -201,9 +201,8 @@ class ReferrerCore extends ObjectModel
*
* @param int $id_product
* @param int $employee
* @param Context $context
*/
public function getStatsSales($id_product, $employee, Shop $shop)
public function getStatsSales($id_product, $employe)
{
$join = $where = '';
if ($id_product)
@@ -221,9 +220,9 @@ class ReferrerCore extends ObjectModel
LEFT JOIN '._DB_PREFIX_.'orders oo ON oo.id_customer = g.id_customer
'.$join.'
WHERE oo.invoice_date BETWEEN '.ModuleGraph::getDateBetween($employee).'
'.$shop->addSqlRestriction(false, 'rs').'
'.$shop->addSqlRestriction(false, 'c').'
'.$shop->addSqlRestriction(Shop::SHARE_ORDER, 'oo').'
'.Shop::addSqlRestriction(false, 'rs').'
'.Shop::addSqlRestriction(false, 'c').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'oo').'
AND oo.date_add > cs.date_add
AND rc.id_referrer = '.(int)$this->id.'
AND oo.valid = 1'
@@ -240,7 +239,7 @@ class ReferrerCore extends ObjectModel
$sql = 'SELECT COUNT(id_order) AS orders, SUM(total_paid_real / conversion_rate) AS sales
FROM '._DB_PREFIX_.'orders
WHERE id_order IN ('.implode($implode, ',').')
'.$shop->addSqlRestriction(Shop::SHARE_ORDER).'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
AND valid = 1';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
}
@@ -267,9 +266,9 @@ class ReferrerCore extends ObjectModel
continue;
$shop = new Shop($shop_id);
$stats_visits = $referrer->getStatsVisits(null, $employee, $shop);
$registrations = $referrer->getRegistrations(null, $employee, $shop);
$stats_sales = $referrer->getStatsSales(null, $employee, $shop);
$stats_visits = $referrer->getStatsVisits(null, $employee);
$registrations = $referrer->getRegistrations(null, $employee);
$stats_sales = $referrer->getStatsSales(null, $employee);
Db::getInstance()->update('referrer_shop', array(
'cache_visitors' => $stats_visits['uniqs'],
@@ -326,9 +325,9 @@ class ReferrerCore extends ObjectModel
$product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'));
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
$referrer = new Referrer($id_referrer);
$stats_visits = $referrer->getStatsVisits($id_product, $employee, $context->shop);
$registrations = $referrer->getRegistrations($id_product, $employee, $context->shop);
$stats_sales = $referrer->getStatsSales($id_product, $employee, $context->shop);
$stats_visits = $referrer->getStatsVisits($id_product, $employee);
$registrations = $referrer->getRegistrations($id_product, $employee);
$stats_sales = $referrer->getStatsSales($id_product, $employee);
// If it's a product and it has no visits nor orders
if ((int)$id_product && !$stats_visits['visits'] && !$stats_sales['orders'])
+5 -5
View File
@@ -252,11 +252,11 @@ class SearchCore
FROM '._DB_PREFIX_.'product p
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (
p.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('cl').'
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
)
WHERE p.`id_product` '.$product_pool.'
ORDER BY position DESC LIMIT 10';
@@ -281,7 +281,7 @@ class SearchCore
FROM '._DB_PREFIX_.'product p
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = '.(int)$context->country->id.'
@@ -300,7 +300,7 @@ class SearchCore
FROM '._DB_PREFIX_.'product p
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = '.(int)Context::getContext()->country->id.'
@@ -628,7 +628,7 @@ class SearchCore
FROM `'._DB_PREFIX_.'product` p
INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.$context->shop->addSqlRestrictionOnLang('pl').'
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
)
'.$context->shop->addSqlAssociation('product', 'p', false).'
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
+1 -1
View File
@@ -252,7 +252,7 @@ class SupplierCore extends ObjectModel
JOIN `'._DB_PREFIX_.'product_supplier` ps ON (ps.id_product = p.id_product
AND ps.id_product_attribute = 0)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
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`
+1 -1
View File
@@ -178,7 +178,7 @@ class TagCore extends ObjectModel
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT pl.name, pl.id_product
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product'.$context->shop->addSqlRestrictionOnLang('pl').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.id_product = pl.id_product'.Shop::addSqlRestrictionOnLang('pl').'
WHERE pl.id_lang = '.(int)$id_lang.'
AND p.active = 1
'.($this->id ? ('AND p.id_product '.$in.' (SELECT pt.id_product FROM `'._DB_PREFIX_.'product_tag` pt WHERE pt.id_tag = '.(int)$this->id.')') : '').'
+4 -4
View File
@@ -754,7 +754,7 @@ class ToolsCore
{
$sql = 'SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description_short`
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`'.Shop::addSqlRestrictionOnLang('pl').')
WHERE pl.id_lang = '.(int)$id_lang.'
AND pl.id_product = '.(int)$id_product.'
AND p.active = 1';
@@ -776,7 +776,7 @@ class ToolsCore
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `name`, `meta_title`, `meta_description`, `meta_keywords`, `description`
FROM `'._DB_PREFIX_.'category_lang` cl
WHERE cl.`id_lang` = '.(int)($id_lang).' AND cl.`id_category` = '.(int)$id_category.Context::getContext()->shop->addSqlRestrictionOnLang('cl'));
WHERE cl.`id_lang` = '.(int)($id_lang).' AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl'));
if ($row)
{
if (empty($row['meta_description']))
@@ -976,7 +976,7 @@ class ToolsCore
{
$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
FROM '._DB_PREFIX_.'category c
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.$context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').')
WHERE c.nleft <= '.$interval['nleft'].'
AND c.nright >= '.$interval['nright'].'
AND c.nleft >= '.$intervalRoot['nleft'].'
@@ -1519,7 +1519,7 @@ class ToolsCore
public static function cccJS($js_files)
{
Tools::displayAsDeprecated();
return Media::cccJS($css_files);
return Media::cccJS($js_files);
}
private static $_cache_nb_media_servers = null;
+1 -1
View File
@@ -1954,7 +1954,7 @@ class AdminControllerCore extends Controller
$select_shop = ', shop.name as shop_name ';
$join_shop = ' LEFT JOIN '._DB_PREFIX_.$this->shopLinkType.' shop
ON a.id_'.$this->shopLinkType.' = shop.id_'.$this->shopLinkType;
$where_shop = $this->context->shop->addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
$where_shop = Shop::addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
}
if ($this->multishop_context)
+8 -8
View File
@@ -789,7 +789,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE DATE_ADD(date_upd, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND date_upd >= \''.pSQL($date_from).'\'
'.Context::getContext()->shop->addSqlRestriction()
'.Shop::addSqlRestriction()
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -815,7 +815,7 @@ class OrderCore extends ObjectModel
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
WHERE 1
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
'.Shop::addSqlRestriction(false, 'o').'
ORDER BY o.`date_add` DESC
'.((int)$limit ? 'LIMIT 0, '.(int)$limit : '');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -838,7 +838,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE DATE_ADD(invoice_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\' AND invoice_date >= \''.pSQL($date_from).'\'
'.Context::getContext()->shop->addSqlRestriction()
'.Shop::addSqlRestriction()
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '').
' ORDER BY invoice_date ASC';
@@ -863,7 +863,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT id_order
FROM '._DB_PREFIX_.'orders o
WHERE o.`current_state` = '.(int)$id_order_state.'
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
'.Shop::addSqlRestriction(false, 'o').'
ORDER BY invoice_date ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -933,7 +933,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT COUNT(`id_order`) AS nb
FROM `'._DB_PREFIX_.'orders`
WHERE `id_customer` = '.(int)$id_customer
.Context::getContext()->shop->addSqlRestriction();
.Shop::addSqlRestriction();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
return isset($result['nb']) ? $result['nb'] : 0;
@@ -950,7 +950,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT `id_order`
FROM `'._DB_PREFIX_.'orders`
WHERE `id_cart` = '.(int)($id_cart)
.Context::getContext()->shop->addSqlRestriction();
.Shop::addSqlRestriction();
$result = Db::getInstance()->getRow($sql);
return isset($result['id_order']) ? $result['id_order'] : false;
@@ -1120,7 +1120,7 @@ class OrderCore extends ObjectModel
$sql = 'SELECT id_order
FROM `'._DB_PREFIX_.'orders`
WHERE `delivery_number` = '.(int)($id_delivery).'
'.Context::getContext()->shop->addSqlRestriction();
'.Shop::addSqlRestriction();
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
return new Order((int)($res['id_order']));
}
@@ -1159,7 +1159,7 @@ class OrderCore extends ObjectModel
WHERE o.`id_order` = '.(int)$this->id.'
AND c.`email` = \''.pSQL($email).'\'
AND c.`is_guest` = 1
'.Context::getContext()->shop->addSqlRestriction(false, 'c');
'.Shop::addSqlRestriction(false, 'c');
return (bool)Db::getInstance()->getValue($sql);
}
+3 -3
View File
@@ -367,7 +367,7 @@ class OrderInvoiceCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
AND oi.date_add >= \''.pSQL($date_from).'\'
'.Context::getContext()->shop->addSqlRestriction().'
'.Shop::addSqlRestriction().'
ORDER BY oi.date_add ASC
');
@@ -393,7 +393,7 @@ class OrderInvoiceCore extends ObjectModel
ORDER BY date_add DESC, id_order_history DESC
LIMIT 1
)
'.Context::getContext()->shop->addSqlRestriction(false, 'o').'
'.Shop::addSqlRestriction(false, 'o').'
ORDER BY oi.`date_add` ASC
');
@@ -415,7 +415,7 @@ class OrderInvoiceCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
WHERE DATE_ADD(oi.delivery_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
AND oi.date_add >= \''.pSQL($date_from).'\'
'.Context::getContext()->shop->addSqlRestriction().'
'.Shop::addSqlRestriction().'
ORDER BY oi.delivery_date ASC
');
+5 -3
View File
@@ -696,7 +696,7 @@ class ShopCore extends ObjectModel
* @param string $alias
* @param string $type shop|group_shop
*/
public function addSqlRestriction($share = false, $alias = null, $type = 'shop')
public static function addSqlRestriction($share = false, $alias = null, $type = 'shop')
{
if ($type != 'shop' && $type != 'group_shop')
$type = 'shop';
@@ -753,9 +753,11 @@ class ShopCore extends ObjectModel
* @param Context $context
* @return string
*/
public function addSqlRestrictionOnLang($alias = null)
public static function addSqlRestrictionOnLang($alias = null, $id_shop = null)
{
return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->id.' ';
if (is_null($id_shop))
$id_shop = Context::getContext()->shop->id;
return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$id_shop.' ';
}
/**
@@ -143,7 +143,7 @@ class AdminStockMvtControllerCore extends AdminController
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (
stock.id_product = pl.id_product
AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').'
AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').'
)
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (
a.id_stock_mvt_reason = mrl.id_stock_mvt_reason
+3 -3
View File
@@ -174,7 +174,7 @@ class BlockCategories extends Module
/*p('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.')
WHERE (c.`active` = 1 OR c.`id_category` = 1)
@@ -185,7 +185,7 @@ class BlockCategories extends Module
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
@@ -259,7 +259,7 @@ class BlockCategories extends Module
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
+2 -2
View File
@@ -104,10 +104,10 @@ class BlockViewed extends Module
$productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT i.id_image, p.id_product, il.legend, p.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.Shop::addSqlRestrictionOnLang('pl').')
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 (il.id_image = i.id_image)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.Shop::addSqlRestrictionOnLang('cl').')
WHERE p.id_product IN ('.$productIds.')
AND pl.id_lang = '.(int)($params['cookie']->id_lang).'
AND cl.id_lang = '.(int)($params['cookie']->id_lang)
+2 -2
View File
@@ -250,9 +250,9 @@ class WishList extends ObjectModel
SELECT wp.`id_product`, wp.`quantity`, p.`quantity` AS product_quantity, pl.`name`, wp.`id_product_attribute`, wp.`priority`, pl.link_rewrite, cl.link_rewrite AS category_rewrite
FROM `'._DB_PREFIX_.'wishlist_product` wp
JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = wp.`id_product`
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Context::getContext()->shop->addSqlRestrictionOnLang('pl').'
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = wp.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
JOIN `'._DB_PREFIX_.'wishlist` w ON w.`id_wishlist` = wp.`id_wishlist`
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = p.`id_category_default` AND cl.id_lang='.(int)$id_lang.Context::getContext()->shop->addSqlRestrictionOnLang('cl').'
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = p.`id_category_default` AND cl.id_lang='.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
WHERE w.`id_customer` = '.(int)($id_customer).'
AND pl.`id_lang` = '.(int)($id_lang).'
AND wp.`id_wishlist` = '.(int)($id_wishlist).
+4 -4
View File
@@ -142,8 +142,8 @@ class CrossSelling extends Module
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id NOT IN ('.$list_product_ids.') AND i.cover = 1 AND p.active = 1
@@ -190,8 +190,8 @@ class CrossSelling extends Module
SELECT DISTINCT od.product_id, pl.name, pl.link_rewrite, p.reference, i.id_image, p.show_price, cl.link_rewrite category, p.ean13
FROM '._DB_PREFIX_.'order_detail od
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = od.product_id)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = od.product_id'.Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default'.Shop::addSqlRestrictionOnLang('cl').')
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = od.product_id)
WHERE od.id_order IN ('.$list.') AND pl.id_lang = '.(int)$this->context->language->id.' AND cl.id_lang = '.(int)$this->context->language->id.'
AND od.product_id != '.(int)$params['product']->id.' AND i.cover = 1 AND p.active = 1
+3 -6
View File
@@ -54,11 +54,8 @@ class FavoriteProduct extends ObjectModel
),
);
public static function getFavoriteProducts($id_customer, $id_lang, Shop $shop = null)
public static function getFavoriteProducts($id_customer, $id_lang)
{
if (!$shop)
$shop = Context::getContext()->shop;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT fp.`id_shop`, p.`id_product`, pl.`description_short`, pl.`link_rewrite`,
pl.`name`, i.`id_image`, CONCAT(p.`id_product`, \'-\', i.`id_image`) as image
@@ -67,13 +64,13 @@ class FavoriteProduct extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON p.`id_product` = pl.`id_product`
AND pl.`id_lang` = '.(int)$id_lang
.$shop->addSqlRestrictionOnLang('pl').'
.Shop::addSqlRestrictionOnLang('pl').'
LEFT OUTER JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND `default_on` = 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)$id_lang.')
WHERE p.`active` = 1
'.($id_customer ? ' AND fp.id_customer = '.(int)$id_customer : '').'
'.$shop->addSqlRestriction(false, 'fp')
'.Shop::addSqlRestriction(false, 'fp')
);
}
+3 -3
View File
@@ -97,7 +97,7 @@ class MailAlert extends ObjectModel
$customer = new Customer($id_customer);
$customer_email = $customer->email;
$products = MailAlert::getProducts($customer, $id_lang, $shop);
$products = MailAlert::getProducts($customer, $id_lang);
if ((empty($products) === true) || (!sizeof($products)))
return array();
@@ -195,7 +195,7 @@ class MailAlert extends ObjectModel
/*
* Get products according to alerts
*/
public static function getProducts($customer, $id_lang, Shop $shop)
public static function getProducts($customer, $id_lang)
{
$sql = 'SELECT ma.`id_product`, p.`quantity` AS product_quantity, pl.`name`, ma.`id_product_attribute`
FROM `'._DB_PREFIX_.self::$definition['table'].'` ma
@@ -204,7 +204,7 @@ class MailAlert extends ObjectModel
WHERE p.`active` = 1
AND (ma.`id_customer` = '.(int)$customer->id.'
OR ma.`customer_email` = \''.pSQL($customer->email).'\')
AND pl.`id_lang` = '.(int)$id_lang.$shop->addSqlRestriction(false, 'ma');
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestriction(false, 'ma');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
}
+1 -1
View File
@@ -73,7 +73,7 @@ class Pagesnotfound extends Module
$sql = 'SELECT http_referer, request_uri, COUNT(*) as nb
FROM `'._DB_PREFIX_.'pagenotfound`
WHERE date_add BETWEEN '.ModuleGraph::getDateBetween()
.$this->sqlShopRestriction().
.Shop::addSqlRestriction().
'GROUP BY http_referer, request_uri';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+3 -3
View File
@@ -245,7 +245,7 @@ class ProductComment extends ObjectModel
SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
FROM `'._DB_PREFIX_.'product_comment` pc
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
WHERE pc.`validate` = '.(int)$validate.'
ORDER BY pc.`date_add` DESC'));
}
@@ -261,7 +261,7 @@ class ProductComment extends ObjectModel
SELECT pc.`id_product_comment`, pc.`id_product`, IF(c.id_customer, CONCAT(c.`firstname`, \' \', c.`lastname`), pc.customer_name) customer_name, pc.`content`, pc.`grade`, pc.`date_add`, pl.`name`
FROM `'._DB_PREFIX_.'product_comment` pc
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
ORDER BY pc.`date_add` DESC'));
}
@@ -388,7 +388,7 @@ class ProductComment extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'product_comment` pc
ON pcr.id_product_comment = pc.id_product_comment
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = pc.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Context::getContext()->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = pc.`id_product` AND pl.`id_lang` = '.(int)Context::getContext()->language->id.' AND pl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').')
ORDER BY pc.`date_add` DESC');
}
+1 -1
View File
@@ -47,7 +47,7 @@ class SEKeywords extends ModuleGraph
$this->_query = 'SELECT `keyword`, COUNT(TRIM(`keyword`)) as occurences
FROM `'._DB_PREFIX_.'sekeyword`
WHERE '.(Configuration::get('SEK_FILTER_KW') == '' ? '1' : '`keyword` REGEXP \''.pSQL(Configuration::get('SEK_FILTER_KW')).'\'')
.$this->sqlShopRestriction().
.Shop::addSqlRestriction().
' AND `date_add` BETWEEN ';
$this->_query2 = 'GROUP BY TRIM(`keyword`)
@@ -170,8 +170,8 @@ class StatsBestCategories extends ModuleGrid
AND dr.`time_end` BETWEEN '.$dateBetween.'
) AS totalPageViewed
FROM `'._DB_PREFIX_.'category` ca
LEFT JOIN `'._DB_PREFIX_.'category_lang` calang ON (ca.`id_category` = calang.`id_category` AND calang.`id_lang` = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('calang').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` parent ON (ca.`id_parent` = parent.`id_category` AND parent.`id_lang` = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('parent').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` calang ON (ca.`id_category` = calang.`id_category` AND calang.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('calang').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` parent ON (ca.`id_parent` = parent.`id_category` AND parent.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('parent').')
LEFT JOIN `'._DB_PREFIX_.'category_product` capr ON ca.`id_category` = capr.`id_category`
LEFT JOIN (
SELECT pr.`id_product`, t.`totalQuantitySold`, t.`totalPriceSold`
@@ -148,7 +148,7 @@ class StatsBestCustomers extends ModuleGrid
LEFT JOIN `'._DB_PREFIX_.'guest` g ON c.`id_customer` = g.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'connections` co ON g.`id_guest` = co.`id_guest`
WHERE co.date_add BETWEEN '.$this->getDate()
.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER, 'c').
.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c').
'GROUP BY c.`id_customer`, c.`lastname`, c.`firstname`, c.`email`';
if (Validate::IsName($this->_sort))
{
@@ -117,7 +117,7 @@ class StatsBestManufacturers extends ModuleGrid
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = od.id_order)
LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer)
WHERE o.invoice_date BETWEEN '.$this->getDate()
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').
.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').
'AND o.valid = 1
AND m.id_manufacturer IS NOT NULL';
return Db::getInstance()->getValue($sql);
@@ -133,7 +133,7 @@ class StatsBestManufacturers extends ModuleGrid
LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = od.id_order)
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)
WHERE '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
WHERE '.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.invoice_date BETWEEN '.$this->getDate().'
AND o.valid = 1
AND m.id_manufacturer IS NOT NULL
@@ -166,7 +166,7 @@ class StatsBestProducts extends ModuleGrid
) AS totalPageViewed
FROM '._DB_PREFIX_.'product p
'.$this->context->shop->addSqlAssociation('product', 'p').'
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->getLang().$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->getLang().Shop::addSqlRestrictionOnLang('pl').')
LEFT JOIN '._DB_PREFIX_.'order_detail od ON od.product_id = p.id_product
LEFT JOIN '._DB_PREFIX_.'orders o ON od.id_order = o.id_order
'.Product::sqlStock('p', 0).'
@@ -119,7 +119,7 @@ class StatsBestSuppliers extends ModuleGrid
LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = od.id_order
LEFT JOIN '._DB_PREFIX_.'supplier s ON s.id_supplier = p.id_supplier
WHERE o.invoice_date BETWEEN '.$this->getDate().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND s.id_supplier IS NOT NULL';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
@@ -135,7 +135,7 @@ class StatsBestSuppliers extends ModuleGrid
LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = od.id_order
LEFT JOIN '._DB_PREFIX_.'supplier s ON s.id_supplier = p.id_supplier
WHERE o.invoice_date BETWEEN '.$this->getDate().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND s.id_supplier IS NOT NULL
GROUP BY p.id_supplier';
@@ -115,7 +115,7 @@ class StatsBestVouchers extends ModuleGrid
FROM '._DB_PREFIX_.'order_cart_rule ocr
LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = ocr.id_order
WHERE o.valid = 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.invoice_date BETWEEN '.$this->getDate().'
GROUP BY ocr.id_cart_rule';
if (Validate::IsName($this->_sort))
+2 -2
View File
@@ -59,7 +59,7 @@ class StatsCarrier extends ModuleGraph
$sql = 'SELECT COUNT(o.`id_order`) as total
FROM `'._DB_PREFIX_.'orders` o
WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.((int)Tools::getValue('id_order_state') ? 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)Tools::getValue('id_order_state') : '');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
$states = OrderState::getOrderStates($this->context->language->id);
@@ -102,7 +102,7 @@ class StatsCarrier extends ModuleGraph
FROM `'._DB_PREFIX_.'carrier` c
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.id_carrier = c.id_carrier
WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.$stateQuery.'
GROUP BY c.`id_carrier`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
+1 -1
View File
@@ -124,7 +124,7 @@ class StatsCatalog extends Module
$sql = 'SELECT p.id_product, pl.name, pl.link_rewrite
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
'.$this->_join.'
WHERE p.`active` = 1
'.(count($precalc2) ? 'AND p.`id_product` NOT IN ('.implode(',', $precalc2).')' : '').'
+3 -3
View File
@@ -134,13 +134,13 @@ class StatsCheckUp extends Module
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
WHERE od.product_id = p.id_product
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
) as nbSales,
IFNULL(stock.quantity, 0) as stock
FROM '._DB_PREFIX_.'product p
'.Product::sqlStock('p', 0).'
LEFT JOIN '._DB_PREFIX_.'product_lang pl
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').')
'.$this->context->shop->addSqlAssociation('product', 'p').'
ORDER BY '.$orderBy;
$result = $db->executeS($sql);
@@ -229,7 +229,7 @@ class StatsCheckUp extends Module
FROM '._DB_PREFIX_.'product_lang pl
LEFT JOIN '._DB_PREFIX_.'lang l
ON pl.id_lang = l.id_lang
WHERE id_product = '.(int)$row['id_product'].$this->context->shop->addSqlRestrictionOnLang('pl'));
WHERE id_product = '.(int)$row['id_product'].Shop::addSqlRestrictionOnLang('pl'));
foreach ($descriptions as $description)
{
$row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description']));
+3 -3
View File
@@ -62,7 +62,7 @@ class StatsEquipment extends ModuleGraph
FROM `'._DB_PREFIX_.'connections` c
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_guest` = c.`id_guest`
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(false, 'c');
'.Shop::addSqlRestriction(false, 'c');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
$calcArray = array(
@@ -165,7 +165,7 @@ class StatsEquipment extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_web_browser` = wb.`id_web_browser`
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
WHERE 1
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND c.`date_add` BETWEEN ';
$this->_query2 = ' GROUP BY g.`id_web_browser`';
break;
@@ -177,7 +177,7 @@ class StatsEquipment extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_operating_system` = os.`id_operating_system`
LEFT JOIN `'._DB_PREFIX_.'connections` c ON g.`id_guest` = c.`id_guest`
WHERE 1
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND c.`date_add` BETWEEN ';
$this->_query2 = ' GROUP BY g.`id_operating_system`';
break;
+18 -18
View File
@@ -119,7 +119,7 @@ class StatsForecast extends Module
LEFT JOIN '._DB_PREFIX_.'product p ON od.product_id = p.id_product
WHERE o.valid = 1
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY '.$dateFromGInvoice.'
ORDER BY fix_date';
$result = $db->query($sql);
@@ -157,7 +157,7 @@ class StatsForecast extends Module
$sql = 'SELECT '.$dateFromGAdd.' as fix_date, COUNT(*) as visits
FROM '._DB_PREFIX_.'connections c
WHERE c.date_add BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
GROUP BY '.$dateFromGAdd;
$visits = Db::getInstance()->query($sql);
while ($row = $db->nextRow($visits))
@@ -170,7 +170,7 @@ class StatsForecast extends Module
WHERE o.valid = 1
AND o.total_paid_real > 0
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween()
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY '.$dateFromGInvoice;
$discounts = Db::getInstance()->query($sql);
while ($row = $db->nextRow($discounts))
@@ -188,7 +188,7 @@ class StatsForecast extends Module
$sql = 'SELECT COUNT(*) FROM '._DB_PREFIX_.'customer
WHERE date_add BETWEEN '.ModuleGraph::getDateBetween().'
AND date_add '.$dateFromGReg
.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER);
.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
$row['registrations'] = Db::getInstance()->getValue($sql);
$totalHT = $row['totalProducts'] - $discountToday;
@@ -266,7 +266,7 @@ class StatsForecast extends Module
$sql = 'SELECT COUNT(DISTINCT c.id_guest)
FROM '._DB_PREFIX_.'connections c
WHERE c.date_add BETWEEN '.ModuleGraph::getDateBetween()
.$this->sqlShopRestriction(false, 'c');
.Shop::addSqlRestriction(false, 'c');
$visitors = Db::getInstance()->getValue($sql);
$sql = 'SELECT COUNT(DISTINCT g.id_customer)
@@ -274,7 +274,7 @@ class StatsForecast extends Module
INNER JOIN '._DB_PREFIX_.'guest g ON c.id_guest = g.id_guest
WHERE g.id_customer != 0
AND c.date_add BETWEEN '.ModuleGraph::getDateBetween()
.$this->sqlShopRestriction(false, 'c');
.Shop::addSqlRestriction(false, 'c');
$customers = Db::getInstance()->getValue($sql);
$sql = 'SELECT COUNT(*)
@@ -283,7 +283,7 @@ class StatsForecast extends Module
SELECT id_cart FROM '._DB_PREFIX_.'cart_product
) AND (
date_add BETWEEN '.ModuleGraph::getDateBetween().' OR date_upd BETWEEN '.ModuleGraph::getDateBetween().'
)'.$this->sqlShopRestriction();
)'.Shop::addSqlRestriction();
$carts = Db::getInstance()->getValue($sql);
$sql = 'SELECT COUNT(*)
@@ -293,14 +293,14 @@ class StatsForecast extends Module
) AND id_address_invoice != 0
AND (
date_add BETWEEN '.ModuleGraph::getDateBetween().' OR date_upd BETWEEN '.ModuleGraph::getDateBetween().'
)'.$this->sqlShopRestriction();
)'.Shop::addSqlRestriction();
$fullcarts = Db::getInstance()->getValue($sql);
$sql = 'SELECT COUNT(*)
FROM '._DB_PREFIX_.'orders o
WHERE o.valid = 1
AND o.date_add BETWEEN '.ModuleGraph::getDateBetween()
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o');
.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o');
$orders = Db::getInstance()->getValue($sql);
$this->_html .= '<br />
@@ -499,12 +499,12 @@ class StatsForecast extends Module
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = od.product_id
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.id_category_default = cl.id_category AND cl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').')
'.$join.'
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$where.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY p.id_category_default';
$ca['cat'] = Db::getInstance()->executeS($sql);
uasort($ca['cat'], 'statsforecast_sort');
@@ -525,7 +525,7 @@ class StatsForecast extends Module
FROM `'._DB_PREFIX_.'orders` o
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o');
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o');
$ca['lang'] = Db::getInstance()->getRow($sql);
arsort($ca['lang']);
@@ -533,7 +533,7 @@ class StatsForecast extends Module
FROM `'._DB_PREFIX_.'orders` o
WHERE o.valid = 1
AND ADDDATE(o.`invoice_date`, interval 30 day) BETWEEN \''.$employee->stats_date_from.' 00:00:00\' AND \''.min(date('Y-m-d H:i:s'), $employee->stats_date_to.' 23:59:59').'\'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o');
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o');
$ca['langprev'] = Db::getInstance()->getRow($sql);
}
else
@@ -548,7 +548,7 @@ class StatsForecast extends Module
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$where.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY o.module
ORDER BY total DESC';
$ca['payment'] = Db::getInstance()->executeS($sql);
@@ -560,7 +560,7 @@ class StatsForecast extends Module
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.id_zone = c.id_zone
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY c.id_zone
ORDER BY total DESC';
$ca['zones'] = Db::getInstance()->executeS($sql);
@@ -572,7 +572,7 @@ class StatsForecast extends Module
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$where.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY o.id_currency
ORDER BY total DESC';
$ca['currencies'] = Db::getInstance()->executeS($sql);
@@ -581,7 +581,7 @@ class StatsForecast extends Module
FROM `'._DB_PREFIX_.'orders` o
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o');
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o');
$ca['ventil'] = Db::getInstance()->getRow($sql);
$sql = 'SELECT /*pac.id_attribute,*/ agl.name as gname, al.name as aname, COUNT(*) as total
@@ -593,7 +593,7 @@ class StatsForecast extends Module
INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (a.id_attribute = al.id_attribute AND al.id_lang = '.(int)$this->context->language->id.')
WHERE o.valid = 1
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY pac.id_attribute';
$ca['attributes'] = Db::getInstance()->executeS($sql);
+3 -3
View File
@@ -66,7 +66,7 @@ class StatsLive extends Module
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
WHERE cp.`time_end` IS NULL
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
GROUP BY c.id_connections
ORDER BY u.firstname, u.lastname';
@@ -90,7 +90,7 @@ class StatsLive extends Module
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND cp.`time_end` IS NULL
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
GROUP BY c.id_connections
@@ -102,7 +102,7 @@ class StatsLive extends Module
FROM `'._DB_PREFIX_.'connections` c
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND TIME_TO_SEC(TIMEDIFF(NOW(), c.`date_add`)) < 900
ORDER BY c.date_add DESC';
}
+4 -4
View File
@@ -82,14 +82,14 @@ class StatsNewsletter extends ModuleGraph
$sql = 'SELECT COUNT(*) as customers
FROM `'._DB_PREFIX_.'customer`
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
$sql = 'SELECT COUNT(*) as visitors
FROM '._DB_PREFIX_.'newsletter
WHERE 1
'.$this->sqlShopRestriction().'
'.Shop::addSqlRestriction().'
AND `newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween();
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
return array('customers' => $result1['customers'], 'visitors' => $result2['visitors'], 'both' => $result1['customers'] + $result2['visitors']);
@@ -105,13 +105,13 @@ class StatsNewsletter extends ModuleGraph
$this->_query = 'SELECT newsletter_date_add
FROM `'._DB_PREFIX_.'customer`
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `newsletter_date_add` BETWEEN ';
$this->_query2 = 'SELECT newsletter_date_add
FROM '._DB_PREFIX_.'newsletter
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `newsletter_date_add` BETWEEN ';
$this->setDateGraph($layers, true);
}
+1 -1
View File
@@ -57,7 +57,7 @@ class StatsOrigin extends ModuleGraph
$sql = 'SELECT http_referer
FROM '._DB_PREFIX_.'connections
WHERE 1
'.$this->sqlShopRestriction().'
'.Shop::addSqlRestriction().'
AND date_add BETWEEN '.$dateBetween;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
$websites = array($directLink => 0);
@@ -133,7 +133,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM '._DB_PREFIX_.'customer c
LEFT JOIN '._DB_PREFIX_.'gender g ON c.id_gender = g.id_gender
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER, 'c').'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c').'
GROUP BY c.id_gender';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -160,7 +160,7 @@ class StatsPersonalInfos extends ModuleGraph
$sql = 'SELECT COUNT(`id_customer`) as total
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 18
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -174,7 +174,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 18
AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 25
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -188,7 +188,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 25
AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 35
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -202,7 +202,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 35
AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 50
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -216,7 +216,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 50
AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 60
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -229,7 +229,7 @@ class StatsPersonalInfos extends ModuleGraph
$sql = 'SELECT COUNT(`id_customer`) as total
FROM `'._DB_PREFIX_.'customer`
WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 60
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `birthday` IS NOT NULL';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
@@ -242,7 +242,7 @@ class StatsPersonalInfos extends ModuleGraph
$sql = 'SELECT COUNT(`id_customer`) as total
FROM `'._DB_PREFIX_.'customer`
WHERE `birthday` IS NULL
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER);
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (isset($result['total']) && $result['total'])
{
@@ -259,7 +259,7 @@ class StatsPersonalInfos extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'country` c ON a.`id_country` = c.`id_country`
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')
WHERE a.id_customer != 0
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER, 'cu').'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'cu').'
GROUP BY c.`id_country`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
@@ -275,7 +275,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.`id_currency` = c.`id_currency`
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY c.`id_currency`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
@@ -291,7 +291,7 @@ class StatsPersonalInfos extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'lang` c ON o.`id_lang` = c.`id_lang`
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
GROUP BY c.`id_lang`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $row)
+10 -10
View File
@@ -61,7 +61,7 @@ class StatsProduct extends ModuleGraph
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)$id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween;
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
@@ -74,7 +74,7 @@ class StatsProduct extends ModuleGraph
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)$id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween;
return (float)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
@@ -89,7 +89,7 @@ class StatsProduct extends ModuleGraph
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\'
'.$this->sqlShopRestriction(false, 'pv').'
'.Shop::addSqlRestriction(false, 'pv').'
AND p.`id_object` = '.(int)$id_product.'
AND dr.`time_start` BETWEEN '.$dateBetween.'
AND dr.`time_end` BETWEEN '.$dateBetween;
@@ -102,7 +102,7 @@ class StatsProduct extends ModuleGraph
$sql = 'SELECT p.`id_product`, p.reference, pl.`name`, IFNULL(stock.quantity, 0) as quantity
FROM `'._DB_PREFIX_.'product` p
'.Product::sqlStock('p', 0).'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.$this->context->shop->addSqlRestrictionOnLang('pl').'
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`'.Shop::addSqlRestrictionOnLang('pl').'
'.$this->context->shop->addSqlAssociation('product', 'p').'
'.(Tools::getValue('id_category') ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`' : '').'
WHERE pl.`id_lang` = '.(int)$id_lang.'
@@ -118,7 +118,7 @@ class StatsProduct extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
WHERE o.date_add BETWEEN '.$this->getDate().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND od.product_id = '.(int)$id_product;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -129,7 +129,7 @@ class StatsProduct extends ModuleGraph
$sql = 'SELECT pl.name as pname, pl.id_product, SUM(od.product_quantity) as pqty, AVG(od.product_price) as pprice
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = od.product_id AND pl.id_lang = '.(int)$id_lang.$this->context->shop->addSqlRestrictionOnLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = od.product_id AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
WHERE o.id_customer IN (
SELECT o.id_customer
FROM `'._DB_PREFIX_.'orders` o
@@ -138,7 +138,7 @@ class StatsProduct extends ModuleGraph
AND o.valid = 1
AND od.product_id = '.(int)$id_product.'
)
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.date_add BETWEEN '.$this->getDate().'
AND o.valid = 1
AND od.product_id != '.(int)$id_product.'
@@ -312,7 +312,7 @@ class StatsProduct extends ModuleGraph
FROM `'._DB_PREFIX_.'order_detail` od
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)$this->_id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween.'
GROUP BY o.`date_add`';
@@ -323,7 +323,7 @@ class StatsProduct extends ModuleGraph
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\'
'.$this->sqlShopRestriction(false, 'pv').'
'.Shop::addSqlRestriction(false, 'pv').'
AND p.`id_object` = '.(int)$this->_id_product.'
AND dr.`time_start` BETWEEN '.$dateBetween.'
AND dr.`time_end` BETWEEN '.$dateBetween.'
@@ -335,7 +335,7 @@ class StatsProduct extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order`
WHERE od.`product_id` = '.(int)$this->_id_product.'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND o.`date_add` BETWEEN '.$dateBetween.'
GROUP BY od.`product_attribute_id`';
@@ -63,7 +63,7 @@ class StatsRegistrations extends ModuleGraph
$sql = 'SELECT COUNT(`id_customer`) as total
FROM `'._DB_PREFIX_.'customer`
WHERE `date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER);
'.Shop::addSqlRestriction(Shop::SHARE_ORDER);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
return isset($result['total']) ? $result['total'] : 0;
}
@@ -80,7 +80,7 @@ class StatsRegistrations extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_connections = cp.id_connections
LEFT JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
WHERE pt.name = "authentication"
'.$this->sqlShopRestriction(false, 'c').'
'.Shop::addSqlRestriction(false, 'c').'
AND (g.id_customer IS NULL OR g.id_customer = 0)
AND c.`date_add` BETWEEN '.ModuleGraph::getDateBetween();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -94,7 +94,7 @@ class StatsRegistrations extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'guest` g ON o.id_customer = g.id_customer
LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_guest = g.id_guest
WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
AND o.valid = 1
AND ABS(TIMEDIFF(o.date_add, c.date_add)+0) < 120000';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -143,7 +143,7 @@ class StatsRegistrations extends ModuleGraph
SELECT `date_add`
FROM `'._DB_PREFIX_.'customer`
WHERE 1
'.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).'
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND `date_add` BETWEEN';
$this->_titles['main'] = $this->l('Number of customer accounts created');
$this->setDateGraph($layers, true);
+3 -3
View File
@@ -109,7 +109,7 @@ class StatsSales extends ModuleGraph
FROM `'._DB_PREFIX_.'orders` o
'.((int)Tools::getValue('id_country') ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').'
WHERE o.valid = 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.((int)Tools::getValue('id_country') ? 'AND a.id_country = '.(int)Tools::getValue('id_country') : '').'
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween();
$result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -119,7 +119,7 @@ class StatsSales extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order`
'.((int)Tools::getValue('id_country') ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').'
WHERE o.valid = 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.((int)Tools::getValue('id_country') ? 'AND a.id_country = '.(int)Tools::getValue('id_country') : '').'
AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween();
$result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -158,7 +158,7 @@ class StatsSales extends ModuleGraph
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order`
'.((int)($this->id_country) ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').'
WHERE o.valid = 1
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.((int)($this->id_country) ? 'AND a.id_country = '.(int)$this->id_country : '').'
AND o.`invoice_date` BETWEEN ';
$this->_query2 = ' GROUP BY o.id_order';
+1 -1
View File
@@ -47,7 +47,7 @@ class StatsSearch extends ModuleGraph
$this->_query = 'SELECT `keywords`, COUNT(TRIM(`keywords`)) as occurences, MAX(results) as total
FROM `'._DB_PREFIX_.'statssearch`
WHERE 1
'.$this->sqlShopRestriction().'
'.Shop::addSqlRestriction().'
AND `date_add` BETWEEN ';
$this->_query2 = 'GROUP BY `keywords`
+1 -1
View File
@@ -70,7 +70,7 @@ class StatsStock extends Module
FROM '._DB_PREFIX_.'product p
'.$this->context->shop->addSqlAssociation('product', 'p').'
INNER JOIN '._DB_PREFIX_.'product_lang pl
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->addSqlRestrictionOnLang('pl').')
ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('pl').')
'.Product::sqlStock('p', 0).'
WHERE 1 = 1
'.$filter;
+4 -4
View File
@@ -59,7 +59,7 @@ class StatsVisits extends ModuleGraph
$sql = 'SELECT COUNT(c.`id_connections`)
FROM `'._DB_PREFIX_.'connections` c
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(false, 'c');
'.Shop::addSqlRestriction(false, 'c');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
@@ -68,7 +68,7 @@ class StatsVisits extends ModuleGraph
$sql = 'SELECT COUNT(DISTINCT c.`id_guest`)
FROM `'._DB_PREFIX_.'connections` c
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
'.$this->sqlShopRestriction(false, 'c');
'.Shop::addSqlRestriction(false, 'c');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
@@ -120,12 +120,12 @@ class StatsVisits extends ModuleGraph
$this->_query[0] = 'SELECT date_add, COUNT(`date_add`) as total
FROM `'._DB_PREFIX_.'connections`
WHERE 1
'.$this->sqlShopRestriction().'
'.Shop::addSqlRestriction().'
AND `date_add` BETWEEN ';
$this->_query[1] = 'SELECT date_add, COUNT(DISTINCT `id_guest`) as total
FROM `'._DB_PREFIX_.'connections`
WHERE 1
'.$this->sqlShopRestriction().'
'.Shop::addSqlRestriction().'
AND `date_add` BETWEEN ';
break;
}