// Context part 15
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7658 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -54,7 +54,7 @@ class AdminInvoices extends AdminTab
|
||||
LIMIT 1
|
||||
) id_order_state
|
||||
FROM '._DB_PREFIX_.'orders o
|
||||
WHERE o.id_shop IN('.implode(', ', Shop::getListFromContext()).')
|
||||
WHERE o.id_shop IN('.implode(', ', $context->shop->getListOfID()).')
|
||||
GROUP BY id_order_state');
|
||||
$statusStats = array();
|
||||
foreach ($result as $row)
|
||||
|
||||
@@ -82,9 +82,9 @@ class AdminModulesPositions extends AdminTab
|
||||
// Adding vars...
|
||||
else
|
||||
{
|
||||
if (!$module->registerHook($hook->name, Shop::getListFromContext()))
|
||||
if (!$module->registerHook($hook->name, Context::getContext()->shop->getListOfID()))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
|
||||
elseif (!$module->registerExceptions($id_hook, $excepts, Shop::getListFromContext()))
|
||||
elseif (!$module->registerExceptions($id_hook, $excepts, Context::getContext()->shop->getListOfID()))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
@@ -124,7 +124,7 @@ class AdminModulesPositions extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('No valid value for field exceptions');
|
||||
|
||||
// Add files exceptions
|
||||
if (!$module->editExceptions($id_hook, $exception, Shop::getListFromContext()))
|
||||
if (!$module->editExceptions($id_hook, $exception, Context::getContext()->shop->getListOfID()))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class AdminModulesPositions extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('No valid value for field exceptions');
|
||||
|
||||
// Add files exceptions
|
||||
if (!$module->editExceptions($id_hook, $exceptions, Shop::getListFromContext()))
|
||||
if (!$module->editExceptions($id_hook, $exceptions, Context::getContext()->shop->getListOfID()))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while transplanting module to hook.');
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=16'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
@@ -167,7 +167,7 @@ class AdminModulesPositions extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('Hook cannot be loaded.');
|
||||
else
|
||||
{
|
||||
if (!$module->unregisterHook($id_hook, Shop::getListFromContext()) OR !$module->unregisterExceptions($id_hook, Shop::getListFromContext()))
|
||||
if (!$module->unregisterHook($id_hook, Context::getContext()->shop->getListOfID()) OR !$module->unregisterExceptions($id_hook, Context::getContext()->shop->getListOfID()))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while deleting module from hook.');
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->displayKey ? '&show_modules='.$this->displayKey : '').'&token='.$this->token);
|
||||
@@ -347,7 +347,7 @@ class AdminModulesPositions extends AdminTab
|
||||
FROM '._DB_PREFIX_.'hook_module
|
||||
WHERE id_module = '.$id_module.'
|
||||
AND id_hook = '.$id_hook.'
|
||||
AND id_shop IN('.implode(', ', ShopCore::getListFromContext()).')';
|
||||
AND id_shop IN('.implode(', ', Context::getContext()->shop->getListOfID()).')';
|
||||
if (!Db::getInstance()->getValue($sql))
|
||||
Tools::redirectAdmin(self::$currentIndex . '&token='.$this->token);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class AdminStockMvt extends AdminTab
|
||||
$context = Context::getContext();
|
||||
|
||||
$this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) employee, mrl.name reason';
|
||||
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock '.Shop::sqlSharedStock('stock').'
|
||||
$this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock '.$context->shop->sqlSharedStock('stock').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (stock.id_product = pl.id_product AND pl.id_lang = '.(int)$context->language->id.' AND pl.id_shop = '.$context->shop->getID(true).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (a.id_stock_mvt_reason = mrl.id_stock_mvt_reason AND mrl.id_lang = '.(int)$context->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
|
||||
|
||||
@@ -1124,6 +1124,7 @@ abstract class AdminTabCore
|
||||
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
/* Manage default params values */
|
||||
if (empty($limit))
|
||||
$limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $context->cookie->{$this->table.'_pagination'});
|
||||
@@ -1168,14 +1169,14 @@ 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 = Shop::sqlRestriction($this->shopShareDatas, 'a', null, null, $this->shopLinkType);
|
||||
$whereShop = $context->shop->sqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
|
||||
}
|
||||
|
||||
$assos = Shop::getAssoTables();
|
||||
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'shop')
|
||||
{
|
||||
$filterKey = $assos[$this->table]['type'];
|
||||
$idenfierShop = Shop::getListFromContext();
|
||||
$idenfierShop = $context->shop->getListOfID();
|
||||
}
|
||||
else if (Context::shop() == Shop::CONTEXT_GROUP)
|
||||
{
|
||||
|
||||
@@ -118,12 +118,15 @@ class AttributeCore extends ObjectModel
|
||||
* @param integer $qty Quantity needed
|
||||
* @return boolean Quantity is available or not
|
||||
*/
|
||||
static public function checkAttributeQty($id_product_attribute, $qty)
|
||||
{
|
||||
static public function checkAttributeQty($id_product_attribute, $qty, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT quantity
|
||||
FROM '._DB_PREFIX_.'stock
|
||||
WHERE id_product_attribute = '.(int)$id_product_attribute
|
||||
.Shop::sqlSharedStock();
|
||||
.$context->shop->sqlSharedStock();
|
||||
$result = (int)Db::getInstance()->getValue($sql);
|
||||
|
||||
return ($result AND $qty <= $result);
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ class CMSCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getLinks($id_lang, $selection = NULL, $active = true, $id_shop = false, Context $context = null)
|
||||
public static function getLinks($id_lang, $selection = NULL, $active = true, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
+24
-23
@@ -176,35 +176,36 @@ class CMSCategoryCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
static public function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, $id_shop = false, Context $context = null)
|
||||
static public function getRecurseCategory($id_lang = null, $current = 1, $active = 1, $links = 0, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$id_lang = is_null($id_lang) ? $context->language->id : $id_lang;
|
||||
|
||||
$category = Db::getInstance()->getRow('
|
||||
SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category` c
|
||||
JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
|
||||
WHERE c.`id_cms_category` = '.(int)($current).'
|
||||
AND `id_lang` = '.(int)($id_lang));
|
||||
$result = Db::getInstance()->ExecuteS('
|
||||
SELECT c.`id_cms_category`
|
||||
FROM `'._DB_PREFIX_.'cms_category` c
|
||||
WHERE c.`id_parent` = '.(int)($current).
|
||||
($active ? ' AND c.`active` = 1' : ''));
|
||||
$id_lang = is_null($id_lang) ? $context->language->id : (int)$id_lang;
|
||||
|
||||
$sql = 'SELECT c.`id_cms_category`, c.`id_parent`, c.`level_depth`, cl.`name`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms_category` c
|
||||
JOIN `'._DB_PREFIX_.'cms_category_lang` cl ON c.`id_cms_category` = cl.`id_cms_category`
|
||||
WHERE c.`id_cms_category` = '.(int)$current.'
|
||||
AND `id_lang` = '.$id_lang;
|
||||
$category = Db::getInstance()->getRow($sql);
|
||||
|
||||
$sql = 'SELECT c.`id_cms_category`
|
||||
FROM `'._DB_PREFIX_.'cms_category` c
|
||||
WHERE c.`id_parent` = '.(int)$current.
|
||||
($active ? ' AND c.`active` = 1' : '');
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
foreach ($result as $row)
|
||||
$category['children'][] = self::getRecurseCategory($id_lang, $row['id_cms_category'], $active, $links);
|
||||
$category['cms'] = Db::getInstance()->ExecuteS('
|
||||
SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms` c
|
||||
'.($id_shop ? 'LEFT JOIN '._DB_PREFIX_.'cms_shop cs ON (cs.id_cms = c.id_cms)' : '').'
|
||||
JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms`
|
||||
WHERE `id_cms_category` = '.(int)($current).'
|
||||
'.($id_shop ? ' AND cs.id_shop='.(int)$id_shop : '').'
|
||||
AND cl.`id_lang` = '.(int)($id_lang).($active ? ' AND c.`active` = 1' : '').'
|
||||
ORDER BY c.`position`');
|
||||
|
||||
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'cms` c
|
||||
'.$context->shop->sqlAsso('cms', 'c').'
|
||||
JOIN `'._DB_PREFIX_.'cms_lang` cl ON c.`id_cms` = cl.`id_cms`
|
||||
WHERE `id_cms_category` = '.(int)$current.'
|
||||
AND cl.`id_lang` = '.$id_lang.($active ? ' AND c.`active` = 1' : '').'
|
||||
ORDER BY c.`position`';
|
||||
$category['cms'] = Db::getInstance()->ExecuteS($sql);
|
||||
if ($links == 1)
|
||||
{
|
||||
$category['link'] = $link->getCMSCategoryLink($current, $category['link_rewrite']);
|
||||
|
||||
+4
-4
@@ -1231,7 +1231,7 @@ class CartCore extends ObjectModel
|
||||
*
|
||||
* @return mixed Return a string if an error occurred and false otherwise
|
||||
*/
|
||||
function checkDiscountValidity($discountObj, $discounts, $order_total, $products, $checkCartDiscount = false, $id_group_shop = false, $id_shop = false, Context $context = null)
|
||||
function checkDiscountValidity($discountObj, $discounts, $order_total, $products, $checkCartDiscount = false, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
@@ -1255,8 +1255,8 @@ class CartCore extends ObjectModel
|
||||
return Tools::displayError('This voucher is not yet valid');
|
||||
if (strtotime($discountObj->date_to) < time())
|
||||
return Tools::displayError('This voucher has expired.');
|
||||
if ($id_group_shop AND $id_shop)
|
||||
if (!$discountObj->availableWithShop((int)$id_group_shop, (int)$id_shop))
|
||||
if (!$context->shop->inGlobalContext())
|
||||
if (!$discountObj->availableWithShop($context))
|
||||
return Tools::displayError('This voucher is not available with this shop.');
|
||||
if (sizeof($discounts) >= 1 AND $checkCartDiscount)
|
||||
{
|
||||
@@ -1427,7 +1427,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
|
||||
'.Shop::sqlRestriction(true, 'c').'
|
||||
'.Context::getContext()->shop->sqlRestriction(true, 'c').'
|
||||
ORDER BY c.`date_upd` DESC';
|
||||
if (!$id_cart = Db::getInstance()->getValue($sql))
|
||||
return false;
|
||||
|
||||
@@ -368,7 +368,7 @@ class CategoryCore extends ObjectModel
|
||||
* @param boolean $active return only active categories
|
||||
* @return array Categories
|
||||
*/
|
||||
static public function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '',$sql_limit = '', $id_shop = false)
|
||||
static public function getCategories($id_lang = false, $active = true, $order = true, $sql_filter = '', $sql_sort = '', $sql_limit = '')
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
@@ -493,7 +493,7 @@ class CategoryCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(cp.`id_product`) AS total
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::sqlAsso('product', 'p', true, $context).'
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
|
||||
WHERE cp.`id_category` = '.(int)($this->id).
|
||||
($active ? ' AND p.`active` = 1' : '').
|
||||
@@ -506,10 +506,10 @@ class CategoryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
|
||||
'.Shop::sqlAsso('product', 'p', true, $context).'
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.Product::sqlStock('p', 'pa', false, $context).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.Shop::sqlLang('cl', $context).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::sqlLang('pl', $context).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('cl').')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('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_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
@@ -567,13 +567,12 @@ class CategoryCore extends ObjectModel
|
||||
return self::getChildren(1, $id_lang, $active);
|
||||
}
|
||||
|
||||
static public function getRootCategory($id_lang = NULL, $id_shop = false, Context $context = null)
|
||||
static public function getRootCategory($id_lang = NULL, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$shop = new Shop($context->shop->getID(true));
|
||||
|
||||
return new Category($shop->getCategory(), is_null($id_lang) ? $context->language->id : $id_lang);
|
||||
|
||||
return new Category($context->shop->getCategory(), is_null($id_lang) ? $context->language->id : $id_lang);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,8 +91,11 @@ class ConnectionCore extends ObjectModel
|
||||
'time_start' => $time_start);
|
||||
}
|
||||
|
||||
public static function setNewConnection($cookie)
|
||||
{
|
||||
public static function setNewConnection($cookie, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])
|
||||
AND 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|H�m�h�kki|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']))
|
||||
{
|
||||
@@ -100,7 +103,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')).'\'
|
||||
AND id_shop = '.Shop::sqlRestriction().'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
ORDER BY `date_add` DESC';
|
||||
if ($id_connections = Db::getInstance()->getValue($sql))
|
||||
{
|
||||
@@ -114,7 +117,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::sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
ORDER BY `date_add` DESC';
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
if (!$result['id_guest'] AND (int)($cookie->id_guest))
|
||||
|
||||
+12
-8
@@ -73,17 +73,21 @@ class ContactCore extends ObjectModel
|
||||
* Return available contacts
|
||||
*
|
||||
* @param integer $id_lang Language ID
|
||||
* @param Context
|
||||
* @return array Contacts
|
||||
*/
|
||||
static public function getContacts($id_lang, $id_shop = false)
|
||||
static public function getContacts($id_lang, Context $context = null)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'contact` c
|
||||
'.($id_shop ? 'LEFT JOIN '._DB_PREFIX_.'contact_shop cs ON (cs.id_contact = c.id_contact)' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`)
|
||||
WHERE cl.`id_lang` = '.(int)($id_lang).($id_shop ? ' AND cs.id_shop='.(int)$id_shop : '').'
|
||||
ORDER BY `name` ASC');
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'contact` c
|
||||
'.$context->shop->sqlAsso('contact', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`)
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
ORDER BY `name` ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-22
@@ -118,7 +118,7 @@ class CountryCore extends ObjectModel
|
||||
* @param boolean $active return only active coutries
|
||||
* @return array Countries and corresponding zones
|
||||
*/
|
||||
static public function getCountries($id_lang, $active = false, $containStates = NULL, $id_shop = false)
|
||||
static public function getCountries($id_lang, $active = false, $containStates = NULL, Context $context = null)
|
||||
{
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
@@ -128,17 +128,16 @@ class CountryCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'state` s
|
||||
ORDER BY s.`name` ASC');
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.($id_shop ? 'LEFT JOIN '._DB_PREFIX_.'country_shop cs ON (cs.id_country = c.id_country)' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)($id_lang).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
|
||||
WHERE 1
|
||||
'.($active ? ' AND c.active = 1' : '')
|
||||
.($id_shop ? ' AND cs.id_shop='.(int)$id_shop : '')
|
||||
.(!is_null($containStates) ? 'AND c.`contains_states` = '.(int)($containStates) : '').'
|
||||
ORDER BY cl.name ASC');
|
||||
$sql = 'SELECT cl.*,c.*, cl.`name` AS country, z.`name` AS zone
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$context->shop->sqlAsso('country', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$id_lang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
|
||||
WHERE 1'
|
||||
.($active ? ' AND c.active = 1' : '')
|
||||
.(!is_null($containStates) ? 'AND c.`contains_states` = '.(int)($containStates) : '').'
|
||||
ORDER BY cl.name ASC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
$countries = array();
|
||||
foreach ($result AS &$country)
|
||||
$countries[$country['id_country']] = $country;
|
||||
@@ -289,19 +288,19 @@ class CountryCore extends ObjectModel
|
||||
return Context::getContext()->country->id;
|
||||
}
|
||||
|
||||
public static function getCountriesByZoneId($id_zone, $id_lang, $id_shop = false)
|
||||
public static function getCountriesByZoneId($id_zone, $id_lang, Context $context = null)
|
||||
{
|
||||
if (empty($id_zone) OR empty($id_lang))
|
||||
die(Tools::displayError());
|
||||
return Db::getInstance()->ExecuteS('
|
||||
SELECT DISTINCT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.($id_shop ? ' LEFT JOIN '._DB_PREFIX_.'country_shop cs ON (cs.id_country = c.id_country)' : '').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.')
|
||||
'.($id_shop ? ' AND cs.id_shop='.(int)$id_shop : '').'
|
||||
AND `id_lang` = '.(int)$id_lang);
|
||||
|
||||
$sql = ' SELECT DISTINCT c.*, cl.*
|
||||
FROM `'._DB_PREFIX_.'country` c
|
||||
'.$context->shop->sqlAsso('country', 'c').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
WHERE (c.`id_zone` = '.(int)$id_zone.' OR s.`id_zone` = '.(int)$id_zone.')
|
||||
AND `id_lang` = '.(int)$id_lang;
|
||||
return Db::getInstance()->ExecuteS($sql);
|
||||
}
|
||||
|
||||
public function isNeedDni()
|
||||
|
||||
+11
-8
@@ -180,15 +180,18 @@ class CurrencyCore extends ObjectModel
|
||||
*
|
||||
* @return array Currencies
|
||||
*/
|
||||
static public function getCurrencies($object = false, $active = 1, $id_shop = false)
|
||||
static public function getCurrencies($object = false, $active = 1, Context $context = null)
|
||||
{
|
||||
$tab = Db::getInstance()->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.($id_shop ? 'LEFT JOIN '._DB_PREFIX_.'currency_shop cs ON (c.id_currency = cs.id_currency)' : '').'
|
||||
WHERE `deleted` = 0
|
||||
'.($active == 1 ? 'AND c.`active` = 1' : '').($id_shop ? ' AND cs.id_shop='.(int)$id_shop : '').'
|
||||
ORDER BY `name` ASC');
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'currency` c
|
||||
'.$context->shop->sqlAsso('currency', 'c').'
|
||||
WHERE `deleted` = 0'
|
||||
.($active == 1 ? ' AND c.`active` = 1' : '').'
|
||||
ORDER BY `name` ASC';
|
||||
$tab = Db::getInstance()->ExecuteS($sql);
|
||||
if ($object)
|
||||
foreach ($tab as $key => $currency)
|
||||
$tab[$key] = Currency::getCurrencyInstance($currency['id_currency']);
|
||||
|
||||
+20
-8
@@ -198,12 +198,15 @@ class CustomerCore extends ObjectModel
|
||||
*
|
||||
* @return array Customers
|
||||
*/
|
||||
static public function getCustomers()
|
||||
static public function getCustomers(Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE 1
|
||||
'.Shop::sqlRestriction(true).'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
ORDER BY `id_customer` ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
}
|
||||
@@ -215,16 +218,19 @@ class CustomerCore extends ObjectModel
|
||||
* @param string $passwd Password is also checked if specified
|
||||
* @return Customer instance
|
||||
*/
|
||||
public function getByEmail($email, $passwd = NULL, $id_group_shop = null, $id_shop = null)
|
||||
public function getByEmail($email, $passwd = NULL, Context $context = null)
|
||||
{
|
||||
if (!Validate::isEmail($email) OR ($passwd AND !Validate::isPasswd($passwd)))
|
||||
die (Tools::displayError());
|
||||
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_ .'customer`
|
||||
WHERE `active` = 1
|
||||
AND `email` = \''.pSQL($email).'\'
|
||||
'.Shop::sqlRestriction(true, null, $id_shop, $id_group_shop).'
|
||||
'.$context->shop->sqlRestriction(true).'
|
||||
'.(isset($passwd) ? 'AND `passwd` = \''.md5(_COOKIE_KEY_.$passwd).'\'' : '').'
|
||||
AND `deleted` = 0
|
||||
AND `is_guest` = 0';
|
||||
@@ -268,15 +274,18 @@ class CustomerCore extends ObjectModel
|
||||
* @param $ignoreGuest boolean, for exclure guest customer
|
||||
* @return Customer ID if found, false otherwise
|
||||
*/
|
||||
static public function customerExists($email, $return_id = false, $ignoreGuest = true, $id_group_shop = null, $id_shop = null)
|
||||
static public function customerExists($email, $return_id = false, $ignoreGuest = true, Context $context = null)
|
||||
{
|
||||
if (!Validate::isEmail($email))
|
||||
die (Tools::displayError());
|
||||
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `email` = \''.pSQL($email).'\'
|
||||
'.Shop::sqlRestriction(true).
|
||||
'.$context->shop->sqlRestriction(true).
|
||||
($ignoreGuest ? 'AND `is_guest` = 0' : '');
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
@@ -441,8 +450,11 @@ class CustomerCore extends ObjectModel
|
||||
* @param string $query Searched string
|
||||
* @return array Corresponding customers
|
||||
*/
|
||||
public static function searchByName($query)
|
||||
public static function searchByName($query, Context $context = null)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE (
|
||||
@@ -450,7 +462,7 @@ class CustomerCore extends ObjectModel
|
||||
OR `id_customer` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `lastname` LIKE \'%'.pSQL($query).'%\'
|
||||
OR `firstname` LIKE \'%'.pSQL($query).'%\'
|
||||
)'.Shop::sqlRestriction(true);
|
||||
)'.$context->shop->sqlRestriction(true);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
}
|
||||
|
||||
|
||||
+10
-5
@@ -511,12 +511,17 @@ class DiscountCore extends ObjectModel
|
||||
return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'discount` WHERE `id_discount` = '.(int)$id_discount);
|
||||
}
|
||||
|
||||
public function availableWithShop($id_group_shop, $id_shop)
|
||||
public function availableWithShop(Context $context = null)
|
||||
{
|
||||
return Db::getInstance()->getValue('SELECT d.id_discount
|
||||
FROM '._DB_PREFIX_.'discount d
|
||||
LEFT JOIN '._DB_PREFIX_.'group_shop gs ON (gs.id_group_shop=d.id_group_shop)
|
||||
WHERE d.id_discount='.(int)$this->id.' AND (d.id_shop='.(int)$id_shop.' OR (d.id_group_shop='.(int)$id_group_shop.' AND gs.share_datas=1))');
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
// @todo share datas on discount ? Utility of this function ?
|
||||
$sql = 'SELECT id_discount
|
||||
FROM '._DB_PREFIX_.'discount
|
||||
WHERE id_discount='.(int)$this->id
|
||||
.$context->shop->sqlRestriction(true);
|
||||
return Db::getInstance()->getValue($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class HookCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'hook` h
|
||||
INNER JOIN `'._DB_PREFIX_.'hook_module` hm ON (h.id_hook = hm.id_hook)
|
||||
INNER JOIN `'._DB_PREFIX_.'module` as m ON (m.id_module = hm.id_module)
|
||||
WHERE hm.id_shop IN('.implode(', ', Shop::getListFromContext()).')
|
||||
WHERE hm.id_shop IN('.implode(', ', Context::getContext()->shop->getListOfID()).')
|
||||
GROUP BY hm.id_hook, hm.id_module
|
||||
ORDER BY hm.position';
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
|
||||
+11
-11
@@ -110,7 +110,7 @@ abstract class ModuleCore
|
||||
{
|
||||
if (self::$modulesCache == NULL AND !is_array(self::$modulesCache))
|
||||
{
|
||||
$list = Shop::getListOfID($this->context);
|
||||
$list = $this->context->shop->getListOfID();
|
||||
|
||||
// Join clause is done to check if the module is activated in current shop context
|
||||
$sql = 'SELECT m.id_module, m.name, (
|
||||
@@ -140,7 +140,7 @@ abstract class ModuleCore
|
||||
|
||||
protected function sqlShopRestriction($share = false, $alias = null)
|
||||
{
|
||||
return Shop::sqlRestriction($share, $alias, $this->context, 'shop');
|
||||
return $this->context->shop->sqlRestriction($share, $alias, 'shop');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +219,7 @@ abstract class ModuleCore
|
||||
*/
|
||||
public function enable($forceAll = false)
|
||||
{
|
||||
$list = Shop::getListOfID($this->context);
|
||||
$list = $this->context->shop->getListOfID();
|
||||
$sql = 'SELECT id_shop
|
||||
FROM '._DB_PREFIX_.'module_shop
|
||||
WHERE id_module = '.$this->id.'
|
||||
@@ -267,7 +267,7 @@ abstract class ModuleCore
|
||||
{
|
||||
$sql = 'DELETE FROM '._DB_PREFIX_.'module_shop
|
||||
WHERE id_module = '.$this->id.'
|
||||
'.((!$forceAll) ? ' AND id_shop IN('.implode(', ', Shop::getListOfID($this->context)).')' : '');
|
||||
'.((!$forceAll) ? ' AND id_shop IN('.implode(', ', $this->context->shop->getListOfID()).')' : '');
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ abstract class ModuleCore
|
||||
// Get modules information from database
|
||||
if (!empty($moduleNameList))
|
||||
{
|
||||
$list = Shop::getListFromContext();
|
||||
$list = Context::getContext()->shop->getListOfID();
|
||||
|
||||
$sql = 'SELECT m.id_module, m.name, (
|
||||
SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE m.id_module = ms.id_module AND ms.id_shop IN ('.implode(',', $list).')
|
||||
@@ -720,7 +720,7 @@ abstract class ModuleCore
|
||||
if (!isset(self::$_hookModulesCache))
|
||||
{
|
||||
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
|
||||
$list = Shop::getListFromContext();
|
||||
$list = $context->shop->getListOfID();
|
||||
|
||||
$sql = 'SELECT h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`
|
||||
FROM `'._DB_PREFIX_.'module` m
|
||||
@@ -794,7 +794,7 @@ abstract class ModuleCore
|
||||
$hookArgs = array('cookie' => $context->cookie, 'cart' => $context->cart);
|
||||
$billing = new Address((int)($context->cart->id_address_invoice));
|
||||
$output = '';
|
||||
$list = Shop::getListFromContext();
|
||||
$list = Context::getContext()->shop->getListOfID();
|
||||
$sql = 'SELECT DISTINCT h.`id_hook`, m.`name`, hm.`position`
|
||||
FROM `'._DB_PREFIX_.'module_country` mc
|
||||
LEFT JOIN `'._DB_PREFIX_.'module` m ON m.`id_module` = mc.`id_module`
|
||||
@@ -895,7 +895,7 @@ abstract class ModuleCore
|
||||
*/
|
||||
public function updatePosition($id_hook, $way, $position = NULL)
|
||||
{
|
||||
$list = ShopCore::getListOfID($this->context);
|
||||
$list = $this->context->shop->getListOfID();
|
||||
foreach ($list as $shopID)
|
||||
{
|
||||
$sql = 'SELECT hm.`id_module`, hm.`position`, hm.`id_hook`
|
||||
@@ -1003,7 +1003,7 @@ abstract class ModuleCore
|
||||
self::$exceptionsCache = array();
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'hook_module_exceptions`
|
||||
WHERE id_shop IN ('.implode(', ', Shop::getListFromContext()).')';
|
||||
WHERE id_shop IN ('.implode(', ', Context::getContext()->shop->getListOfID()).')';
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
foreach ($result as $row)
|
||||
{
|
||||
@@ -1022,7 +1022,7 @@ abstract class ModuleCore
|
||||
if (!$dispatch)
|
||||
{
|
||||
$files = array();
|
||||
foreach (Shop::getListFromContext() as $shopID)
|
||||
foreach (Context::getContext()->shop->getListOfID() as $shopID)
|
||||
if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shopID]))
|
||||
foreach (self::$exceptionsCache[$key][$shopID] as $file)
|
||||
if (!in_array($file, $files))
|
||||
@@ -1032,7 +1032,7 @@ abstract class ModuleCore
|
||||
else
|
||||
{
|
||||
$list = array();
|
||||
foreach (Shop::getListFromContext() as $shopID)
|
||||
foreach (Context::getContext()->shop->getListOfID() as $shopID)
|
||||
if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shopID]))
|
||||
$list[$shopID] = self::$exceptionsCache[$key][$shopID];
|
||||
return $list;
|
||||
|
||||
@@ -297,7 +297,7 @@ abstract class ObjectModelCore
|
||||
// If this table is linked to multishop system, update / insert for all shops from context
|
||||
if ($this->langMultiShop)
|
||||
{
|
||||
$listShops = ($this->id_shop && !$this->getShopFromContext) ? array($this->id_shop) : Shop::getListFromContext();
|
||||
$listShops = ($this->id_shop && !$this->getShopFromContext) ? array($this->id_shop) : Context::getContext()->shop->getListOfID();
|
||||
foreach ($listShops as $shop)
|
||||
{
|
||||
$field['id_shop'] = $shop;
|
||||
|
||||
+10
-9
@@ -661,7 +661,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).'\'
|
||||
AND id_shop IN('.implode(', ', Shop::getListFromContext()).')'
|
||||
'.Context::getContext()->shop->sqlRestriction()
|
||||
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
|
||||
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '');
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
@@ -701,7 +701,8 @@ class OrderCore extends ObjectModel
|
||||
) AS `state_name`
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
|
||||
WHERE o.id_shop IN('.implode(', ', Shop::getListFromContext()).')
|
||||
WHERE 1
|
||||
'.Context::getContext()->shop->sqlRestriction(false, 'o').'
|
||||
ORDER BY o.`date_add` DESC
|
||||
'.((int)$limit ? 'LIMIT 0, '.(int)$limit : '');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
@@ -712,7 +713,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).'\'
|
||||
AND id_shop IN('.implode(', ', Shop::getListFromContext()).')'
|
||||
'.Context::getContext()->shop->sqlRestriction()
|
||||
.($type ? ' AND '.pSQL(strval($type)).'_number != 0' : '')
|
||||
.($id_customer ? ' AND id_customer = '.(int)($id_customer) : '').
|
||||
' ORDER BY invoice_date ASC';
|
||||
@@ -735,7 +736,7 @@ class OrderCore extends ObjectModel
|
||||
ORDER BY date_add DESC, id_order_history DESC
|
||||
LIMIT 1
|
||||
)
|
||||
AND o.id_shop IN('.implode(', ', Shop::getListFromContext()).')
|
||||
'.Context::getContext()->shop->sqlRestriction(false, 'o').'
|
||||
ORDER BY invoice_date ASC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
|
||||
@@ -799,8 +800,8 @@ class OrderCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(`id_order`) AS nb
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_customer` = '.(int)($id_customer)
|
||||
.' AND id_shop IN('.implode(', ', Shop::getListFromContext()).')';
|
||||
WHERE `id_customer` = '.(int)$id_customer
|
||||
.Context::getContext()->shop->sqlRestriction();
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
|
||||
return isset($result['nb']) ? $result['nb'] : 0;
|
||||
@@ -817,7 +818,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT `id_order`
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `id_cart` = '.(int)($id_cart)
|
||||
.' AND id_shop IN('.implode(', ', Shop::getListFromContext()).')';
|
||||
.Context::getContext()->shop->sqlRestriction();
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
return isset($result['id_order']) ? $result['id_order'] : false;
|
||||
@@ -970,7 +971,7 @@ class OrderCore extends ObjectModel
|
||||
$sql = 'SELECT id_order
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `delivery_number` = '.(int)($id_delivery).'
|
||||
AND id_shop IN('.implode(', ', Shop::getListFromContext()).')';
|
||||
'.Context::getContext()->shop->sqlRestriction();
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
return new Order((int)($res['id_order']));
|
||||
}
|
||||
@@ -1003,7 +1004,7 @@ class OrderCore extends ObjectModel
|
||||
WHERE o.`id_order` = '.(int)$this->id.'
|
||||
AND c.`email` = \''.pSQL($email).'\'
|
||||
AND c.`is_guest` = 1
|
||||
AND c.id_shop IN('.implode(', ', Shop::getListFromContext()).')';
|
||||
'.Context::getContext()->shop->sqlRestriction(false, 'c');
|
||||
return (bool)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1517,7 +1517,7 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
$sql = 'SELECT COUNT(DISTINCT p.`id_product`) AS nb
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::sqlAsso('product', 'p', true, $context).'
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
WHERE p.`active` = 1
|
||||
AND p.`show_price` = 1
|
||||
'.((!$beginning AND !$ending) ? ' AND p.`id_product` IN('.((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
|
||||
@@ -1535,9 +1535,9 @@ class ProductCore extends ObjectModel
|
||||
pl.`name`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
'.Shop::sqlAsso('product', 'p', true, $context).'
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
'.Product::sqlStock('p', 0, false, $context).'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::sqlLang('pl', $context).')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.$context->shop->sqlLang('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_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
@@ -2067,7 +2067,7 @@ class ProductCore extends ObjectModel
|
||||
else if (is_string($productAttribute))
|
||||
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($productAttribute).'.id_product_attribute, 0)';
|
||||
}
|
||||
$sql .= Shop::sqlSharedStock('stock', $context) . ' ';
|
||||
$sql .= $context->shop->sqlSharedStock('stock') . ' ';
|
||||
|
||||
return $sql;
|
||||
}
|
||||
@@ -2168,7 +2168,7 @@ class ProductCore extends ObjectModel
|
||||
FROM '._DB_PREFIX_.'stock
|
||||
WHERE id_product = '.$this->id.'
|
||||
AND id_product_attribute = '.(int)$id_product_attribute
|
||||
.Shop::sqlSharedStock('', $context);
|
||||
.$context->shop->sqlSharedStock('', $context);
|
||||
return (int)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
|
||||
+19
-18
@@ -135,9 +135,9 @@ class ReferrerCore extends ObjectModel
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $employee
|
||||
* @param int $shopID Since 1.5.0
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getStatsVisits($id_product = null, $employee = null, $shopID = null)
|
||||
public function getStatsVisits($id_product, $employee, Shop $shop)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -160,8 +160,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::sqlRestriction(false, 'rs', $shopID).'
|
||||
'.Shop::sqlRestriction(false, 'c', $shopID).'
|
||||
'.$shop->sqlRestriction(false, 'rs').'
|
||||
'.$shop->sqlRestriction(false, 'c').'
|
||||
AND rc.id_referrer = '.(int)$this->id
|
||||
.$where;
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
@@ -172,9 +172,9 @@ class ReferrerCore extends ObjectModel
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $employee
|
||||
* @param int $shopID Since 1.5.0
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getRegistrations($id_product = null, $employee = null, $shopID = null)
|
||||
public function getRegistrations($id_product, $employee, Shop $shop)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -195,9 +195,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::sqlRestriction(false, 'rs', $shopID).'
|
||||
'.Shop::sqlRestriction(false, 'c', $shopID).'
|
||||
'.Shop::sqlRestriction(true, 'cu', $shopID).'
|
||||
'.$shop->sqlRestriction(false, 'rs').'
|
||||
'.$shop->sqlRestriction(false, 'c').'
|
||||
'.$shop->sqlRestriction(true, 'cu').'
|
||||
AND cu.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)($this->id)
|
||||
.$where;
|
||||
@@ -210,9 +210,9 @@ class ReferrerCore extends ObjectModel
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $employee
|
||||
* @param int $shopID Since 1.5.0
|
||||
* @param Context $context
|
||||
*/
|
||||
public function getStatsSales($id_product = null, $employee = null, $shopID = null)
|
||||
public function getStatsSales($id_product, $employee, Shop $shop)
|
||||
{
|
||||
$join = $where = '';
|
||||
if ($id_product)
|
||||
@@ -230,9 +230,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::sqlRestriction(false, 'rs', $shopID).'
|
||||
'.Shop::sqlRestriction(false, 'c', $shopID).'
|
||||
'.Shop::sqlRestriction(true, 'oo', $shopID).'
|
||||
'.$shop->sqlRestriction(false, 'rs').'
|
||||
'.$shop->sqlRestriction(false, 'c').'
|
||||
'.$shop->sqlRestriction(true, 'oo').'
|
||||
AND oo.date_add > cs.date_add
|
||||
AND rc.id_referrer = '.(int)($this->id).'
|
||||
AND oo.valid = 1'
|
||||
@@ -249,7 +249,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::sqlRestriction(true, '', $shopID).'
|
||||
'.$shop->sqlRestriction(true).'
|
||||
AND valid = 1';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
@@ -275,9 +275,10 @@ class ReferrerCore extends ObjectModel
|
||||
if (!$referrer->isAssociatedToShop($shopID))
|
||||
continue;
|
||||
|
||||
$statsVisits = $referrer->getStatsVisits(null, $employee, $shopID);
|
||||
$registrations = $referrer->getRegistrations(null, $employee, $shopID);
|
||||
$statsSales = $referrer->getStatsSales(null, $employee, $shopID);
|
||||
$shop = new Shop($shopID);
|
||||
$statsVisits = $referrer->getStatsVisits(null, $employee, $shop);
|
||||
$registrations = $referrer->getRegistrations(null, $employee, $shop);
|
||||
$statsSales = $referrer->getStatsSales(null, $employee, $shop);
|
||||
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'referrer_shop', array(
|
||||
'cache_visitors' => $statsVisits['uniqs'],
|
||||
|
||||
+25
-24
@@ -444,15 +444,13 @@ class ShopCore extends ObjectModel
|
||||
/**
|
||||
* Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID)
|
||||
*
|
||||
* @param int $shopID
|
||||
* @param int $shopGroupID
|
||||
* @param bool $share If true and if $shopID is set, list shops with share data too
|
||||
* @return array
|
||||
*/
|
||||
public static function getListOfID(Context $context, $share = false)
|
||||
public function getListOfID($share = false)
|
||||
{
|
||||
$shopID = $context->shop->getID();
|
||||
$shopGroupID = $context->shop->getGroupID();
|
||||
$shopID = $this->getID();
|
||||
$shopGroupID = $this->getGroupID();
|
||||
|
||||
if ($shopID)
|
||||
$list = (!$share) ? array($shopID) : Shop::getSharedShops($shopID);
|
||||
@@ -536,7 +534,7 @@ class ShopCore extends ObjectModel
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getListFromContext()
|
||||
public function getListFromContext()
|
||||
{
|
||||
return Shop::getListOfID(Context::getContext());
|
||||
}
|
||||
@@ -556,7 +554,17 @@ class ShopCore extends ObjectModel
|
||||
return Shop::CONTEXT_ALL;
|
||||
}
|
||||
|
||||
public static function sqlRestriction($share = false, $alias = null, Context $context = null, $type = 'shop')
|
||||
/**
|
||||
* Check if we are in "all" context
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function inGlobalContext()
|
||||
{
|
||||
return $this->getContextType() == Shop::CONTEXT_ALL;
|
||||
}
|
||||
|
||||
public function sqlRestriction($share = false, $alias = null, $type = 'shop')
|
||||
{
|
||||
if ($type != 'shop' && $type != 'group_shop')
|
||||
$type = 'shop';
|
||||
@@ -565,10 +573,8 @@ class ShopCore extends ObjectModel
|
||||
$alias .= '.';
|
||||
|
||||
$restriction = '';
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$shopID = $context->shop->getID();
|
||||
$shopGroupID = $context->shop->getGroupID();
|
||||
$shopID = $this->getID();
|
||||
$shopGroupID = $this->getGroupID();
|
||||
|
||||
if ($type == 'group_shop')
|
||||
{
|
||||
@@ -580,21 +586,19 @@ class ShopCore extends ObjectModel
|
||||
else
|
||||
{
|
||||
if ($shopID || $shopGroupID)
|
||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', Shop::getListOfID($context, $share)).')';
|
||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', Shop::getListOfID($shopID, $shopGroupID, $share)).')';
|
||||
}
|
||||
|
||||
return $restriction;
|
||||
}
|
||||
|
||||
public static function sqlSharedStock($alias = null, Context $context = null)
|
||||
public function sqlSharedStock($alias = null)
|
||||
{
|
||||
if ($alias)
|
||||
$alias .= '.';
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$shopID = $context->shop->getID();
|
||||
$shopGroupID = $context->shop->getGroupID();
|
||||
$shopID = $this->getID();
|
||||
$shopGroupID = $this->getGroupID();
|
||||
if (!$shopID)
|
||||
return ($shopGroupID) ? ' AND '.$alias.'id_group_shop = '.(int)$shopGroupID : '';
|
||||
|
||||
@@ -614,11 +618,8 @@ class ShopCore extends ObjectModel
|
||||
* @param Context $context
|
||||
* @return string
|
||||
*/
|
||||
public static function sqlAsso($table, $alias, $innerJoin = false, Context $context = null)
|
||||
public function sqlAsso($table, $alias, $innerJoin = false)
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
|
||||
$tableAlias = ' asso_shop_'.$table;
|
||||
if (strpos($table, '.') !== false)
|
||||
list($tableAlias, $table) = explode('.', $table);
|
||||
@@ -629,7 +630,7 @@ class ShopCore extends ObjectModel
|
||||
|
||||
$sql = (($innerJoin) ? ' INNER' : ' LEFT').' JOIN '._DB_PREFIX_.$table.'_shop '.$tableAlias.'
|
||||
ON '.$tableAlias.'.id_'.$table.' = '.$alias.'.id_'.$table.'
|
||||
AND '.$tableAlias.'.id_shop IN('.implode(', ', Shop::getListFromContext($context)).') ';
|
||||
AND '.$tableAlias.'.id_shop IN('.implode(', ', Shop::getListOfID($this->getID(), $this->getGroupID())).') ';
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@@ -640,9 +641,9 @@ class ShopCore extends ObjectModel
|
||||
* @param Context $context
|
||||
* @return string
|
||||
*/
|
||||
public static function sqlLang($alias, Context $context = null)
|
||||
public function sqlLang($alias)
|
||||
{
|
||||
return ' AND '.$alias.'.id_shop = '.$context->shop->getID(true). ' ';
|
||||
return ' AND '.$alias.'.id_shop = '.$this->getID(true). ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,7 +245,7 @@ class AddressControllerCore extends FrontController
|
||||
else
|
||||
$selectedCountry = (int)Configuration::get('PS_COUNTRY_DEFAULT');
|
||||
|
||||
$countries = Country::getCountries((int)self::$cookie->id_lang, true, NULL, $this->id_current_shop);
|
||||
$countries = Country::getCountries((int)self::$cookie->id_lang, true);
|
||||
$countriesList = '';
|
||||
foreach ($countries AS $country)
|
||||
$countriesList .= '<option value="'.(int)($country['id_country']).'" '.($country['id_country'] == $selectedCountry ? 'selected="selected"' : '').'>'.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'</option>';
|
||||
|
||||
@@ -308,7 +308,7 @@ class AuthControllerCore extends FrontController
|
||||
}*/
|
||||
if (!isset($selectedCountry))
|
||||
$selectedCountry = (int)(Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
$countries = Country::getCountries((int)(self::$cookie->id_lang), true, NULL, $this->id_current_shop);
|
||||
$countries = Country::getCountries((int)(self::$cookie->id_lang), true);
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'countries' => $countries,
|
||||
|
||||
@@ -78,8 +78,8 @@ class CartControllerCore extends FrontController
|
||||
$orderTotal = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
|
||||
$this->cartDiscounts = $context->cart->getDiscounts();
|
||||
foreach ($this->cartDiscounts AS $k => $this->cartDiscount)
|
||||
if ($error = $context->cart->checkDiscountValidity(new Discount((int)($this->cartDiscount['id_discount'])), $this->cartDiscounts, $orderTotal, $context->cart->getProducts(), false, (int)$this->id_current_group_shop, (int)$this->id_current_shop))
|
||||
$context->cart->deleteDiscount($this->cartDiscount['id_discount']);
|
||||
if ($error = self::$cart->checkDiscountValidity(new Discount((int)($this->cartDiscount['id_discount'])), $this->cartDiscounts, $orderTotal, $context->$cart->getProducts(), false))
|
||||
$context->cart->deleteDiscount((int)($this->cartDiscount['id_discount']));
|
||||
|
||||
$add = Tools::getIsset('add') ? 1 : 0;
|
||||
$delete = Tools::getIsset('delete') ? 1 : 0;
|
||||
@@ -220,7 +220,7 @@ class CartControllerCore extends FrontController
|
||||
{
|
||||
$discountObj = new Discount((int)($discount['id_discount']), (int)(self::$cookie->id_lang));
|
||||
|
||||
if ($error = self::$cart->checkDiscountValidity($discountObj, $discounts, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS), self::$cart->getProducts(), false, (int)$this->id_current_group_shop, (int)$this->id_current_shop))
|
||||
if ($error = self::$cart->checkDiscountValidity($discountObj, $discounts, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS), self::$cart->getProducts(), false))
|
||||
{
|
||||
self::$cart->deleteDiscount((int)($discount['id_discount']));
|
||||
self::$cart->update();
|
||||
|
||||
@@ -249,7 +249,7 @@ class ContactControllerCore extends FrontController
|
||||
WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop='.(int)$this->id_current_shop.' AND token = \''.pSQL($token).'\'');
|
||||
$this->smarty->assign('customerThread', $customerThread);
|
||||
}
|
||||
$this->smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang, (int)$this->id_current_shop),
|
||||
$this->smarty->assign(array('contacts' => Contact::getContacts((int)self::$cookie->id_lang),
|
||||
'message' => html_entity_decode(Tools::getValue('message'))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class ParentOrderControllerCore extends FrontController
|
||||
$discount = new Discount((int)(Discount::getIdByName($discountName)));
|
||||
if (Validate::isLoadedObject($discount))
|
||||
{
|
||||
if ($tmpError = $context->cart->checkDiscountValidity($discount, $context->cart->getDiscounts(), $context->cart->getOrderTotal(), $context->cart->getProducts(), true, (int)$this->id_current_group_shop, (int)$this->id_current_shop))
|
||||
if ($tmpError = $context->cart->checkDiscountValidity($discount, $context->cart->getDiscounts(), $context->cart->getOrderTotal(), $context->cart->getProducts(), true))
|
||||
$this->errors[] = $tmpError;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -45,7 +45,7 @@ class SitemapControllerCore extends FrontController
|
||||
{
|
||||
parent::process();
|
||||
$this->smarty->assign('categoriesTree', Category::getRootCategory()->recurseLiteCategTree(0));
|
||||
$this->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(Context::getContext()->language->id, 1, 1, 1, $this->id_current_shop));
|
||||
$this->smarty->assign('categoriescmsTree', CMSCategory::getRecurseCategory(Context::getContext()->language->id, 1, 1, 1));
|
||||
$this->smarty->assign('voucherAllowed', (int)Configuration::get('PS_VOUCHERS'));
|
||||
$blockmanufacturer = Module::getInstanceByName('blockmanufacturer');
|
||||
$blocksupplier = Module::getInstanceByName('blocksupplier');
|
||||
|
||||
@@ -60,7 +60,7 @@ class BlockCurrencies extends Module
|
||||
if (Configuration::get('PS_CATALOG_MODE'))
|
||||
return ;
|
||||
|
||||
$currencies = Currency::getCurrencies(false, 1, $this->context->shop->getID());
|
||||
$currencies = Currency::getCurrencies(false, 1, $this->context);
|
||||
if (!sizeof($currencies))
|
||||
return '';
|
||||
$this->context->smarty->assign('currencies', $currencies);
|
||||
|
||||
@@ -387,8 +387,8 @@ class BlockLayered extends Module
|
||||
p.ean13, pl.available_later, pl.description_short, pl.link_rewrite, pl.name, i.id_image, il.legend, m.name manufacturer_name, p.condition, p.id_manufacturer, stock.quantity,
|
||||
DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.Shop::sqlAsso('product', 'p', true, $context).'
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.Shop::sqlLang('pl', $context).')
|
||||
'.$context->shop->sqlAsso('product', 'p', true).'
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product'.$context->shop->sqlLang('pl').')
|
||||
'.Product::sqlStock('p', 0).'
|
||||
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)$context->language->id.')
|
||||
|
||||
@@ -311,7 +311,7 @@ class MailAlerts extends Module
|
||||
$sql = 'SELECT id_product, quantity
|
||||
FROM '._DB_PREFIX_.'stock
|
||||
WHERE id_product_attribute = '.(int)$params['id_product_attribute']
|
||||
.Shop::sqlSharedStock();
|
||||
.Context::getContext()->sqlSharedStock();
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
|
||||
if ($this->_customer_qty AND $result['quantity'] > 0)
|
||||
@@ -480,7 +480,7 @@ class MailAlerts extends Module
|
||||
$sql = 'SELECT ma.`id_product`, stock.quantity AS product_quantity, pl.`name`, ma.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'mailalert_customer_oos` ma
|
||||
JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = ma.`id_product`
|
||||
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = ma.`id_product` AND pl.`id_lang` = '.$id_lang.Shop::sqlLang('pl').'
|
||||
JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = ma.`id_product` AND pl.`id_lang` = '.$id_lang.Context::getContext()->shop->sqlLang('pl').'
|
||||
'.Product::sqlStock('p', 0).'
|
||||
WHERE ma.`id_customer` = '.$id_customer;
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
|
||||
|
||||
@@ -362,7 +362,7 @@ class ReferralProgram extends Module
|
||||
if (!Validate::isLoadedObject($discount))
|
||||
return false;
|
||||
|
||||
if ($params['cart']->checkDiscountValidity($discount, $params['cart']->getDiscounts(), $params['cart']->getOrderTotal(true, Cart::ONLY_PRODUCTS), $params['cart']->getProducts(), false, $this->context->shop->getID(), $this->context->shop->getGroupID())===false)
|
||||
if ($params['cart']->checkDiscountValidity($discount, $params['cart']->getDiscounts(), $params['cart']->getOrderTotal(true, Cart::ONLY_PRODUCTS), $params['cart']->getProducts(), false, $this->context) === false)
|
||||
{
|
||||
global $smarty;
|
||||
$smarty->assign(array('discount_display' => Discount::display($discount->value, $discount->id_discount_type, new Currency($params['cookie']->id_currency)), 'discount' => $discount));
|
||||
@@ -438,7 +438,7 @@ class ReferralProgram extends Module
|
||||
return false;
|
||||
|
||||
$sponsor = new Customer();
|
||||
if ($sponsor = $sponsor->getByEmail($sponsorEmail, NULL, $this->context->shop->getGroupID(), $this->context->shop->getID()))
|
||||
if ($sponsor = $sponsor->getByEmail($sponsorEmail, NULL, $this->context))
|
||||
{
|
||||
include_once(dirname(__FILE__).'/ReferralProgramModule.php');
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class StatsBestCategories extends ModuleGrid
|
||||
WHERE c.id_category IN (
|
||||
SELECT s.id_category
|
||||
FROM '._DB_PREFIX_.'shop s
|
||||
WHERE s.id_shop IN ('.implode(', ', Shop::getListOfID($this->context)).')
|
||||
WHERE s.id_shop IN ('.implode(', ', $this->context->shop->getListOfID()).')
|
||||
)';
|
||||
if ($result = Db::getInstance()->executeS($sql))
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ class StatsBestProducts extends ModuleGrid
|
||||
AND dr.time_end BETWEEN '.$dateBetween.'
|
||||
) AS totalPageViewed
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.Shop::sqlAsso('product', 'p', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('product', 'p', true).'
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)($this->getLang()).')
|
||||
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
|
||||
|
||||
@@ -147,7 +147,7 @@ class StatsCatalog extends Module
|
||||
$this->_join = ' LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)';
|
||||
$this->_where = ' AND cp.`id_category` = '.$id_category;
|
||||
}
|
||||
$this->_join .= Shop::sqlAsso('product', 'p', true, $this->context);
|
||||
$this->_join .= $this->context->shop->sqlAsso('product', 'p', true);
|
||||
|
||||
$result1 = $this->getQuery1(true);
|
||||
$total = $result1['total'];
|
||||
|
||||
@@ -82,7 +82,7 @@ class StatsCheckUp extends Module
|
||||
// Get languages
|
||||
$sql = 'SELECT l.*
|
||||
FROM '._DB_PREFIX_.'lang l'
|
||||
.Shop::sqlAsso('lang', 'l', true, $this->context);
|
||||
.$this->context->shop->sqlAsso('lang', 'l', true);
|
||||
$languages = $db->ExecuteS($sql);
|
||||
|
||||
$arrayColors = array(
|
||||
@@ -109,7 +109,7 @@ class StatsCheckUp extends Module
|
||||
$sql = 'SELECT p.id_product, p.active, pl.name, (
|
||||
SELECT COUNT(*)
|
||||
FROM '._DB_PREFIX_.'image i
|
||||
'.Shop::sqlAsso('image', 'i', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('image', 'i', true).'
|
||||
WHERE i.id_product = p.id_product
|
||||
) as nbImages, (
|
||||
SELECT SUM(od.product_quantity)
|
||||
@@ -125,7 +125,7 @@ class StatsCheckUp extends Module
|
||||
), p.quantity) as stock
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$cookie->id_lang.')
|
||||
'.Shop::sqlAsso('product', 'p', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('product', 'p', true).'
|
||||
ORDER BY '.$orderBy;
|
||||
$result = $db->ExecuteS($sql);
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ class StatsForecast extends Module
|
||||
$langValues = '';
|
||||
$sql = 'SELECT l.id_lang, l.iso_code
|
||||
FROM `'._DB_PREFIX_.'lang` l
|
||||
'.Shop::sqlAsso('lang', 'l', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('lang', 'l', true).'
|
||||
WHERE l.active = 1';
|
||||
$languages = Db::getInstance()->ExecuteS($sql);
|
||||
foreach ($languages as $language)
|
||||
|
||||
@@ -103,7 +103,7 @@ class StatsProduct extends ModuleGraph
|
||||
(SELECT SUM(pa.quantity) FROM '._DB_PREFIX_.'product_attribute pa WHERE pa.id_product = p.id_product), p.quantity) as quantity
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product`
|
||||
'.Shop::sqlAsso('product', 'p', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('product', 'p', true).'
|
||||
'.(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).'
|
||||
'.(Tools::getValue('id_category') ? 'AND cp.id_category = '.(int)(Tools::getValue('id_category')) : '').'
|
||||
|
||||
@@ -75,7 +75,7 @@ class StatsStock extends Module
|
||||
FROM '._DB_PREFIX_.'product_attribute pa WHERE p.id_product = pa.id_product
|
||||
), p.wholesale_price * p.quantity) as stockvalue
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
'.Shop::sqlAsso('product', 'p', true, $this->context).'
|
||||
'.$this->context->shop->sqlAsso('product', 'p', true).'
|
||||
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = '.(int)$cookie->id_lang.')
|
||||
WHERE 1 = 1
|
||||
'.$filter;
|
||||
|
||||
Reference in New Issue
Block a user