';
- $groups = Group::getGroups((int)($cookie->id_lang));
+ $groups = Group::getGroups((int)($context->language->id));
if (sizeof($groups))
{
echo '
diff --git a/admin-dev/tabs/AdminMeta.php b/admin-dev/tabs/AdminMeta.php
index a63d9ef21..674751d50 100644
--- a/admin-dev/tabs/AdminMeta.php
+++ b/admin-dev/tabs/AdminMeta.php
@@ -188,7 +188,7 @@ class AdminMeta extends AdminTab
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
{
- parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Shop::getCurrentShop(true));
+ parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->getID());
}
}
diff --git a/admin-dev/tabs/AdminModulesPositions.php b/admin-dev/tabs/AdminModulesPositions.php
index 5f0a3ffa4..e3fd658c7 100644
--- a/admin-dev/tabs/AdminModulesPositions.php
+++ b/admin-dev/tabs/AdminModulesPositions.php
@@ -262,7 +262,7 @@ class AdminModulesPositions extends AdminTab
else
echo '
'.$this->l('By clicking here you will be redirected to the front office of your shop to move and delete modules directly.').'
-
'.$this->l('Run LiveEdit').'';
+
'.$this->l('Run LiveEdit').'';
echo '';
// Print hook list
diff --git a/admin-dev/tabs/AdminPayment.php b/admin-dev/tabs/AdminPayment.php
index 7446b945e..3796c804e 100644
--- a/admin-dev/tabs/AdminPayment.php
+++ b/admin-dev/tabs/AdminPayment.php
@@ -31,9 +31,9 @@ class AdminPayment extends AdminTab
public function __construct()
{
- global $cookie;
- /* Get all modules then select only payment ones*/
+ $shopID = Context::getContext()->shop->getID();
+ /* Get all modules then select only payment ones*/
$modules = Module::getModulesOnDisk();
foreach ($modules AS $module)
@@ -43,19 +43,19 @@ class AdminPayment extends AdminTab
{
if(!get_class($module) == 'SimpleXMLElement')
$module->country = array();
- $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM '._DB_PREFIX_.'module_country WHERE id_module = '.(int)$module->id.' AND `id_shop`='.Shop::getCurrentShop(true));
+ $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM '._DB_PREFIX_.'module_country WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
foreach ($countries as $country)
$module->country[] = $country['id_country'];
if(!get_class($module) == 'SimpleXMLElement')
$module->currency = array();
- $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM '._DB_PREFIX_.'module_currency WHERE id_module = '.(int)$module->id.' AND `id_shop`='.Shop::getCurrentShop(true));
+ $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM '._DB_PREFIX_.'module_currency WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
foreach ($currencies as $currency)
$module->currency[] = $currency['id_currency'];
if(!get_class($module) == 'SimpleXMLElement')
$module->group = array();
- $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM '._DB_PREFIX_.'module_group WHERE id_module = '.(int)$module->id.' AND `id_shop`='.Shop::getCurrentShop(true));
+ $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM '._DB_PREFIX_.'module_group WHERE id_module = '.(int)$module->id.' AND `id_shop`='.$shopID);
foreach ($groups as $group)
$module->group[] = $group['id_group'];
}
@@ -84,12 +84,13 @@ class AdminPayment extends AdminTab
private function saveRestrictions($type)
{
- global $currentIndex, $cookie;
- Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'module_'.$type.' WHERE id_shop='.Shop::getCurrentShop(true));
+ global $currentIndex;
+
+ Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'module_'.$type.' WHERE id_shop='.Context::getContext()->shop->getID());
foreach ($this->paymentModules as $module)
if ($module->active AND isset($_POST[$module->name.'_'.$type.'']))
foreach ($_POST[$module->name.'_'.$type.''] as $selected)
- $values[] = '('.(int)$module->id.', '.Shop::getCurrentShop(true).', '.(int)$selected.')';
+ $values[] = '('.(int)$module->id.', '.Context::getContext()->shop->getID().', '.(int)$selected.')';
if (sizeof($values))
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values));
Tools::redirectAdmin($currentIndex.'&conf=4'.'&token='.$this->token);
diff --git a/admin-dev/tabs/AdminPreferences.php b/admin-dev/tabs/AdminPreferences.php
index 4dd6232d4..4957c69eb 100644
--- a/admin-dev/tabs/AdminPreferences.php
+++ b/admin-dev/tabs/AdminPreferences.php
@@ -222,7 +222,7 @@ class AdminPreferences extends AdminTab
{
if (Tools::isSubmit('submitAppearanceconfiguration'))
{
- $id_shop = Shop::getCurrentShop(true);
+ $id_shop = Context::getContext()->shop->getID();
if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name'])
{
if ($error = checkImage($_FILES['PS_LOGO'], 300000))
@@ -242,7 +242,7 @@ class AdminPreferences extends AdminTab
$this->_errors[] = $error;
if (!$tmpName == tempnam(_PS_TMP_IMG_DIR_, 'PS_MAIL') OR !move_uploaded_file($_FILES['PS_LOGO_MAIL']['tmp_name'], $tmpName))
return false;
- if ($id_shop = Configuration::get('PS_SHOP_DEFAULT') && !@imageResize($tmpName, _PS_IMG_DIR_.'logo_mail.jpg'))
+ if ($id_shop == Configuration::get('PS_SHOP_DEFAULT') && !@imageResize($tmpName, _PS_IMG_DIR_.'logo_mail.jpg'))
$this->_errors[] = 'an error occurred during logo copy';
if (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_mail-'.(int)$id_shop.'.jpg'))
$this->_errors[] = 'an error occurred during logo copy';
diff --git a/admin-dev/tabs/AdminThemes.php b/admin-dev/tabs/AdminThemes.php
index 0461b4bf7..a7a1587f8 100644
--- a/admin-dev/tabs/AdminThemes.php
+++ b/admin-dev/tabs/AdminThemes.php
@@ -95,7 +95,7 @@ class AdminThemes extends AdminPreferences
{
$this->className = 'Configuration';
$this->table = 'configuration';
- $id_shop = (int)Shop::getCurrentShop(true);
+ $id_shop = Context::getContext()->shop->getID();
$this->_fieldsAppearance = array(
'PS_LOGO' => array('title' => $this->l('Header logo:'), 'desc' => $this->l('Will appear on main page'), 'type' => 'file', 'thumb' => array('file' => _PS_IMG_.'logo-'.(int)$id_shop.'.jpg?date='.time(), 'pos' => 'before')),
'PS_LOGO_MAIL' => array('title' => $this->l('Mail logo:'), 'desc' => $this->l('Will appear on e-mail headers, if undefined the Header logo will be used'), 'type' => 'file', 'thumb' => array('file' => ((file_exists(_PS_IMG_DIR_.'logo_mail-'.(int)$id_shop.'.jpg')) ? _PS_IMG_.'logo_mail-'.(int)$id_shop.'.jpg?date='.time() : _PS_IMG_.'logo-'.(int)$id_shop.'.jpg?date='.time()), 'pos' => 'before')),
diff --git a/classes/AdminTab.php b/classes/AdminTab.php
index a9862cb46..64184fe00 100644
--- a/classes/AdminTab.php
+++ b/classes/AdminTab.php
@@ -1127,22 +1127,22 @@ abstract class AdminTabCore
*/
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
{
- global $cookie;
+ $context = Context::getContext();
/* Manage default params values */
if (empty($limit))
- $limit = ((!isset($cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $cookie->{$this->table.'_pagination'});
+ $limit = ((!isset($context->cookie->{$this->table.'_pagination'})) ? $this->_pagination[1] : $limit = $context->cookie->{$this->table.'_pagination'});
if (!Validate::isTableOrIdentifier($this->table))
die (Tools::displayError('Table name is invalid:').' "'.$this->table.'"');
if (empty($orderBy))
- $orderBy = $cookie->__get($this->table.'Orderby') ? $cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy;
+ $orderBy = $context->cookie->__get($this->table.'Orderby') ? $context->cookie->__get($this->table.'Orderby') : $this->_defaultOrderBy;
if (empty($orderWay))
- $orderWay = $cookie->__get($this->table.'Orderway') ? $cookie->__get($this->table.'Orderway') : 'ASC';
+ $orderWay = $context->cookie->__get($this->table.'Orderway') ? $context->cookie->__get($this->table.'Orderway') : 'ASC';
$limit = (int)(Tools::getValue('pagination', $limit));
- $cookie->{$this->table.'_pagination'} = $limit;
+ $context->cookie->{$this->table.'_pagination'} = $limit;
/* Check params validity */
if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)
@@ -1176,21 +1176,21 @@ abstract class AdminTabCore
$whereShop = Shop::sqlRestriction($this->shopShareDatas, 'a', null, null, $this->shopLinkType);
}
$filterShop = '';
- if (($context_type = Shop::getContextType()) != Shop::CONTEXT_ALL)
+ if ($context->shop->getContextType() != Shop::CONTEXT_ALL)
{
- if ($context_type == Shop::CONTEXT_SHOP)
+ if ($context->shop->getContextType() == Shop::CONTEXT_SHOP)
{
$assos = Shop::getAssoTables();
if (isset($assos[$this->table]) AND $assos[$this->table]['type'] == 'shop')
$filterKey = $assos[$this->table]['type'];
- $idenfierShop = Shop::getCurrentShop();
+ $idenfierShop = $context->shop->getID();
}
- elseif ($context_type == Shop::CONTEXT_GROUP)
+ elseif ($context->shop->getContextType() == Shop::CONTEXT_GROUP)
{
$assos = GroupShop::getAssoTables();
if (isset($assos[$this->table]) AND $assos[$this->table]['type'] == 'group_shop')
$filterKey = $assos[$this->table]['type'];
- $idenfierShop = Shop::getCurrentGroupShop();
+ $idenfierShop = $context->shop->getGroup();
}
if (isset($filterKey))
$filterShop = 'JOIN `'._DB_PREFIX_.$this->table.'_'.$filterKey.'` sa ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filterKey.'='.(int)$idenfierShop.')';
@@ -1833,12 +1833,14 @@ abstract class AdminTabCore
* @param integer $id_lang Language id (optional)
* @return string
*/
- protected function getFieldValue($obj, $key, $id_lang = NULL, $id_shop = NULL)
+ protected function getFieldValue($obj, $key, $id_lang = NULL, $context = NULL)
{
- global $cookie;
+ $id_shop = ($context) ? $context->shop->getID() : null;
+ if (!$context)
+ $context = Context::getContext();
if (!$id_shop AND $obj->isLangMultishop())
- $id_shop = Shop::getCurrentShop(true);
+ $id_shop = $context->shop->getID();
if ($id_lang)
$defaultValue = ($obj->id AND isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
@@ -2066,10 +2068,8 @@ abstract class AdminTabCore
{
if (!Tools::isMultiShopActivated())
return;
- if (!$id_shop = Shop::getCurrentShop())
- $id_shop = Configuration::get('PS_SHOP_DEFAULT');
- $shop = new Shop((int)$id_shop);
- return $this->l('This field will be changed for the shop:').' '.$shop->name;
+
+ return $this->l('This field will be changed for the shop:').' '.Context::getContext()->shop->name;
}
protected function displayAssoGroupShop($field_name = 'name')
diff --git a/classes/Customer.php b/classes/Customer.php
index 642d842d9..d8243ac07 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -276,7 +276,7 @@ class CustomerCore extends ObjectModel
$sql = 'SELECT `id_customer`
FROM `'._DB_PREFIX_.'customer`
WHERE `email` = \''.pSQL($email).'\'
- '.Shop::sqlRestriction(true, null, $id_shop, $id_group_shop).
+ '.Shop::sqlRestriction(true).
($ignoreGuest ? 'AND `is_guest` = 0' : '');
$result = Db::getInstance()->getRow($sql);
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index 77b703ac8..200903f58 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -118,7 +118,7 @@ abstract class ObjectModelCore
die(Tools::displayError());
if ($this->langMultiShop AND $id_shop == NULL)
- $id_shop = (int)Shop::getCurrentShop(true);
+ $id_shop = Context::getContext()->shop->getID();
if ($id_shop AND $this->langMultiShop)
$this->id_shop = $id_shop;
/* Connect to database and check SQL table/identifier */
@@ -683,7 +683,7 @@ abstract class ObjectModelCore
{
$multi_shop_join = ' LEFT JOIN `'._DB_PREFIX_.$this->table.'_'.$assoc[$this->table]['type'].'` AS multi_shop_'.$this->table.' ON (main.'.$this->identifier.' = '.'multi_shop_'.$this->table.'.'.$this->identifier.')';
$class_name = WebserviceRequest::$ws_current_classname;
- $vars = get_class_vars($classname);
+ $vars = get_class_vars($class_name);
foreach ($vars['shopIDs'] as $id_shop)
$OR[] = ' multi_shop_'.$this->table.'.id_shop = '.$id_shop.' ';
$multi_shop_filter = ' AND ('.implode('OR', $OR).') ';
diff --git a/classes/Page.php b/classes/Page.php
index 1ea98ee03..ffc2b66f2 100644
--- a/classes/Page.php
+++ b/classes/Page.php
@@ -108,13 +108,14 @@ class PageCore extends ObjectModel
public static function setPageViewed($id_page)
{
$id_date_range = DateRange::getCurrentRange();
+ $context = Context::getContext();
// Try to increment the visits counter
$sql = 'UPDATE `'._DB_PREFIX_.'page_viewed`
SET `counter` = `counter` + 1
WHERE `id_date_range` = '.(int)$id_date_range.'
AND `id_page` = '.(int)$id_page.'
- AND `id_shop` = ' . Shop::getCurrentShop();
+ AND `id_shop` = ' . $context->shop->getID();
Db::getInstance()->Execute($sql);
// If no one has seen the page in this date range, it is added
@@ -123,8 +124,8 @@ class PageCore extends ObjectModel
'id_date_range' => (int)$id_date_range,
'id_page' => (int)$id_page,
'counter' => 1,
- 'id_shop' => Shop::getCurrentShop(),
- 'id_group_shop' => Shop::getCurrentGroupShop(),
+ 'id_shop' => $context->shop->getID(),
+ 'id_group_shop' => $context->shop->getGroup(),
), 'INSERT');
}
}
\ No newline at end of file
diff --git a/classes/Product.php b/classes/Product.php
index 6b77206ba..cafc368a2 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -2089,7 +2089,7 @@ class ProductCore extends ObjectModel
// For retrocompatibility
$id_product_attribute = (int)$id_product_attribute;
$quantity = (int)$quantity;
- if (Shop::isDefaultShop($shop))
+ if (Shop::getInstance($shop)->isDefaultShop())
{
if ($id_product_attribute)
{
diff --git a/classes/Referrer.php b/classes/Referrer.php
index 731954b6d..bce4bf6eb 100644
--- a/classes/Referrer.php
+++ b/classes/Referrer.php
@@ -71,7 +71,6 @@ class ReferrerCore extends ObjectModel
{
parent::validateFields();
- $fields['id_shop'] = (!$this->id_shop) ? Shop::getCurrentShop(true) : (int)$this->id_shop;
$fields['name'] = pSQL($this->name);
$fields['passwd'] = pSQL($this->passwd);
$fields['http_referer_regexp'] = pSQL($this->http_referer_regexp, true);
diff --git a/classes/Search.php b/classes/Search.php
index 49eec5129..e8ed0fa9b 100644
--- a/classes/Search.php
+++ b/classes/Search.php
@@ -405,8 +405,8 @@ class SearchCore
// Every indexed words are cached into a PHP array
$wordIdsByWord = array();
$wordIds = Db::getInstance()->ExecuteS('
- SELECT sw.id_word, sw.word, id_lang, id_shop
- FROM '._DB_PREFIX_.'search_word sw', false);
+ SELECT id_word, word, id_lang, id_shop
+ FROM '._DB_PREFIX_.'search_word', false);
$wordIdsByWord = array();
while ($wordId = $db->nextRow($wordIds))
{
@@ -533,10 +533,15 @@ class SearchCore
$queryArray3 = array();
}
- public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, $context = null)
+ public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, $shops = null, $context = null)
{
if (!$context)
$context = Context::getContext();
+ if (is_null($shops))
+ $shops = array($context->shop->getID());
+ if (!is_array($shops))
+ $shops = array($shops);
+
// Only use cookie if id_customer is not present
if ($useCookie)
$id_customer = (int)$context->customer->id;
@@ -552,45 +557,46 @@ class SearchCore
if ($count)
{
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT COUNT(DISTINCT pt.`id_product`) nb
- FROM `'._DB_PREFIX_.'product` p
- LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
- LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
- LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
- LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
- WHERE p.`active` = 1
- AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
- SELECT id_group FROM '._DB_PREFIX_.'customer_group
- WHERE id_customer = '.(int)$id_customer.')').'
- AND t.`name` LIKE \'%'.pSQL($tag).'%\'');
- return isset($result['nb']) ? $result['nb'] : 0;
+ $sql = 'SELECT COUNT(DISTINCT pt.`id_product`) nb
+ FROM `'._DB_PREFIX_.'product` p
+ INNER JOIN '._DB_PREFIX_.'product_shop ps ON p.id_product = ps.id_product AND ps.id_shop IN ('.implode(', ', $shops).')
+ LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
+ LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
+ LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
+ LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
+ WHERE p.`active` = 1
+ AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
+ SELECT id_group FROM '._DB_PREFIX_.'customer_group
+ WHERE id_customer = '.(int)$id_customer.')').'
+ AND t.`name` LIKE \'%'.pSQL($tag).'%\'';
+ return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
-
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
- SELECT DISTINCT p.*, pl.`description_short`, pl.`link_rewrite`, pl.`name`, tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
- 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 new
- 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.')
- 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`
- AND tr.`id_country` = '.(int)$context->country->id.'
- AND tr.`id_state` = 0)
- LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
- LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
- LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
- LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
- LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
- LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
- WHERE p.`active` = 1
- AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
- SELECT id_group FROM '._DB_PREFIX_.'customer_group
- WHERE id_customer = '.(int)$id_customer.')').'
- AND t.`name` LIKE \'%'.pSQL($tag).'%\'
- ORDER BY position DESC'.($orderBy ? ', '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
- LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize);
- if (!$result) return false;
+
+ $sql = 'SELECT DISTINCT p.*, pl.`description_short`, pl.`link_rewrite`, pl.`name`, tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
+ 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 new
+ 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.' AND pl.id_shop IN ('.implode(', ', $shops).'))
+ INNER JOIN '._DB_PREFIX_.'product_shop ps ON p.id_product = ps.id_product AND ps.id_shop IN ('.implode(', ', $shops).')
+ 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`
+ AND tr.`id_country` = '.(int)$context->country->id.'
+ AND tr.`id_state` = 0)
+ LEFT JOIN `'._DB_PREFIX_.'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
+ LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
+ LEFT JOIN `'._DB_PREFIX_.'product_tag` pt ON (p.`id_product` = pt.`id_product`)
+ LEFT JOIN `'._DB_PREFIX_.'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
+ LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
+ LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
+ WHERE p.`active` = 1
+ AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
+ SELECT id_group FROM '._DB_PREFIX_.'customer_group
+ WHERE id_customer = '.(int)$id_customer.')').'
+ AND t.`name` LIKE \'%'.pSQL($tag).'%\'
+ ORDER BY position DESC'.($orderBy ? ', '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
+ LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize;
+ if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql))
+ return false;
return Product::getProductsProperties((int)$id_lang, $result);
}
diff --git a/classes/Shop.php b/classes/Shop.php
index 9549a12f4..a2c949843 100644
--- a/classes/Shop.php
+++ b/classes/Shop.php
@@ -36,16 +36,26 @@ class ShopCore extends ObjectModel
public $active;
public $id_category;
public $deleted;
-
- private static $current_base_uri;
- private static $current_theme_name;
+
+ protected $base_uri;
+ protected $theme_name;
+
+ /**
+ * @var GroupShop
+ */
+ protected $group;
+
+ //private static $current_base_uri;
+ //private static $current_theme_name;
private static $id_current_shop;
private static $id_current_group_shop;
private static $id_current_root_category;
-
+
protected $fieldsSize = array('name' => 64);
- protected $fieldsValidate = array('active' => 'isBool',
- 'name' => 'isGenericName');
+ protected $fieldsValidate = array(
+ 'active' => 'isBool',
+ 'name' => 'isGenericName',
+ );
protected $table = 'shop';
protected $identifier = 'id_shop';
@@ -75,7 +85,7 @@ class ShopCore extends ObjectModel
'store' => array('type' => 'shop'),
'webservice_account' => array('type' => 'shop'),
);
-
+
protected $webserviceParameters = array(
'fields' => array(
'id_group_shop' => array('xlink_resource' => 'shop_groups'),
@@ -83,14 +93,14 @@ class ShopCore extends ObjectModel
'id_theme' => array(),
),
);
-
+
/**
* There are 3 kinds of shop context : shop, group shop and general
*/
const CONTEXT_SHOP = 1;
const CONTEXT_GROUP = 2;
const CONTEXT_ALL = 3;
-
+
public function getFields()
{
parent::validateFields();
@@ -103,30 +113,14 @@ class ShopCore extends ObjectModel
$fields['deleted'] = (int)$this->deleted;
return $fields;
}
-
- /**
- * Get an instance of a shop
- *
- * @param int $id shop ID
- * @return Shop
- */
- public static function getInstance($id)
- {
- return new Shop($id);
- }
-
- public static function getAssoTables()
- {
- return self::$assoTables;
- }
-
+
public function add($autodate = true, $nullValues = false)
{
$res = parent::add();
- Shop::loadShops(true);
+ Shop::cacheShops(true);
return $res;
}
-
+
public function delete()
{
if (!$res = parent::delete())
@@ -150,20 +144,173 @@ class ShopCore extends ObjectModel
$res &= Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.$table_name.'` WHERE `'.$id.'`='.(int)$this->id);
}
- Shop::loadShops(true);
+ Shop::cacheShops(true);
return $res;
}
+
+ /**
+ * Get a new instance of a shop
+ *
+ * @param int $id shop ID
+ * @return Shop
+ */
+ public static function getInstance($id)
+ {
+ return new Shop($id);
+ }
+
+ /**
+ * Find the shop from current domain / uri and get an instance of this shop
+ *
+ * @return Shop
+ */
+ public static function initialize()
+ {
+ // Get list of excluded uri
+ $dirname = dirname(__FILE__);
+ $directories = scandir($dirname.'/../');
+ $excluded_uris = array();
+ foreach ($directories AS $directory)
+ if (is_dir($dirname.'/../'.$directory) AND (!preg_match ('/^\./', $directory)))
+ $excluded_uris[] = $directory;
+
+ // Parse request_uri
+ preg_match('/^'.Tools::pRegexp(_PS_DIRECTORY_, '/').'([a-z0-9]+)\/.*$/Ui', $_SERVER['REQUEST_URI'], $res);
+ $uri = (isset($res[1]) AND !in_array($res[1], $excluded_uris)) ? $res[1] : '';
+
+ if (!$id_shop = Tools::getValue('id_shop'))
+ {
+ // Find current shop from URL
+ $db = Db::getInstance();
+ $sql = 'SELECT s.id_shop
+ FROM '._DB_PREFIX_.'shop_url su
+ LEFT JOIN '._DB_PREFIX_.'shop s ON (s.id_shop = su.id_shop)
+ WHERE su.domain=\''.pSQL(Tools::getHttpHost()).'\'
+ AND uri=\''.pSQL($uri).'\'
+ AND s.active = 1
+ AND s.deleted = 0';
+ if (!$id_shop = $db->getValue($sql))
+ $id_shop = Configuration::get('PS_SHOP_DEFAULT');
+ }
+
+ // Get instance of found shop
+ $shop = new Shop($id_shop);
+ if (!Validate::isLoadedObject($shop))
+ die(Tools::displayError());
+ return $shop;
+ }
/**
- * Check if shop is the same as default shop in configuration
+ * Load some additional data of current shop (theme name, shop uri)
*
- * @param int $shopID
* @return bool
*/
- public static function isDefaultShop($shopID)
+ protected function loadShopInfos()
{
- return ($shopID == Configuration::get('PS_SHOP_DEFAULT'));
+ $sql = 'SELECT su.uri, t.name
+ FROM '._DB_PREFIX_.'shop s
+ LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
+ LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
+ WHERE s.id_shop = '.$this->id.'
+ AND s.active = 1
+ AND s.deleted = 0
+ AND su.main = 1';
+ if (!$row = Db::getInstance()->getRow($sql))
+ return false;
+
+ $this->theme_name = $row['name'];
+ $this->base_uri = $row['uri'];
+ return true;
+ }
+
+ /**
+ * Get shop theme name
+ *
+ * @return string
+ */
+ public function getTheme()
+ {
+ if (!$this->theme_name)
+ $this->loadShopInfos();
+ return $this->theme_name;
+ }
+
+ /**
+ *
+ * Get shop URI
+ *
+ * @param bool $with_base
+ * @return string
+ */
+ public function getBaseURI($with_base = true)
+ {
+ if (!$this->theme_name)
+ $this->loadShopInfos();
+ return ($with_base ? _PS_DIRECTORY_ : '').$this->base_uri;
+ }
+
+ /**
+ * Get group of current shop
+ *
+ * @param bool $asObject If false, return only the ID of the group
+ * @return GroupShop
+ */
+ public function getGroup($asObject = false)
+ {
+ if (!$asObject)
+ return $this->id_group_shop;
+
+ if (!$this->group)
+ $this->group = new GroupShop($this->id_group_shop);
+ return $this->group;
+ }
+
+ /**
+ * Get current shop ID.
+ *
+ * @param bool $forceContext If true and if no shop is selected in context, get default shop ID
+ * @return int
+ */
+ public static function getID($forceContext = false)
+ {
+ if (!$this->id && $forceContext)
+ return (int)Configuration::get('PS_SHOP_DEFAULT');
+ return (int)$this->id;
+ }
+
+ /**
+ * Get root category of current shop
+ *
+ * @return int
+ */
+ public function getRootCategory()
+ {
+ return $this->id_category;
+ }
+
+ /**
+ * Get list of shop's urls
+ *
+ * @return array
+ */
+ public function getUrls()
+ {
+ $sql = 'SELECT *
+ FROM '._DB_PREFIX.'shop_url
+ WHERE active = 1
+ AND id_shop='.(int)$this->id;
+ return Db::getInstance()->ExecuteS($sql);
+ }
+
+ /**
+ * Check if current shop ID is the same as default shop in configuration
+ *
+ * @return bool
+ */
+ public function isDefaultShop()
+ {
+ return ($this->id == Configuration::get('PS_SHOP_DEFAULT'));
}
/**
@@ -171,7 +318,7 @@ class ShopCore extends ObjectModel
*
* @param bool $refresh
*/
- public static function loadShops($refresh = false)
+ public static function cacheShops($refresh = false)
{
if (self::$shops && !$refresh)
return;
@@ -208,11 +355,14 @@ class ShopCore extends ObjectModel
}
}
- public function getUrls()
+ /**
+ * Get list of associated tables to shop
+ *
+ * @return array
+ */
+ public static function getAssoTables()
{
- return Db::getInstance()->ExecuteS('SELECT *
- FROM '._DB_PREFIX.'shop_url
- WHERE active=1 AND id_shop='.(int)$this->id);
+ return self::$assoTables;
}
/**
@@ -224,7 +374,7 @@ class ShopCore extends ObjectModel
*/
public static function getShops($active = true, $id_group_shop = null, $getAsListID = false)
{
- Shop::loadShops();
+ Shop::cacheShops();
$results = array();
foreach (self::$shops as $groupID => $groupData)
foreach ($groupData['shops'] as $id => $shopData)
@@ -246,7 +396,7 @@ class ShopCore extends ObjectModel
*/
public static function getIdByName($name)
{
- Shop::loadShops();
+ Shop::cacheShops();
foreach (self::$shops as $groupData)
foreach ($groupData['shops'] as $shopID => $shopData)
if (Tools::strtolower($shopData['name']) == Tools::strtolower($name))
@@ -262,99 +412,6 @@ class ShopCore extends ObjectModel
return count(Shop::getShops($active));
}
- public static function setCurrentShop()
- {
- $excluded_uris = self::getExcludedUris();
- preg_match('/^'.Tools::pRegexp(_PS_DIRECTORY_, '/').'([a-z0-9]+)\/.*$/Ui', $_SERVER['REQUEST_URI'], $res);
- if (isset($res[1]) AND !in_array($res[1], $excluded_uris))
- $uri = $res[1];
- else
- $uri = '';
-
- if (!$id_shop = (int)Tools::getValue('id_shop'))
- {
- $id_shop = Db::getInstance()->getValue('SELECT s.id_shop
- FROM '._DB_PREFIX_.'shop_url su
- LEFT JOIN '._DB_PREFIX_.'shop s ON (s.id_shop = su.id_shop)
- WHERE su.domain=\''.pSQL(Tools::getHttpHost()).'\' AND uri=\''.pSQL($uri).'\' AND s.active=1 AND s.deleted=0');
- if (!$id_shop)
- $id_shop = Configuration::get('PS_SHOP_DEFAULT');
- }
-
- $res = Db::getInstance()->getRow('SELECT s.id_shop, s.id_group_shop, s.id_category, su.uri, t.name
- FROM '._DB_PREFIX_.'shop s
- LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
- LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
- WHERE s.id_shop='.(int)$id_shop.' AND s.active=1 AND s.deleted=0 AND su.main=1');
-
- $id_shop = (int)$res['id_shop'];
- $id_group_shop = (int)$res['id_group_shop'];
- self::$id_current_shop = (int)$id_shop;
- self::$id_current_group_shop = (int)$id_group_shop;
- self::$id_current_root_category = (int)$res['id_category'];
- self::$current_base_uri = (!empty($res['uri']) ? $res['uri'].'/' : '' );
- self::$current_theme_name = $res['name'];
- }
-
- public static function getExcludedUris()
- {
- $dirname = dirname(__FILE__);
- $directories = scandir($dirname.'/../');
- $not_uri = array();
- foreach ($directories AS $directory)
- if (is_dir($dirname.'/../'.$directory) AND (!preg_match ('/^\./', $directory)))
- $not_uri[] = $directory;
- return $not_uri;
- }
-
- public static function getCurrentTheme()
- {
- return self::$current_theme_name;
- }
-
- public static function getCurrentBaseURI($with_base = true)
- {
- return ($with_base ? _PS_DIRECTORY_ : '').self::$current_base_uri;
- }
-
- public static function getCurrentGroupShop()
- {
- return Shop::retrieveContext('group');
- }
-
- /**
- * Get current shop ID.
- *
- * @param bool $forceContext If true and if no shop is selected in context, get default shop ID
- * @return int
- */
- public static function getCurrentShop($forceContext = false)
- {
- $shopID = Shop::retrieveContext('shop');
- if (!$shopID && $forceContext)
- $shopID = (int)Configuration::get('PS_SHOP_DEFAULT');
- return $shopID;
- }
-
- public function getTheme($entity = false, $id = false)
- {
- return Db::getInstance()->getValue('SELECT t.name
- FROM '._DB_PREFIX_.'shop s
- LEFT JOIN '._DB_PREFIX_.'theme t ON (s.id_theme = t.id_theme)
- WHERE id_shop='.(int)$this->id);
-
- }
-
- public static function getCurrentRootCategory()
- {
- return self::$id_current_root_category;
- }
-
- public function getRootCategory()
- {
- return $this->id_category;
- }
-
/**
* Retrieve group ID of a shop
*
@@ -363,7 +420,7 @@ class ShopCore extends ObjectModel
*/
public static function getGroupFromShop($shopID, $asID = true)
{
- Shop::loadShops();
+ Shop::cacheShops();
foreach (self::$shops as $groupID => $groupData)
if (array_key_exists($shopID, $groupData['shops']))
return ($asID) ? $groupID : $groupData;
@@ -371,14 +428,14 @@ class ShopCore extends ObjectModel
}
/**
- * If the shop group has a the option "share_datas" activated, get all shops ID of this group, else get current shop ID
+ * If the shop group has the option "share_datas" activated, get all shops ID of this group, else get current shop ID
*
* @param int $shopID
* @return array
*/
public static function getSharedShops($shopID)
{
- Shop::loadShops();
+ Shop::cacheShops();
foreach (self::$shops as $groupData)
if (array_key_exists($shopID, $groupData['shops']) && $groupData['share_datas'])
return array_keys($groupData['shops']);
@@ -519,7 +576,7 @@ class ShopCore extends ObjectModel
if (!$shopID)
return ($shopGroupID) ? ' AND '.$alias.'id_group_shop = '.(int)$shopGroupID : '';
- Shop::loadShops();
+ Shop::cacheShops();
foreach (self::$shops as $groupID => $groupData)
if (array_key_exists($shopID, $groupData['shops']) && $groupData['share_stock'])
return ' AND '.$alias.'id_group_shop = '.$groupID;
@@ -533,7 +590,7 @@ class ShopCore extends ObjectModel
*/
public static function getTree()
{
- Shop::loadShops();
+ Shop::cacheShops();
return self::$shops;
}
diff --git a/config/config.inc.php b/config/config.inc.php
index 5ad22aed3..0a4de6720 100644
--- a/config/config.inc.php
+++ b/config/config.inc.php
@@ -92,10 +92,11 @@ function ppp($var) {
function ddd($var) {
Tools::d($var);
}
+
/* Set the current Shop */
-Shop::setCurrentShop();
-define('_THEME_NAME_', Shop::getCurrentTheme());
-define('__PS_BASE_URI__', Shop::getCurrentBaseURI());
+Context::getContext()->shop = Shop::initialize();
+define('_THEME_NAME_', Context::getContext()->shop->getTheme());
+define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
/* Include all defines */
require_once(dirname(__FILE__).'/defines.inc.php');
diff --git a/controllers/ProductController.php b/controllers/ProductController.php
index f532ed91b..59858783b 100644
--- a/controllers/ProductController.php
+++ b/controllers/ProductController.php
@@ -205,7 +205,7 @@ class ProductControllerCore extends FrontController
$ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
$this->smarty->assign(array(
- 'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)($this->product->id), (int)(Shop::getCurrentShop()), (int)(self::$cookie->id_currency), $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)($tax)),
+ 'quantity_discounts' => $this->formatQuantityDiscounts(SpecificPrice::getQuantityDiscounts((int)($this->product->id), $this->id_current_shop, (int)(self::$cookie->id_currency), $id_country, $id_group), $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false), (float)($tax)),
'product' => $this->product,
'ecotax_tax_inc' => $ecotaxTaxAmount,
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php
index a87355378..748bf877f 100755
--- a/modules/blockcms/blockcms.php
+++ b/modules/blockcms/blockcms.php
@@ -179,13 +179,12 @@ class BlockCms extends Module
if (!$context)
$context = Context::getContext();
- $id_current_shop = Shop::getCurrentShop();
$cmsCategories = Db::getInstance()->ExecuteS('
SELECT bc.`id_cms_block`, bc.`id_cms_category`, bc.`display_store`, ccl.`link_rewrite`, ccl.`name` category_name, bcl.`name` block_name
FROM `'._DB_PREFIX_.'cms_block` bc
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
- WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.' AND bc.id_shop='.(int)$id_current_shop.'
+ WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.' AND bc.id_shop='.$context->shop->getID().'
ORDER BY `position`');
$content = array();
diff --git a/modules/referralprogram/ReferralProgramModule.php b/modules/referralprogram/ReferralProgramModule.php
index 96d491b77..ed4218670 100644
--- a/modules/referralprogram/ReferralProgramModule.php
+++ b/modules/referralprogram/ReferralProgramModule.php
@@ -186,8 +186,8 @@ class ReferralProgramModule extends ObjectModel
{
if (empty($email) OR !Validate::isEmail($email))
die (Tools::displayError('Email invalid.'));
-// $return_id = false, $ignoreGuest = true, $id_group_shop = false, $id_shop = false
- if ($checkCustomer === true AND Customer::customerExists($email, false, true, (int)Shop::getCurrentGroupShop(), (int)Shop::getCurrentShop()))
+
+ if ($checkCustomer === true AND Customer::customerExists($email))
return false;
$result = Db::getInstance()->getRow('
SELECT s.`id_referralprogram`
diff --git a/modules/themeinstallator/themeinstallator.php b/modules/themeinstallator/themeinstallator.php
index f3abeca79..0e9aac68d 100644
--- a/modules/themeinstallator/themeinstallator.php
+++ b/modules/themeinstallator/themeinstallator.php
@@ -426,6 +426,7 @@ class ThemeInstallator extends Module
$hookedModule = array();
$position = array();
$msg = '';
+ $shopID = Context::getContext()->shop->getID();
foreach ($this->xml->modules->hooks->hook as $row)
{
@@ -455,17 +456,17 @@ class ThemeInstallator extends Module
WHERE `name` = \''.pSQL($row).'\'');
else if (!$obj OR !$obj->install())
continue;
- Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.(int)Shop::getCurrentShop().')');
+ Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')');
$msg .= '
- '.pSQL($row).'';
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'hook_module`
- WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.(int)Shop::getCurrentShop());
+ WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.$shopID);
$count = -1;
while (isset($hookedModule[++$count]))
if ($hookedModule[$count] == $row)
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`)
- VALUES ('.(int)$obj->id.', '.(int)Shop::getCurrentShop().', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')');
+ VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')');
}
if (($val = (int)(Tools::getValue('nativeModules'))) != 1)
{
@@ -482,7 +483,7 @@ class ThemeInstallator extends Module
$msg .= '
- '.pSQL($row).'';
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'module_shop`
- WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.(int)Shop::getCurrentShop(true));
+ WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.$shopID);
}
}
$flag = 0;
@@ -496,7 +497,7 @@ class ThemeInstallator extends Module
UPDATE `'._DB_PREFIX_.'module`
SET `active`= 1
WHERE `name` = \''.pSQL($row).'\'');
- Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.(int)Shop::getCurrentShop(true).')');
+ Db::getInstance()->Execute('INSERT IGNORE INTO '._DB_PREFIX_.'module_shop (id_module, id_shop) VALUES('.(int)$obj->id.', '.$shopID.')');
}
else if (!is_object($obj) OR !$obj->install())
continue ;
@@ -505,19 +506,19 @@ class ThemeInstallator extends Module
$msg .= '
- '.pSQL($row).'';
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'hook_module`
- WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.(int)Shop::getCurrentShop(true));
+ WHERE `id_module` = '.pSQL($obj->id).' AND id_shop='.$shopID);
$count = -1;
while (isset($hookedModule[++$count]))
if ($hookedModule[$count] == $row)
{
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_shop`, `id_hook`, `position`)
- VALUES ('.(int)$obj->id.', '.(int)Shop::getCurrentShop(true).', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')');
+ VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', '.(int)$position[$count].')');
foreach ($exceptions[$count] as $filename)
if (!empty($filename))
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'hook_module_exceptions` (`id_module`, id_shop, `id_hook`, `file_name`)
- VALUES ('.(int)$obj->id.', '.(int)Shop::getCurrentShop(true).', '.(int)Hook::get($hook[$count]).', "'.pSQL($filename).'")');
+ VALUES ('.(int)$obj->id.', '.$shopID.', '.(int)Hook::get($hook[$count]).', "'.pSQL($filename).'")');
}
}
}