diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php
index cfc707e4c..ca3759695 100644
--- a/admin-dev/ajax.php
+++ b/admin-dev/ajax.php
@@ -503,7 +503,7 @@ if (Tools::isSubmit('saveHook'))
$hooks_list = explode(',', Tools::getValue('hooks_list'));
$id_shop = (int)Tools::getValue('id_shop');
if (!$id_shop)
- $id_shop = Context::getContext()->shop->getId(true);
+ $id_shop = Context::getContext()->shop->id;
$res = true;
$hookableList = array();
diff --git a/admin-dev/functions.php b/admin-dev/functions.php
index 605aae742..3ec961410 100644
--- a/admin-dev/functions.php
+++ b/admin-dev/functions.php
@@ -1,6 +1,6 @@
$group_data)
{
$disabled = ($group_data['totalShops'] != count($group_data['shops'])) ? 'disabled="disabled"' : '';
-
- if ($context->controller->multishop_context & Shop::CONTEXT_GROUP)
- $html .= ''.translate('Group:').' '.htmlspecialchars($group_data['name']).' ';
- else
- $html .= '';
-
- if ($context->controller->multishop_context & Shop::CONTEXT_SHOP)
- foreach ($group_data['shops'] as $sID => $shopData)
- if ($shopData['active'])
- $html .= 'shop->id == $sID) ? 'selected="selected"' : '').'>» '.$shopData['name'].' ';
-
- if (!($context->controller->multishop_context & Shop::CONTEXT_GROUP))
- $html .= ' ';
+ $html .= ''.translate('Group:').' '.htmlspecialchars($group_data['name']).' ';
+ foreach ($group_data['shops'] as $sID => $shopData)
+ if ($shopData['active'])
+ $html .= '» '.$shopData['name'].' ';
}
$html .= '';
@@ -511,12 +501,12 @@ function runAdminTab($tab, $ajaxMode = false)
'.translate('Back Office').'
'.$bread.'';
- if (!$ajaxMode && Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL)
+ if (!$ajaxMode && Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL)
{
echo '
';
- if (Context::shop() == Shop::CONTEXT_GROUP)
+ if (Shop::getContext() == Shop::CONTEXT_GROUP)
printf(translate('You are configuring your store for group shop %s'), ''.Context::getContext()->shop->getGroup()->name.' ');
- elseif (Context::shop() == Shop::CONTEXT_SHOP)
+ elseif (Shop::getContext() == Shop::CONTEXT_SHOP)
printf(translate('You are configuring your store for shop %s'), ''.Context::getContext()->shop->name.' ');
echo '
';
}
diff --git a/admin-dev/header.inc.php b/admin-dev/header.inc.php
index 719bd8f25..60b4efa0c 100644
--- a/admin-dev/header.inc.php
+++ b/admin-dev/header.inc.php
@@ -1,6 +1,6 @@
'.Context::getContext()->shop->getGroup()->name.'');
else
$youEditFieldFor = sprintf(translate('A modification of this field will be applied for the shop %s'), ''.Context::getContext()->shop->name.' ');
diff --git a/admin-dev/init.php b/admin-dev/init.php
index 2ef72e4d4..60c067a7d 100644
--- a/admin-dev/init.php
+++ b/admin-dev/init.php
@@ -1,6 +1,6 @@
{$shop_name}";
{else}
var youEditFieldFor = "{l s='A modification of this field will be applied for the shop ' slashes=1 }{$shop_name} ";
diff --git a/classes/AdminTab.php b/classes/AdminTab.php
index b0b1d4a56..c85ed52b5 100644
--- a/classes/AdminTab.php
+++ b/classes/AdminTab.php
@@ -995,7 +995,7 @@ abstract class AdminTabCore
{
foreach ($fields as $key => $options)
{
- if (isset($options['visibility']) && $options['visibility'] > Context::getContext()->shop->getContextType())
+ if (isset($options['visibility']) && $options['visibility'] > Shop::getContext())
continue;
if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key]))
@@ -1315,13 +1315,13 @@ abstract class AdminTabCore
$filterKey = $assos[$this->table]['type'];
$idenfierShop = $this->context->shop->getListOfID();
}
- else if (Context::shop() == Shop::CONTEXT_GROUP)
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
{
$assos = GroupShop::getAssoTables();
if (isset($assos[$this->table]) && $assos[$this->table]['type'] == 'group_shop')
{
$filterKey = $assos[$this->table]['type'];
- $idenfierShop = array($this->context->shop->getGroupID());
+ $idenfierShop = array(Shop::getContextGroupShopID());
}
}
@@ -1333,7 +1333,7 @@ abstract class AdminTabCore
else if (!preg_match('#(\s|,)\s*a\.`?'.pSQL($this->identifier).'`?(\s|,|$)#', $this->_group))
$this->_group .= ', a.'.pSQL($this->identifier);
- if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filterKey).'`? *sa#', $this->_join))
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filterKey).'`? *sa#', $this->_join))
$filterShop = 'JOIN `'._DB_PREFIX_.$this->table.'_'.$filterKey.'` sa ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filterKey.' IN ('.implode(', ', $idenfierShop).'))';
}
///////////////////////
@@ -1869,12 +1869,12 @@ abstract class AdminTabCore
$isDisabled = $isInvisible = false;
if (Shop::isFeatureActive())
{
- if (isset($field['visibility']) && $field['visibility'] > $this->context->shop->getContextType())
+ if (isset($field['visibility']) && $field['visibility'] > Shop::getContext())
{
$isDisabled = true;
$isInvisible = true;
}
- else if (Context::shop() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
+ else if (Shop::getContext() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
$isDisabled = true;
}
@@ -1903,7 +1903,7 @@ abstract class AdminTabCore
$this->$method($key, $field, $value);
// Multishop default value
- if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible)
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible)
echo '
'.$this->l('Use default value').'
@@ -2166,7 +2166,7 @@ abstract class AdminTabCore
public function getFieldValue($obj, $key, $id_lang = NULL, $id_shop = null)
{
if (!$id_shop && $obj->isLangMultishop())
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if ($id_lang)
$defaultValue = ($obj->id && isset($obj->{$key}[$id_lang])) ? $obj->{$key}[$id_lang] : '';
@@ -2332,7 +2332,7 @@ abstract class AdminTabCore
protected function displayAssoShop($type = 'shop')
{
- if (!Shop::isFeatureActive() || (!$this->_object && $this->context->shop->getContextType() != Shop::CONTEXT_ALL))
+ if (!Shop::isFeatureActive() || (!$this->_object && Shop::getContext() != Shop::CONTEXT_ALL))
return;
if ($type != 'shop' && $type != 'group_shop')
diff --git a/classes/Attribute.php b/classes/Attribute.php
index 92a076c9f..453703732 100644
--- a/classes/Attribute.php
+++ b/classes/Attribute.php
@@ -171,7 +171,7 @@ class AttributeCore extends ObjectModel
if (!$shop)
$shop = Context::getContext()->shop;
- $result = StockAvailable::getQuantityAvailableByProduct(null, (int)$id_product_attribute, $shop->getID());
+ $result = StockAvailable::getQuantityAvailableByProduct(null, (int)$id_product_attribute, $shop->id);
return ($result && $qty <= $result);
}
diff --git a/classes/Carrier.php b/classes/Carrier.php
index 1214daa0f..d9af5ffdc 100644
--- a/classes/Carrier.php
+++ b/classes/Carrier.php
@@ -213,7 +213,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_zone Zone id (for customer delivery address)
* @return float Delivery price
*/
- public function getDeliveryPriceByWeight($total_weight, $id_zone, Shop $shop = null)
+ public function getDeliveryPriceByWeight($total_weight, $id_zone)
{
$cache_key = $this->id.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight[$cache_key]))
@@ -225,7 +225,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$total_weight.' >= w.`delimiter1`
AND '.(float)$total_weight.' < w.`delimiter2`
AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_weight', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!isset($result['price']))
@@ -236,7 +236,7 @@ class CarrierCore extends ObjectModel
return self::$price_by_weight[$cache_key];
}
- public static function checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone, Shop $shop = null)
+ public static function checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone)
{
$cache_key = $id_carrier.'_'.$total_weight.'_'.$id_zone;
if (!isset(self::$price_by_weight2[$cache_key]))
@@ -248,7 +248,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$total_weight.' >= w.`delimiter1`
AND '.(float)$total_weight.' < w.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.'
- '.Carrier::sqlDeliveryRangeShop('range_weight', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_weight2[$cache_key] = (isset($result['price']));
@@ -256,14 +256,14 @@ class CarrierCore extends ObjectModel
return self::$price_by_weight2[$cache_key];
}
- public function getMaxDeliveryPriceByWeight($id_zone, Shop $shop = null)
+ public function getMaxDeliveryPriceByWeight($id_zone)
{
$sql = 'SELECT d.`price`
FROM `'._DB_PREFIX_.'delivery` d
INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
WHERE d.`id_zone` = '.(int)$id_zone.'
AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_weight', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_weight').'
ORDER BY w.`delimiter2` DESC LIMIT 1';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!isset($result[0]['price']))
@@ -278,7 +278,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_zone Zone id (for customer delivery address)
* @return float Delivery price
*/
- public function getDeliveryPriceByPrice($order_total, $id_zone, $id_currency = null, Shop $shop = null)
+ public function getDeliveryPriceByPrice($order_total, $id_zone, $id_currency = null)
{
$cache_key = $this->id.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price[$cache_key]))
@@ -293,7 +293,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_price', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
if (!isset($result['price']))
@@ -313,7 +313,7 @@ class CarrierCore extends ObjectModel
* @param integer $id_currency
* @return float Delivery price
*/
- public static function checkDeliveryPriceByPrice($id_carrier, $order_total, $id_zone, $id_currency = null, Shop $shop = null)
+ public static function checkDeliveryPriceByPrice($id_carrier, $order_total, $id_zone, $id_currency = null)
{
$cache_key = $id_carrier.'_'.$order_total.'_'.$id_zone.'_'.$id_currency;
if (!isset(self::$price_by_price2[$cache_key]))
@@ -328,7 +328,7 @@ class CarrierCore extends ObjectModel
AND '.(float)$order_total.' >= r.`delimiter1`
AND '.(float)$order_total.' < r.`delimiter2`
AND d.`id_carrier` = '.(int)$id_carrier.'
- '.Carrier::sqlDeliveryRangeShop('range_price', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter1` ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
self::$price_by_price2[$cache_key] = (isset($result['price']));
@@ -336,14 +336,14 @@ class CarrierCore extends ObjectModel
return self::$price_by_price2[$cache_key];
}
- public function getMaxDeliveryPriceByPrice($id_zone, Shop $shop = null)
+ public function getMaxDeliveryPriceByPrice($id_zone)
{
$sql = 'SELECT d.`price`
FROM `'._DB_PREFIX_.'delivery` d
INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
WHERE d.`id_zone` = '.(int)$id_zone.'
AND d.`id_carrier` = '.(int)$this->id.'
- '.Carrier::sqlDeliveryRangeShop('range_price', $shop).'
+ '.Carrier::sqlDeliveryRangeShop('range_price').'
ORDER BY r.`delimiter2` DESC LIMIT 1';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!isset($result[0]['price']))
@@ -357,7 +357,7 @@ class CarrierCore extends ObjectModel
* @param string $rangeTable Table name (price or weight)
* @return array Delivery prices
*/
- public static function getDeliveryPriceByRanges($range_table, $id_carrier, Shop $shop = null)
+ public static function getDeliveryPriceByRanges($range_table, $id_carrier)
{
$range_table = pSQL($range_table);
$sql = 'SELECT d.id_'.$range_table.', d.id_carrier, d.id_zone, d.price
@@ -366,7 +366,7 @@ class CarrierCore extends ObjectModel
WHERE d.id_carrier = '.(int)$id_carrier.'
AND d.id_'.$range_table.' IS NOT NULL
AND d.id_'.$range_table.' != 0
- '.Carrier::sqlDeliveryRangeShop($range_table, $shop).'
+ '.Carrier::sqlDeliveryRangeShop($range_table).'
ORDER BY r.delimiter1';
return Db::getInstance()->executeS($sql);
}
@@ -695,20 +695,16 @@ class CarrierCore extends ObjectModel
* @param string $rangeTable Table name to clean (weight or price according to shipping method)
* @return boolean Deletion result
*/
- public function deleteDeliveryPrice($range_table, Shop $shop = null)
+ public function deleteDeliveryPrice($range_table)
{
$where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.$range_table.'` IS NOT NULL OR `id_'.$range_table.'` = 0) ';
- if (!$shop)
- $shop = Context::getContext()->shop;
- $shop_id = $shop->getID();
- $shop_group_id = $shop->getGroupID();
- if (!$shop_id && !$shop_group_id)
+ if (Shop::getContext() == Shop::CONTEXT_ALL)
$where .= 'AND id_shop IS NULL AND id_group_shop IS NULL';
- else if (!$shop_id)
- $where .= 'AND id_shop IS NULL AND id_group_shop = '.$shop_group_id;
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ $where .= 'AND id_shop IS NULL AND id_group_shop = '.(int)Shop::getContextGroupShopID();
else
- $where .= 'AND id_shop = '.$shop_id;
+ $where .= 'AND id_shop = '.(int)Shop::getContextShopID();
return Db::getInstance()->delete('delivery', $where);
}
@@ -717,10 +713,9 @@ class CarrierCore extends ObjectModel
* Add new delivery prices
*
* @param array $priceList Prices list in multiple arrays (changed to array since 1.5.0)
- * @param Shop $shop Optionnal
* @return boolean Insertion result
*/
- public function addDeliveryPrice($price_list, Shop $shop = null)
+ public function addDeliveryPrice($price_list)
{
if (!$price_list)
return false;
@@ -731,18 +726,13 @@ class CarrierCore extends ObjectModel
if (!in_array('id_group_shop', $keys))
$keys[] = 'id_group_shop';
- if (!$shop)
- $shop = Context::getContext()->shop;
- $shop_id = $shop->getID();
- $shop_group_id = $shop->getGroupID();
-
$sql = 'INSERT INTO `'._DB_PREFIX_.'delivery` ('.implode(', ', $keys).') VALUES ';
foreach ($price_list as $values)
{
if (!isset($values['id_shop']))
- $values['id_shop'] = ($shop_id) ? $shop_id : null;
+ $values['id_shop'] = (Shop::getContext() == Shop::CONTEXT_SHOP) ? Shop::getContextShopID() : null;
if (!isset($values['id_group_shop']))
- $values['id_group_shop'] = ($shop_group_id) ? $shop_group_id : null;
+ $values['id_group_shop'] = (Shop::getContext() != Shop::CONTEXT_ALL) ? Shop::getContextGroupShopID() : null;
$sql .= '(';
foreach ($values as $v)
@@ -951,22 +941,16 @@ class CarrierCore extends ObjectModel
*
* @since 1.5.0
* @param string $rangeTable
- * @param Shop $shop
* @return string
*/
- public static function sqlDeliveryRangeShop($range_table, Shop $shop = null, $alias = 'd')
+ public static function sqlDeliveryRangeShop($range_table, $alias = 'd')
{
- if (!$shop)
- $shop = Context::getContext()->shop;
- $shop_id = $shop->getID();
- $shop_group_id = $shop->getGroupID();
- $where = '';
- if (!$shop_id && !$shop_group_id)
+ if (Shop::getContext() == Shop::CONTEXT_ALL)
$where = 'AND d2.id_shop IS NULL AND d2.id_group_shop IS NULL';
- else if (!$shop_id)
- $where = 'AND ((d2.id_group_shop IS NULL OR d2.id_group_shop = '.$shop_group_id.') AND d2.id_shop IS NULL)';
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ $where = 'AND ((d2.id_group_shop IS NULL OR d2.id_group_shop = '.Shop::getContextGroupShopID().') AND d2.id_shop IS NULL)';
else
- $where = 'AND (d2.id_shop = '.$shop_id.' OR (d2.id_group_shop = '.$shop_group_id.'
+ $where = 'AND (d2.id_shop = '.Shop::getContextShopID().' OR (d2.id_group_shop = '.Shop::getContextGroupShopID().'
AND d2.id_shop IS NULL) OR (d2.id_group_shop IS NULL AND d2.id_shop IS NULL))';
$sql = 'AND '.$alias.'.id_delivery = (
@@ -1075,7 +1059,7 @@ class CarrierCore extends ObjectModel
public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
if (is_null($cart))
$cart = Context::getContext()->cart;
diff --git a/classes/Cart.php b/classes/Cart.php
index 85e3b9e44..8bb0900d8 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -758,7 +758,7 @@ class CartCore extends ObjectModel
$quantity = (int)$quantity;
$id_product = (int)$id_product;
$id_product_attribute = (int)$id_product_attribute;
- $product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->getID());
+ $product = new Product($id_product, false, Configuration::get('PS_LANG_DEFAULT'), $shop->id);
/* If we have a product combination, the minimal quantity is set with the one of this combination */
if (!empty($id_product_attribute))
@@ -857,7 +857,7 @@ class CartCore extends ObjectModel
'id_product_attribute' => (int)$id_product_attribute,
'id_cart' => (int)$this->id,
'id_address_delivery' => (int)$id_address_delivery,
- 'id_shop' => $shop->getID(true),
+ 'id_shop' => $shop->id,
'quantity' => (int)$quantity,
'date_add' => date('Y-m-d H:i:s')
));
diff --git a/classes/Category.php b/classes/Category.php
index aa4b7b77c..3b907ac65 100644
--- a/classes/Category.php
+++ b/classes/Category.php
@@ -739,7 +739,7 @@ class CategoryCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Context::getContext()->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (c.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
WHERE `id_lang` = '.(int)$id_lang.'
- AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).'
+ AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND c.`id_parent` = '.(int)$id_parent.'
'.($active ? 'AND `active` = 1' : '').'
ORDER BY cs.`position` ASC');
@@ -798,7 +798,7 @@ class CategoryCore extends ObjectModel
WHERE `id_lang` = '.(int)$id_lang;
if (Context::getContext()->shop() == Shop::CONTEXT_SHOP && $use_shop_context)
$sql .= '
- AND cs.`id_shop` = '.(int)$shop->getID(true);
+ AND cs.`id_shop` = '.(int)$shop->id;
$sql .= '
AND c.`id_parent` = '.(int)$id_parent.'
ORDER BY `position` ASC';
@@ -983,7 +983,7 @@ class CategoryCore extends ObjectModel
WHERE c.`id_category` = '.(int)$id_current;
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP)
$sql .= '
- AND cs.`id_shop` = '.(int)$context->shop->getID(true);
+ AND cs.`id_shop` = '.(int)$context->shop->id;
$root_category = Category::getRootCategory();
if (Shop::isFeatureActive() && $context->shop() == Shop::CONTEXT_SHOP &&
(!Tools::isSubmit('id_category') ||
diff --git a/classes/Configuration.php b/classes/Configuration.php
index d4994c14a..a3cdbc6b7 100644
--- a/classes/Configuration.php
+++ b/classes/Configuration.php
@@ -377,11 +377,23 @@ class ConfigurationCore extends ObjectModel
*/
public static function deleteFromContext($key)
{
- list($shopID, $shopGroupID) = Shop::getContext();
- if (!$shopID && !$shopGroupID)
+ if (Shop::getContext() == Shop::CONTEXT_ALL)
+ $id_shop = $id_group_shop = null;
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ {
+ $id_group_shop = Shop::getContextGroupShopID();
+ $id_shop = null;
+ }
+ else
+ {
+ $id_group_shop = Shop::getContextGroupShopID();
+ $id_shop = Shop::getContextShopID();
+ }
+
+ if (!$id_shop && !$id_group_shop)
return;
- $id = Configuration::getIdByName($key, $shopGroupID, $shopID);
+ $id = Configuration::getIdByName($key, $id_group_shop, $id_shop);
$sql = 'DELETE FROM '._DB_PREFIX_.'configuration
WHERE id_configuration = '.$id;
Db::getInstance()->execute($sql);
@@ -395,17 +407,29 @@ class ConfigurationCore extends ObjectModel
* Check if configuration var is defined in given context
*
* @param string $key
- * @param int $langID
+ * @param int $id_lang
* @param int $context
*/
- public static function hasContext($key, $langID, $context)
+ public static function hasContext($key, $id_lang, $context)
{
- list($shopID, $shopGroupID) = Shop::getContext();
- if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $langID, null, $shopID))
+ if (Shop::getContext() == Shop::CONTEXT_ALL)
+ $id_shop = $id_group_shop = null;
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ {
+ $id_group_shop = Shop::getContextGroupShopID();
+ $id_shop = null;
+ }
+ else
+ {
+ $id_group_shop = Shop::getContextGroupShopID();
+ $id_shop = Shop::getContextShopID();
+ }
+
+ if ($context == Shop::CONTEXT_SHOP && Configuration::hasKey($key, $id_lang, null, $id_shop))
return true;
- else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $langID, $shopGroupID))
+ else if ($context == Shop::CONTEXT_GROUP && Configuration::hasKey($key, $id_lang, $id_group_shop))
return true;
- else if ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $langID))
+ else if ($context == Shop::CONTEXT_ALL && Configuration::hasKey($key, $id_lang))
return true;
return false;
}
@@ -416,17 +440,17 @@ class ConfigurationCore extends ObjectModel
{
$testContext = false;
foreach (Language::getLanguages(false) as $lang)
- if ((Context::shop() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP))
- || (Context::shop() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP)))
+ if ((Shop::getContext() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_SHOP))
+ || (Shop::getContext() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, $lang['id_lang'], Shop::CONTEXT_GROUP)))
$testContext = true;
}
else
{
- $testContext = ((Context::shop() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP))
- || (Context::shop() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false;
+ $testContext = ((Shop::getContext() == Shop::CONTEXT_SHOP && Configuration::hasContext($key, null, Shop::CONTEXT_SHOP))
+ || (Shop::getContext() == Shop::CONTEXT_GROUP && Configuration::hasContext($key, null, Shop::CONTEXT_GROUP))) ? true : false;
}
- return (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $testContext);
+ return (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $testContext);
}
/**
@@ -451,11 +475,23 @@ class ConfigurationCore extends ObjectModel
if (!Shop::isFeatureActive())
return;
- list($shopID, $shopGroupID) = Shop::getContext();
+ if (Shop::getContext() == Shop::CONTEXT_ALL)
+ $shop_id = $group_shop_id = null;
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ {
+ $group_shop_id = Shop::getContextGroupShopID();
+ $shop_id = null;
+ }
+ else
+ {
+ $group_shop_id = Shop::getContextGroupShopID();
+ $shop_id = Shop::getContextShopID();
+ }
+
if (is_null($id_shop))
- $id_shop = $shopID;
+ $id_shop = $shop_id;
if (is_null($id_group_shop))
- $id_group_shop = $shopGroupID;
+ $id_group_shop = $group_shop_id;
$id_shop = (int)$id_shop;
$id_group_shop = (int)$id_group_shop;
diff --git a/classes/Connection.php b/classes/Connection.php
index 59876b390..78782e9c0 100644
--- a/classes/Connection.php
+++ b/classes/Connection.php
@@ -72,9 +72,9 @@ class ConnectionCore extends ObjectModel
public function getFields()
{
if (!$this->id_shop)
- $this->id_shop = Context::getContext()->shop->getId(true);
+ $this->id_shop = Context::getContext()->shop->id;
if (!$this->id_group_shop)
- $this->id_group_shop = Context::getContext()->shop->getGroupID();
+ $this->id_group_shop = Context::getContext()->shop->id_group_shop;
$fields = parent::getFields();
return $fields;
@@ -147,8 +147,8 @@ class ConnectionCore extends ObjectModel
$connection->id_guest = (int)$cookie->id_guest;
$connection->id_page = Page::getCurrentId();
$connection->ip_address = Tools::getRemoteAddr() ? ip2long(Tools::getRemoteAddr()) : '';
- $connection->id_shop = Context::getContext()->shop->getID();
- $connection->id_group_shop = Context::getContext()->shop->getGroupID();
+ $connection->id_shop = Context::getContext()->shop->id;
+ $connection->id_group_shop = Context::getContext()->shop->id_group_shop;
$connection->date_add = $cookie->date_add;
if (Validate::isAbsoluteUrl($referer))
$connection->http_referer = $referer;
diff --git a/classes/Context.php b/classes/Context.php
index 708f24b4f..d6c2c7a0e 100644
--- a/classes/Context.php
+++ b/classes/Context.php
@@ -116,14 +116,4 @@ class ContextCore
{
return clone($this);
}
-
- /**
- * @return int Shop context type (Shop::CONTEXT_ALL, etc.)
- */
- public static function shop()
- {
- if (!self::$instance->shop->getContextType())
- return Shop::CONTEXT_ALL;
- return self::$instance->shop->getContextType();
- }
}
\ No newline at end of file
diff --git a/classes/Currency.php b/classes/Currency.php
index 5b227105a..257629df1 100644
--- a/classes/Currency.php
+++ b/classes/Currency.php
@@ -216,7 +216,7 @@ class CurrencyCore extends ObjectModel
public static function getPaymentCurrenciesSpecial($id_module, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT *
FROM '._DB_PREFIX_.'module_currency
@@ -228,7 +228,7 @@ class CurrencyCore extends ObjectModel
public static function getPaymentCurrencies($id_module, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT c.*
FROM `'._DB_PREFIX_.'module_currency` mc
@@ -244,7 +244,7 @@ class CurrencyCore extends ObjectModel
public static function checkPaymentCurrencies($id_module, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'module_currency`
diff --git a/classes/Customer.php b/classes/Customer.php
index afce3d9bd..5bc7b853a 100644
--- a/classes/Customer.php
+++ b/classes/Customer.php
@@ -193,8 +193,8 @@ class CustomerCore extends ObjectModel
public function add($autodate = true, $null_values = true)
{
- $this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->getID();
- $this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->getGroupID();
+ $this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
+ $this->id_group_shop = ($this->id_group_shop) ? $this->id_group_shop : Context::getContext()->shop->id_group_shop;
$this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days);
$this->secure_key = md5(uniqid(rand(), true));
$this->last_passwd_gen = date('Y-m-d H:i:s', strtotime('-'.Configuration::get('PS_PASSWD_TIME_FRONT').'minutes'));
diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php
index 8051a91b4..c307ea920 100644
--- a/classes/CustomerThread.php
+++ b/classes/CustomerThread.php
@@ -89,7 +89,7 @@ class CustomerThreadCore extends ObjectModel
SELECT cm.id_customer_thread
FROM '._DB_PREFIX_.'customer_thread cm
WHERE cm.email = \''.pSQL($email).'\'
- AND cm.id_shop = '.(int)Context::getContext()->shop->getId(true).'
+ AND cm.id_shop = '.(int)Context::getContext()->shop->id.'
AND cm.id_order = '.(int)$id_order
);
}
diff --git a/classes/Employee.php b/classes/Employee.php
index 4d5f833fc..0c299ba95 100644
--- a/classes/Employee.php
+++ b/classes/Employee.php
@@ -254,10 +254,10 @@ class EmployeeCore extends ObjectModel
{
$context = Context::getContext();
- switch ($type = $context->shop->getContextType())
+ switch (Shop::getContext())
{
- case 1:
- if ($context->shop->checkIfShopExist($context->shop->id))
+ case Shop::CONTEXT_SHOP:
+ if ($context->shop->checkIfShopExist(Shop::getContextShopID()))
{
if (!in_array($context->shop->id, Employee::getEmployeeShopById($id_employee)))
return false;
@@ -266,10 +266,10 @@ class EmployeeCore extends ObjectModel
return false;
break;
- case 2:
- if ($context->shop->checkIfGroupShopExist($context->shop->getGroupID()))
+ case Shop::CONTEXT_GROUP:
+ if ($context->shop->checkIfGroupShopExist(Shop::getContextGroupShopID()))
{
- $shops = $context->shop->getIdShopsByIdGroupShop($context->shop->getGroupID());
+ $shops = $context->shop->getIdShopsByIdGroupShop(Shop::getContextGroupShopID());
foreach ($shops as $shop)
if (!in_array($shop, Employee::getEmployeeShopById($id_employee)))
return false;
@@ -278,7 +278,7 @@ class EmployeeCore extends ObjectModel
return false;
break;
- case 3:
+ case Shop::CONTEXT_ALL:
if ($context->employee->id_profile == _PS_ADMIN_PROFILE_ ||
$context->shop->getTotalShopsWhoExists() == Employee::getTotalEmployeeShopById($id_employee))
return true;
diff --git a/classes/Meta.php b/classes/Meta.php
index c227bd266..7236c0f6a 100644
--- a/classes/Meta.php
+++ b/classes/Meta.php
@@ -161,10 +161,10 @@ class MetaCore extends ObjectModel
SELECT id_meta
FROM `'._DB_PREFIX_.'meta_lang`
WHERE url_rewrite = \''.pSQL($url_rewrite).'\' AND id_lang = '.(int)$id_lang.'
- AND id_shop = '.Context::getContext()->shop->getID(true).'
+ AND id_shop = '.Context::getContext()->shop->id.'
)
AND id_lang = '.(int)$new_id_lang.'
- AND id_shop = '.Context::getContext()->shop->getID(true));
+ AND id_shop = '.Context::getContext()->shop->id);
}
}
diff --git a/classes/Module.php b/classes/Module.php
index 5fa4f0d2c..81643c53c 100644
--- a/classes/Module.php
+++ b/classes/Module.php
@@ -1249,8 +1249,8 @@ abstract class ModuleCore
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
WHERE h.`name` = \''.pSQL($hookPayment).'\'
AND mc.id_country = '.(int)$billing->id_country.'
- AND mc.id_shop = '.(int)$context->shop->getID(true).'
- AND mg.id_shop = '.(int)$context->shop->getID(true).'
+ AND mc.id_shop = '.(int)$context->shop->id.'
+ AND mg.id_shop = '.(int)$context->shop->id.'
AND (SELECT COUNT(*) FROM '._DB_PREFIX_.'module_shop ms WHERE ms.id_module = m.id_module AND ms.id_shop IN('.implode(', ', $list).')) = '.count($list).'
AND hm.id_shop IN('.implode(', ', $list).')
AND (mg.`id_group` IN('.implode(', ', $groups).'))
@@ -1690,7 +1690,7 @@ abstract class ModuleCore
FROM `'._DB_PREFIX_.'hook_module`
WHERE `id_hook` = '.(int)($id_hook).'
AND `id_module` = '.(int)($this->id).'
- AND `id_shop` = '.(int)Context::getContext()->shop->getId(true));
+ AND `id_shop` = '.(int)Context::getContext()->shop->id);
return $result['position'];
}
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index d69c84a8b..8c13008dc 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -162,7 +162,7 @@ abstract class ObjectModelCore
}
if ($this->isLangMultishop() && !$this->id_shop)
- $this->id_shop = Context::getContext()->shop->getID(true);
+ $this->id_shop = Context::getContext()->shop->id;
if (!Validate::isTableOrIdentifier($this->def['primary']) || !Validate::isTableOrIdentifier($this->def['table']))
throw new PrestaShopException('Identifier or table format not valid for class '.get_class($this));
@@ -423,11 +423,11 @@ abstract class ObjectModelCore
if (!Shop::isFeatureActive())
{
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'shop')
- $result &= $this->associateTo(Context::getContext()->shop->getID(true), 'shop');
+ $result &= $this->associateTo(Context::getContext()->shop->id, 'shop');
$assos = GroupShop::getAssoTables();
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'group_shop')
- $result &= $this->associateTo(Context::getContext()->shop->getGroupID(), 'group_shop');
+ $result &= $this->associateTo(Context::getContext()->shop->id_group_shop, 'group_shop');
}
// @hook actionObject*AddAfter
@@ -954,7 +954,7 @@ abstract class ObjectModelCore
public function isAssociatedToShop($id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
$sql = 'SELECT id_shop
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
@@ -1003,7 +1003,7 @@ abstract class ObjectModelCore
public function isAssociatedToGroupShop($id_group_shop = null)
{
if (is_null($id_group_shop))
- $id_group_shop = Context::getContext()->shop->getGroupID();
+ $id_group_shop = Context::getContext()->shop->id_group_shop;
$sql = 'SELECT id_group_shop
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_group_shop`
diff --git a/classes/Page.php b/classes/Page.php
index cf754cb60..bb0cc81a5 100644
--- a/classes/Page.php
+++ b/classes/Page.php
@@ -113,7 +113,7 @@ class PageCore extends ObjectModel
SET `counter` = `counter` + 1
WHERE `id_date_range` = '.(int)$id_date_range.'
AND `id_page` = '.(int)$id_page.'
- AND `id_shop` = '.(int)$context->shop->getID();
+ AND `id_shop` = '.(int)$context->shop->id;
Db::getInstance()->execute($sql);
// If no one has seen the page in this date range, it is added
@@ -122,8 +122,8 @@ class PageCore extends ObjectModel
'id_date_range' => (int)$id_date_range,
'id_page' => (int)$id_page,
'counter' => 1,
- 'id_shop' => (int)$context->shop->getID(),
- 'id_group_shop' => (int)$context->shop->getGroupID(),
+ 'id_shop' => (int)$context->shop->id,
+ 'id_group_shop' => (int)$context->shop->id_group_shop,
));
}
}
diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php
index 35fb3a1ab..9883031b8 100644
--- a/classes/PaymentModule.php
+++ b/classes/PaymentModule.php
@@ -151,8 +151,8 @@ abstract class PaymentModuleCore extends Module
$order->id_cart = (int)$cart->id;
$order->reference = $reference;
- $order->id_shop = (int)($shop->getID() ? $shop->getID() : $cart->id_shop);
- $order->id_group_shop = (int)($shop->getID() ? $shop->getGroupID() : $cart->id_group_shop);
+ $order->id_shop = (int)(Shop::getContext() == Shop::CONTEXT_SHOP ? $shop->id : $cart->id_shop);
+ $order->id_group_shop = (int)(Shop::getContext() == Shop::CONTEXT_SHOP ? $shop->id_group_shop : $cart->id_group_shop);
$customer = new Customer($order->id_customer);
$order->secure_key = ($secure_key ? pSQL($secure_key) : pSQL($customer->secure_key));
diff --git a/classes/Product.php b/classes/Product.php
index bc4ff4be2..04084b344 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -1881,7 +1881,7 @@ class ProductCore extends ObjectModel
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
return SpecificPrice::getProductIdByDate(
- $context->shop->getID(),
+ $context->shop->id,
$context->currency->id,
$id_country,
$context->customer->id_default_group,
@@ -2293,7 +2293,7 @@ class ProductCore extends ObjectModel
$id_customer = $context->customer->id;
return Product::priceCalculation(
- $context->shop->getID(),
+ $context->shop->id,
$id_product,
$id_product_attribute,
$id_country,
@@ -2514,7 +2514,7 @@ class ProductCore extends ObjectModel
$ids = Address::getCountryAndState((int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$id_country = (int)($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
- return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $context->shop->getID(), $id_currency, $id_country, $id_group, $quantity);
+ return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $context->shop->id, $id_currency, $id_country, $id_group, $quantity);
}
/**
@@ -2649,7 +2649,7 @@ class ProductCore extends ObjectModel
else if (is_string($product_attribute))
$sql->where('stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)');
}
- $sql = StockAvailable::addSqlShopRestriction($sql, $shop->getID(true), 'stock');
+ $sql = StockAvailable::addSqlShopRestriction($sql, $shop->id, 'stock');
}
else
{
@@ -2667,7 +2667,7 @@ class ProductCore extends ObjectModel
$sql .= ' AND stock.id_product_attribute = IFNULL('.pSQL($product_attribute).'.id_product_attribute, 0)';
}
- $sql .= StockAvailable::addSqlShopRestriction(null, $shop->getID(true), 'stock').' )';
+ $sql .= StockAvailable::addSqlShopRestriction(null, $shop->id, 'stock').' )';
}
return $sql;
@@ -4662,7 +4662,7 @@ class ProductCore extends ObjectModel
$manager = StockManagerFactory::getManager();
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Product::usesAdvancedStockManagement($id_product) &&
StockAvailable::dependsOnStock($id_product, $id_shop))
diff --git a/classes/Search.php b/classes/Search.php
index b43663099..c3fdaff65 100644
--- a/classes/Search.php
+++ b/classes/Search.php
@@ -178,7 +178,7 @@ class SearchCore
FROM '._DB_PREFIX_.'search_word sw
LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
WHERE sw.id_lang = '.(int)$id_lang.'
- AND sw.id_shop = '.$context->shop->getID(true).'
+ AND sw.id_shop = '.$context->shop->id.'
AND sw.word LIKE
'.($word[0] == '-'
? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\''
@@ -201,7 +201,7 @@ class SearchCore
FROM '._DB_PREFIX_.'search_word sw
LEFT JOIN '._DB_PREFIX_.'search_index si ON sw.id_word = si.id_word
WHERE sw.id_lang = '.(int)$id_lang.'
- AND sw.id_shop = '.$context->shop->getID(true).'
+ AND sw.id_shop = '.$context->shop->id.'
AND si.id_product = p.id_product
AND ('.implode(' OR ', $score_array).')
) position';
@@ -608,7 +608,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
WHERE p.`active` = 1
- AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID().'
+ AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
@@ -645,7 +645,7 @@ class SearchCore
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cg.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
'.Product::sqlStock('p', 0).'
WHERE p.`active` = 1
- AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID().'
+ AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
AND cg.`id_group` '.(!$id_customer ? '= 1' : 'IN (
SELECT id_group FROM '._DB_PREFIX_.'customer_group
WHERE id_customer = '.(int)$id_customer.')').'
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index f55b1aba6..cd5281fc4 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -884,7 +884,7 @@ class AdminControllerCore extends Controller
foreach ($fields as $field => $values)
{
// We don't validate fields with no visibility
- if (Shop::isFeatureActive() && isset($values['visibility']) && ($values['visibility'] > Context::getContext()->shop->getContextType()))
+ if (Shop::isFeatureActive() && isset($values['visibility']) && ($values['visibility'] > Shop::getContext()))
continue;
// Check if field is required
@@ -919,7 +919,7 @@ class AdminControllerCore extends Controller
{
foreach ($fields as $key => $options)
{
- if (Shop::isFeatureActive() && isset($options['visibility']) && ($options['visibility'] > Context::getContext()->shop->getContextType()))
+ if (Shop::isFeatureActive() && isset($options['visibility']) && ($options['visibility'] > Shop::getContext()))
continue;
if (Shop::isFeatureActive() && isset($_POST['configUseDefault'][$key]))
@@ -1201,7 +1201,7 @@ class AdminControllerCore extends Controller
$quick_access = QuickAccess::getQuickAccesses($this->context->language->id);
foreach ($quick_access as $index => $quick)
{
- if ($quick['link'] == '../' && Context::shop() == Shop::CONTEXT_SHOP)
+ if ($quick['link'] == '../' && Shop::getContext() == Shop::CONTEXT_SHOP)
$quick_access[$index]['link'] = $this->context->shop->getBaseURL();
else
{
@@ -1312,26 +1312,14 @@ class AdminControllerCore extends Controller
// Shop context
if ($is_multishop)
{
- if (Context::shop() == Shop::CONTEXT_ALL)
- {
- $shop_context = 'all';
- $shop_name = '';
- }
- else if (Context::shop() == Shop::CONTEXT_GROUP)
- {
- $shop_context = 'group';
- $shop_name = $this->context->shop->getGroup()->name;
- }
- else
- {
- $shop_context = 'shop';
+ if (Shop::getContext() == Shop::CONTEXT_SHOP)
$shop_name = $this->context->shop->name;
- }
+ else
+ $shop_name = 'PrestaShop';
$this->context->smarty->assign(array(
- 'shop_name' => $shop_name,
- 'shop_context' => $shop_context,
- ));
+ 'shop_name' => $shop_name,
+ ));
}
}
@@ -1669,12 +1657,22 @@ class AdminControllerCore extends Controller
}
else if (!Shop::isFeatureActive())
$this->context->cookie->shopContext = 's-1';
+
$shop_id = '';
+ Shop::setContext(Shop::CONTEXT_ALL);
if ($this->context->cookie->shopContext)
{
$split = explode('-', $this->context->cookie->shopContext);
- if (count($split) == 2 && $split[0] == 's')
- $shop_id = (int)$split[1];
+ if (count($split) == 2)
+ {
+ if ($split[0] == 'g')
+ Shop::setContext(Shop::CONTEXT_GROUP, $split[1]);
+ else
+ {
+ Shop::setContext(Shop::CONTEXT_SHOP, $split[1]);
+ $shop_id = $split[1];
+ }
+ }
}
else if ($this->context->employee->id_profile == _PS_ADMIN_PROFILE_)
$shop_id = '';
@@ -1688,7 +1686,9 @@ class AdminControllerCore extends Controller
Employee::getEmployeeShopAccess((int)$this->context->employee->id);
// Replace existing shop if necessary
- if ($this->context->shop->id != $shop_id)
+ if (!$shop_id)
+ $this->context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
+ else if ($this->context->shop->id != $shop_id)
$this->context->shop = new Shop($shop_id);
if ($this->ajax && method_exists($this, 'ajaxPreprocess'))
@@ -1955,7 +1955,7 @@ class AdminControllerCore extends Controller
else if (isset($assos_group[$this->table]) && $assos_group[$this->table]['type'] == 'group_shop')
{
$filter_key = $assos_group[$this->table]['type'];
- $idenfier_shop = array($this->context->shop->getGroupID());
+ $idenfier_shop = array(Shop::getContextGroupShopID());
}
}
@@ -1968,7 +1968,7 @@ class AdminControllerCore extends Controller
$this->_group .= ', a.'.pSQL($this->identifier);
$test_join = !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_'.$filter_key).'`? *sa#', $this->_join);
- if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $test_join)
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $test_join)
{
$filter_shop = ' JOIN `'._DB_PREFIX_.$this->table.'_'.$filter_key.'` sa ';
$filter_shop .= 'ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_'.$filter_key.' IN ('.implode(', ', $idenfier_shop).'))';
diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php
index ed7caacff..768c8197e 100755
--- a/classes/controller/FrontController.php
+++ b/classes/controller/FrontController.php
@@ -230,8 +230,8 @@ class FrontControllerCore extends Controller
$cart->id_lang = (int)($this->context->cookie->id_lang);
$cart->id_currency = (int)($this->context->cookie->id_currency);
$cart->id_guest = (int)($this->context->cookie->id_guest);
- $cart->id_group_shop = (int)$this->context->shop->getGroupID();
- $cart->id_shop = $this->context->shop->getID(true);
+ $cart->id_group_shop = (int)$this->context->shop->id_group_shop;
+ $cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer)
{
$cart->id_customer = (int)($this->context->cookie->id_customer);
@@ -308,7 +308,7 @@ class FrontControllerCore extends Controller
'come_from' => Tools::getHttpHost(true, true).Tools::htmlentitiesUTF8(str_replace('\'', '', urldecode($_SERVER['REQUEST_URI']))),
'cart_qties' => (int)$cart->nbProducts(),
'currencies' => Currency::getCurrencies(),
- 'languages' => Language::getLanguages(true, $this->context->shop->getID()),
+ 'languages' => Language::getLanguages(true, $this->context->shop->id),
'priceDisplay' => Product::getTaxCalculationMethod(),
'add_prod_display' => (int)Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'shop_name' => Configuration::get('PS_SHOP_NAME'),
@@ -694,7 +694,7 @@ class FrontControllerCore extends Controller
'ad' => $ad,
'live_edit' => true,
'hook_list' => Hook::$executed_hooks,
- 'id_shop' => $this->context->shop->getId(true)
+ 'id_shop' => $this->context->shop->id
));
return $this->context->smarty->createTemplate(_PS_ALL_THEMES_DIR_.'live_edit.tpl', $data)->fetch();
}
diff --git a/classes/helper/HelperForm.php b/classes/helper/HelperForm.php
index 95382c79f..723a204ed 100644
--- a/classes/helper/HelperForm.php
+++ b/classes/helper/HelperForm.php
@@ -209,21 +209,21 @@ class HelperFormCore extends Helper
}
else
{
- switch (Context::shop())
+ switch (Shop::getContext())
{
case Shop::CONTEXT_SHOP :
- $assos[$this->context->shop->id] = $this->context->shop->id;
- break;
+ $assos[Shop::getContextShopID()] = Shop::getContextShopID();
+ break;
case Shop::CONTEXT_GROUP :
- foreach (Shop::getShops(false, $this->context->shop->getGroupID(), true) as $id_shop)
+ foreach (Shop::getShops(false, Shop::getContextGroupShopID(), true) as $id_shop)
$assos[$id_shop] = $id_shop;
- break;
+ break;
default :
foreach (Shop::getShops(false, null, true) as $id_shop)
$assos[$id_shop] = $id_shop;
- break;
+ break;
}
}
diff --git a/classes/helper/HelperOptions.php b/classes/helper/HelperOptions.php
index bb3eec7ef..f2568ddac 100644
--- a/classes/helper/HelperOptions.php
+++ b/classes/helper/HelperOptions.php
@@ -71,12 +71,12 @@ class HelperOptionsCore extends Helper
$isDisabled = $isInvisible = false;
if (Shop::isFeatureActive())
{
- if (isset($field['visibility']) && $field['visibility'] > $this->context->shop->getContextType())
+ if (isset($field['visibility']) && $field['visibility'] > Shop::getContext())
{
$isDisabled = true;
$isInvisible = true;
}
- else if (Context::shop() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
+ else if (Shop::getContext() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key))
$isDisabled = true;
}
$field['is_disabled'] = $isDisabled;
@@ -126,7 +126,7 @@ class HelperOptionsCore extends Helper
}
// Multishop default value
- $field['multishop_default'] = (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && !$isInvisible);
+ $field['multishop_default'] = (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible);
// Assign the modifications back to parent array
$category_data['fields'][$key] = $field;
diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php
index df2b0fab3..b04860c74 100644
--- a/classes/order/OrderDetail.php
+++ b/classes/order/OrderDetail.php
@@ -227,7 +227,7 @@ class OrderDetailCore extends ObjectModel
$this->context = $context;
$id_shop = null;
if ($this->context != null && isset($this->context->shop))
- $id_shop = $this->context->shop->getID();
+ $id_shop = $this->context->shop->id;
parent::__construct($id, $id_lang, $id_shop);
}
@@ -458,7 +458,7 @@ class OrderDetailCore extends ObjectModel
$this->group_reduction = (float)(Group::getReduction((int)($order->id_customer)));
if (isset($this->context->shop))
- $shop_id = $this->context->shop->getID();
+ $shop_id = $this->context->shop->id;
else
$shop_id = $cart->id_shop;
diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php
index 52b45a545..adf159886 100644
--- a/classes/shop/Shop.php
+++ b/classes/shop/Shop.php
@@ -105,6 +105,10 @@ class ShopCore extends ObjectModel
),
);
+ protected static $context;
+ protected static $context_id_shop;
+ protected static $context_id_group_shop;
+
/**
* There are 3 kinds of shop context : shop, group shop and general
*/
@@ -369,32 +373,10 @@ class ShopCore extends ObjectModel
public function getGroup()
{
if (!$this->group)
- $this->group = new GroupShop($this->getGroupID());
+ $this->group = new GroupShop($this->id_group_shop);
return $this->group;
}
- /**
- * Get current shop ID
- *
- * @return int
- */
- public function getID($use_default = false)
- {
- return (!$this->id && $use_default) ? (int)Configuration::get('PS_SHOP_DEFAULT') : (int)$this->id;
- }
-
- /**
- * Get current shop group ID
- *
- * @return int
- */
- public function getGroupID()
- {
- if (defined('_PS_ADMIN_DIR_'))
- return Shop::getContextGroupID();
- return (isset($this->id_group_shop)) ? (int)$this->id_group_shop : null;
- }
-
/**
* Get root category of current shop
*
@@ -637,13 +619,10 @@ class ShopCore extends ObjectModel
*/
public function getListOfID($share = false)
{
- $shop_id = $this->getID();
- $shop_group_id = $this->getGroupID();
-
- if ($shop_id)
- $list = ($share) ? Shop::getSharedShops($shop_id, $share) : array($shop_id);
- else if ($shop_group_id)
- $list = Shop::getShops(true, $shop_group_id, true);
+ if (Shop::getContext() == Shop::CONTEXT_SHOP)
+ $list = ($share) ? Shop::getSharedShops(Shop::getContextShopID(), $share) : array(Shop::getContextShopID());
+ else if (Shop::getContext() == Shop::CONTEXT_GROUP)
+ $list = Shop::getShops(true, Shop::getContextGroupShopID(), true);
else
$list = Shop::getShops(true, null, true);
@@ -669,46 +648,45 @@ class ShopCore extends ObjectModel
return Db::getInstance()->executeS($sql);
}
- /**
- * Retrieve the current shop context in FO or BO
- *
- * @param string null|shop|group
- * @return array(id_shop, id_group_shop)|int
- */
- public static function getContext($type = null)
+ public static function setContext($type, $id = null)
{
- $context = Context::getContext();
- if (!isset($context->shop))
- return ($type == 'shop' || $type == 'group') ? '' : array('', '');
-
- $shop_id = $context->shop->id;
- $shop_group_id = $context->shop->id_group_shop;
- if (defined('_PS_ADMIN_DIR_'))
+ switch ($type)
{
- if (!isset($context->cookie) || !$context->cookie->shopContext)
- return ($type == 'shop' || $type == 'group') ? '' : array('', '');
+ case self::CONTEXT_ALL :
+ self::$context_id_shop = null;
+ self::$context_id_group_shop = null;
+ break;
- // Parse shopContext cookie value (E.g. s-2, g-4)
- $split = explode('-', $context->cookie->shopContext);
- if (count($split) == 2 && $split[0] == 'g')
- $shop_group_id = (int)$split[1];
+ case self::CONTEXT_GROUP :
+ self::$context_id_shop = null;
+ self::$context_id_group_shop = (int)$id;
+ break;
+
+ case self::CONTEXT_SHOP :
+ self::$context_id_shop = (int)$id;
+ self::$context_id_group_shop = Shop::getGroupFromShop($id);
+ break;
+
+ default :
+ throw new PrestaShopException('Unknown context for shop');
}
- if ($type == 'shop')
- return $shop_id;
- else if ($type == 'group')
- return $shop_group_id;
- return array($shop_id, $shop_group_id);
+ self::$context = $type;
}
- /**
- * Get ID shop from context
- *
- * @return int
- */
- public static function getContextID()
+ public static function getContext()
{
- return Shop::getContext('shop');
+ return self::$context;
+ }
+
+ public static function getContextShopID()
+ {
+ return self::$context_id_shop;
+ }
+
+ public static function getContextGroupShopID()
+ {
+ return self::$context_id_group_shop;
}
/**
@@ -721,21 +699,6 @@ class ShopCore extends ObjectModel
return Shop::getContext('group');
}
- /**
- * Check in which type of shop context we are
- *
- * @return int
- */
- public function getContextType()
- {
- list($shop_id, $shop_group_id) = Shop::getContext();
- if ($shop_id)
- return Shop::CONTEXT_SHOP;
- else if ($shop_group_id)
- return Shop::CONTEXT_GROUP;
- return Shop::CONTEXT_ALL;
- }
-
/**
* Add an sql restriction for shops fields
*
@@ -752,19 +715,14 @@ class ShopCore extends ObjectModel
$alias .= '.';
$restriction = '';
- $shop_id = $this->getID();
- $shop_group_id = $this->getGroupID();
-
if ($type == 'group_shop')
{
- if ($shop_id)
- $restriction = ' AND '.$alias.'id_group_shop = '.Shop::getGroupFromShop($shop_id).' ';
- else if ($shop_group_id)
- $restriction = ' AND '.$alias.'id_group_shop = '.$shop_group_id.' ';
+ if (Shop::getContext() != Shop::CONTEXT_ALL)
+ $restriction = ' AND '.$alias.'id_group_shop = '.Shop::getContextGroupShopID().' ';
}
else
{
- if ($shop_id || $shop_group_id)
+ if (Shop::getContext() != Shop::CONTEXT_ALL)
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', $this->getListOfID($share)).') ';
//else if ($share == Shop::SHARE_STOCK)
// $restriction = ' AND '.$alias.'id_shop = '.$this->getID(true);
@@ -807,7 +765,7 @@ class ShopCore extends ObjectModel
*/
public function addSqlRestrictionOnLang($alias = null)
{
- return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->getID(true).' ';
+ return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$this->id.' ';
}
/**
@@ -888,12 +846,12 @@ class ShopCore extends ObjectModel
}
/**
- * @deprecated 1.5.0 Use shop->getID()
+ * @deprecated 1.5.0 Use shop->id
*/
public static function getCurrentShop()
{
Tools::displayAsDeprecated();
- return Context::getContext()->shop->getID(true);
+ return Context::getContext()->shop->id;
}
/**
@@ -938,7 +896,7 @@ class ShopCore extends ObjectModel
SELECT `id_category`
FROM `'._DB_PREFIX_.'category_shop`
WHERE `id_category` = '.(int)$id_category.'
- AND `id_shop` = '.(int)Context::getContext()->shop->getID(true));
+ AND `id_shop` = '.(int)Context::getContext()->shop->id);
}
/**
@@ -958,6 +916,6 @@ class ShopCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs
ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
WHERE p.`id_product` = '.(int)$id_product.'
- AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true));
+ AND cs.`id_shop` = '.(int)Context::getContext()->shop->id);
}
}
diff --git a/classes/shop/ShopUrl.php b/classes/shop/ShopUrl.php
index 45695d940..e7166774e 100644
--- a/classes/shop/ShopUrl.php
+++ b/classes/shop/ShopUrl.php
@@ -143,7 +143,7 @@ class ShopUrlCore extends ObjectModel
if (!self::$main_domain)
self::$main_domain = Db::getInstance()->getValue('SELECT domain
FROM '._DB_PREFIX_.'shop_url
- WHERE main=1 AND id_shop = '.Context::getContext()->shop->getID(true));
+ WHERE main=1 AND id_shop = '.Context::getContext()->shop->id);
return self::$main_domain;
}
@@ -154,7 +154,7 @@ class ShopUrlCore extends ObjectModel
$sql = 'SELECT domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
- AND id_shop='.Context::getContext()->shop->getID(true);
+ AND id_shop='.Context::getContext()->shop->id;
self::$main_domain_ssl = Db::getInstance()->getValue($sql);
}
return self::$main_domain_ssl;
diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php
index 37e5c198e..78828816d 100644
--- a/classes/stock/StockAvailable.php
+++ b/classes/stock/StockAvailable.php
@@ -182,7 +182,7 @@ class StockAvailableCore extends ObjectModel
public static function setProductDependsOnStock($id_product, $depends_on_stock = true, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop);
@@ -223,7 +223,7 @@ class StockAvailableCore extends ObjectModel
public static function setProductOutOfStock($id_product, $out_of_stock = false, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$existing_id = StockAvailable::getStockAvailableIdByProductId((int)$id_product, 0, (int)$id_shop);
@@ -261,7 +261,7 @@ class StockAvailableCore extends ObjectModel
public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
// if null, it's a product without attributes
if (is_null($id_product_attribute))
@@ -381,7 +381,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one
if (is_null($id_shop))
- $id_shop = (int)$context->shop->getID(true);
+ $id_shop = (int)$context->shop->id;
$id_lang = Context::getContext()->language->id;
$depends_on_stock = StockAvailable::dependsOnStock($id_product);
@@ -503,7 +503,7 @@ class StockAvailableCore extends ObjectModel
public static function dependsOnStock($id_product, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$query = new DbQuery();
$query->select('depends_on_stock');
@@ -526,7 +526,7 @@ class StockAvailableCore extends ObjectModel
public static function outOfStock($id_product, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$query = new DbQuery();
$query->select('out_of_stock');
@@ -557,7 +557,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one
if (is_null($id_shop))
- $id_shop = $context->shop->getID();
+ $id_shop = $context->shop->id;
// if we are in group_shop context
$group_shop = $context->shop->getGroup();
@@ -610,7 +610,7 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one
if (is_null($id_shop))
- $id_shop = $context->shop->getID(true);
+ $id_shop = $context->shop->id;
$group_shop = $context->shop->getGroup();
diff --git a/classes/stock/Warehouse.php b/classes/stock/Warehouse.php
index 8e6394ca9..19c876590 100644
--- a/classes/stock/Warehouse.php
+++ b/classes/stock/Warehouse.php
@@ -307,7 +307,7 @@ class WarehouseCore extends ObjectModel
public static function getProductWarehouseList($id_product, $id_product_attribute = 0, $id_shop = null)
{
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
// if it's a pack, returns warehouses if and only if some products use the advanced stock management
if (Pack::isPack($id_product))
@@ -344,7 +344,7 @@ class WarehouseCore extends ObjectModel
{
if (!$ignore_shop)
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$query = new DbQuery();
$query->select('w.id_warehouse, CONCAT(reference, \' - \', name) as name');
@@ -497,7 +497,7 @@ class WarehouseCore extends ObjectModel
return false;
if (is_null($id_shop))
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
// warehouses of the pack
$pack_warehouses = WarehouseProductLocation::getCollection((int)$id_product);
diff --git a/config/config.inc.php b/config/config.inc.php
index 48b56b18e..0fc8e8dd0 100644
--- a/config/config.inc.php
+++ b/config/config.inc.php
@@ -1,6 +1,6 @@
if (defined('_PS_ADMIN_DIR_'))
$cookie = new Cookie('psAdmin', '', $cookieLifetime);
else
- $cookie = new Cookie('ps'.Context::getContext()->shop->getID(), '', $cookieLifetime);
+ $cookie = new Cookie('ps'.Context::getContext()->shop->id, '', $cookieLifetime);
Context::getContext()->cookie = $cookie;
/* Create employee if in BO, customer else */
diff --git a/controllers/admin/AdminAccountingManagementController.php b/controllers/admin/AdminAccountingManagementController.php
index 8d0825c64..e1a8ae3d4 100644
--- a/controllers/admin/AdminAccountingManagementController.php
+++ b/controllers/admin/AdminAccountingManagementController.php
@@ -1,6 +1,6 @@
initToolbar();
$zones = Zone::getZones();
- $id_shop = $this->context->shop->getID();
+ $id_shop = $this->context->shop->id;
// Set default zone value to the shop and sort it
foreach ($zones as $zone)
@@ -105,7 +105,7 @@ class AdminAccountingManagementControllerCore extends AdminController
*/
protected function updateAccountNumber()
{
- $id_shop = $this->context->shop->getID();
+ $id_shop = $this->context->shop->id;
// Update the current default shop account number
Configuration::updateValue(
diff --git a/controllers/admin/AdminCategoriesController.php b/controllers/admin/AdminCategoriesController.php
index eb978da9b..ee3411469 100644
--- a/controllers/admin/AdminCategoriesController.php
+++ b/controllers/admin/AdminCategoriesController.php
@@ -153,7 +153,7 @@ class AdminCategoriesControllerCore extends AdminController
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (a.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')';
// we add restriction for shop
if (Shop::CONTEXT_SHOP == Context::getContext()->shop() && $is_multishop)
- $this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true);
+ $this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id;
$categories_tree = $this->_category->getParentsCategories();
if (empty($categories_tree)
@@ -181,7 +181,7 @@ class AdminCategoriesControllerCore extends AdminController
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
- parent::getList($id_lang, 'cs.position', $order_way, $start, $limit, Context::getContext()->shop->getID(true));
+ parent::getList($id_lang, 'cs.position', $order_way, $start, $limit, Context::getContext()->shop->id);
// Check each row to see if there are combinations and get the correct action in consequence
$nb_items = count($this->_list);
@@ -271,7 +271,7 @@ class AdminCategoriesControllerCore extends AdminController
{
$this->initToolbar();
$obj = $this->loadObject(true);
- $id_shop = Context::getContext()->shop->getID(true);
+ $id_shop = Context::getContext()->shop->id;
$selected_cat = array((isset($obj->id_parent) && $obj->isParentCategoryAvailable($id_shop))? $obj->id_parent : Tools::getValue('id_parent', Category::getRootCategory()->id));
$unidentified = new Group(Configuration::get('PS_UNIDENTIFIED_GROUP'));
$guest = new Group(Configuration::get('PS_GUEST_GROUP'));
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index 22a24c6b0..b6b29b0fb 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -1,6 +1,6 @@
id_shop = $this->context->shop->getID(true);
+ $customer->id_shop = $this->context->shop->id;
}
public function renderView()
diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php
index 2f0f17b28..06cc9f5ac 100644
--- a/controllers/admin/AdminGroupShopController.php
+++ b/controllers/admin/AdminGroupShopController.php
@@ -229,11 +229,11 @@ class AdminGroupShopControllerCore extends AdminController
'desc' => $this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop')
);
- $default_group_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
+ $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array(
'disabled' => $disabled,
'checked' => (Tools::getValue('addgroup_shop') !== false) ? true : false,
- 'defaultGroup' => $default_group_shop->getGroupID(),
+ 'defaultGroup' => $default_shop->id_group_shop,
);
if (isset($this->fields_import_form))
$this->tpl_form_vars = array_merge($this->tpl_form_vars, array('form_import' => $this->fields_import_form));
diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php
index aaf11e5bf..4175a1d20 100644
--- a/controllers/admin/AdminImportController.php
+++ b/controllers/admin/AdminImportController.php
@@ -1139,7 +1139,7 @@ class AdminImportControllerCore extends AdminController
$specific_price = new SpecificPrice();
$specific_price->id_product = (int)$product->id;
// @todo multishop specific price import
- $specific_price->id_shop = $this->context->shop->getID(true);
+ $specific_price->id_shop = $this->context->shop->id;
$specific_price->id_currency = 0;
$specific_price->id_country = 0;
$specific_price->id_group = 0;
diff --git a/controllers/admin/AdminMetaController.php b/controllers/admin/AdminMetaController.php
index 2dcf7b183..84c28ec61 100644
--- a/controllers/admin/AdminMetaController.php
+++ b/controllers/admin/AdminMetaController.php
@@ -1,6 +1,6 @@
shop->getID(true));
+ parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->id);
}
/**
diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php
index 04c5eca31..7839b515a 100644
--- a/controllers/admin/AdminModulesController.php
+++ b/controllers/admin/AdminModulesController.php
@@ -633,7 +633,7 @@ class AdminModulesControllerCore extends AdminController
else
{
// If we install a module, force temporary global context for multishop
- if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $method != 'getContent')
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $method != 'getContent')
{
Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
Context::getContext()->shop = new Shop();
@@ -677,9 +677,9 @@ class AdminModulesControllerCore extends AdminController
$toolbar .= '
active) ? 'checked="checked"' : '').' '.$activateOnclick.' /> '.$this->l('Activate module for').' ';
- if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP)
+ if (Shop::getContext() == Shop::CONTEXT_SHOP)
$toolbar .= 'shop '.$this->context->shop->name.' ';
- elseif ($this->context->shop->getContextType() == Shop::CONTEXT_GROUP)
+ elseif (Shop::getContext() == Shop::CONTEXT_GROUP)
$toolbar .= 'all shops of group shop '.$this->context->shop->getGroup()->name.' ';
else
$toolbar .= 'all shops';
@@ -701,7 +701,7 @@ class AdminModulesControllerCore extends AdminController
$return = ($method == 'install' ? 12 : 13);
elseif ($echo === false)
$module_errors[] = array('name' => $name, 'message' => $module->getErrors());
- if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop))
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop))
{
Context::getContext()->shop = clone(Context::getContext()->tmpOldShop);
unset(Context::getContext()->tmpOldShop);
diff --git a/controllers/admin/AdminModulesPositionsController.php b/controllers/admin/AdminModulesPositionsController.php
index 21b7c09d7..88e25992f 100644
--- a/controllers/admin/AdminModulesPositionsController.php
+++ b/controllers/admin/AdminModulesPositionsController.php
@@ -1,6 +1,6 @@
$module_instances,
'url_show_invisible' => self::$currentIndex.'&token='.$this->token.'&show_modules='.(int)Tools::getValue('show_modules').'&hook_position=',
'hook_position' => Tools::getValue('hook_position'),
- 'live_edit' => Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP,
+ 'live_edit' => Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP,
'url_live_edit' => $this->context->link->getPageLink('index', false, null,
'live_edit&ad='.$admin_dir.'&liveToken='.sha1($admin_dir._COOKIE_KEY_)
- .(Shop::isFeatureActive()?'&id_shop='.Context::getContext()->shop->getID() : '')),
+ .(Shop::isFeatureActive()?'&id_shop='.Context::getContext()->shop->id : '')),
'display_key' => $this->display_key,
'hooks' => $hooks,
'url_submit' => self::$currentIndex.'&token='.$this->token,
- 'can_move' => (Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_SHOP) ? false : true,
+ 'can_move' => (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) ? false : true,
));
return $this->createTemplate('list_modules.tpl')->fetch();
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index 607c08011..0708db0bb 100755
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -1,6 +1,6 @@
id_contact = 0;
$customer_thread->id_customer = (int)$order->id_customer;
- $customer_thread->id_shop = (int)$this->context->shop->getId(true);
+ $customer_thread->id_shop = (int)$this->context->shop->id;
$customer_thread->id_order = (int)$order->id;
$customer_thread->id_lang = (int)$this->context->language->id;
$customer_thread->email = $customer->email;
@@ -1151,7 +1151,7 @@ class AdminOrdersControllerCore extends AdminController
$productObj = new Product((int)$product['id_product'], false, (int)$this->context->language->id);
$combinations = array();
$attributes = $productObj->getAttributesGroups((int)$this->context->language->id);
- $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->getID());
+ $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], 0, (int)$this->context->shop->id);
// Tax rate for this customer
if (Tools::isSubmit('id_address'))
$product['tax_rate'] = $productObj->getTaxesRate(new Address(Tools::getValue('id_address')));
@@ -1174,7 +1174,7 @@ class AdminOrdersControllerCore extends AdminController
$combinations[$attribute['id_product_attribute']]['formatted_price'] = Tools::displayPrice(Tools::convertPrice($price_tax_incl, $currency), $currency);
}
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
- $combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID());
+ $combinations[$attribute['id_product_attribute']]['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->id);
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)$product['advanced_stock_management'] == 1)
$product['warehouse_list'][$attribute['id_product_attribute']] = Warehouse::getProductWarehouseList($product['id_product'], $attribute['id_product_attribute']);
diff --git a/controllers/admin/AdminPaymentController.php b/controllers/admin/AdminPaymentController.php
index de7d08e05..f28041762 100644
--- a/controllers/admin/AdminPaymentController.php
+++ b/controllers/admin/AdminPaymentController.php
@@ -1,6 +1,6 @@
shop->getID(true);
+ $shop_id = Context::getContext()->shop->id;
/* Get all modules then select only payment ones */
$modules = Module::getModulesOnDisk(true);
@@ -108,11 +108,11 @@ class AdminPaymentControllerCore extends AdminController
protected function saveRestrictions($type)
{
- Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module_'.bqSQL($type).'` WHERE id_shop = '.Context::getContext()->shop->getID(true));
+ Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'module_'.bqSQL($type).'` WHERE id_shop = '.Context::getContext()->shop->id);
foreach ($this->payment_modules as $module)
if ($module->active && isset($_POST[$module->name.'_'.$type.'']))
foreach ($_POST[$module->name.'_'.$type.''] as $selected)
- $values[] = '('.(int)$module->id.', '.Context::getContext()->shop->getID(true).', '.(int)$selected.')';
+ $values[] = '('.(int)$module->id.', '.Context::getContext()->shop->id.', '.(int)$selected.')';
if (count($values))
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'module_'.$type.' (`id_module`, `id_shop`, `id_'.$type.'`) VALUES '.implode(',', $values));
@@ -130,7 +130,7 @@ class AdminPaymentControllerCore extends AdminController
$this->toolbar_title = $this->l('Paiement');
unset($this->toolbar_btn['back']);
- $shop_context = (!Shop::isFeatureActive() || $this->context->shop->getContextType() == Shop::CONTEXT_SHOP);
+ $shop_context = (!Shop::isFeatureActive() || Shop::getContext() == Shop::CONTEXT_SHOP);
if (!$shop_context)
{
$this->tpl_view_vars = array('shop_context' => $shop_context);
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index 4aa9dc873..0e158d664 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -1,6 +1,6 @@
context->link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id), null, null, Context::getContext()->shop->getID());
+ $preview_url = $this->context->link->getProductLink($this->getFieldValue($object, 'id'), $this->getFieldValue($object, 'link_rewrite', $this->context->language->id), Category::getLinkRewrite($this->getFieldValue($object, 'id_category_default'), $this->context->language->id), null, null, Context::getContext()->shop->id);
if (!$object->active)
{
$admin_dir = dirname($_SERVER['PHP_SELF']);
@@ -1909,7 +1909,7 @@ class AdminProductsControllerCore extends AdminController
{
if ($id_category = (int)Tools::getValue('id_category'))
self::$currentIndex .= '&id_category='.(int)$id_category;
- $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true));
+ $this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->id);
$id_category = (int)Tools::getValue('id_category', 1);
$this->tpl_list_vars['is_category_filter'] = Tools::getValue('id_category') ? true : false;
@@ -2172,7 +2172,7 @@ class AdminProductsControllerCore extends AdminController
$preview_url = $this->context->link->getProductLink(
$product,
$this->getFieldValue($product, 'link_rewrite', $this->context->language->id),
- Category::getLinkRewrite($product->id_category_default, $this->context->language->id), null, null, Context::getContext()->shop->getID());
+ Category::getLinkRewrite($product->id_category_default, $this->context->language->id), null, null, Context::getContext()->shop->id);
if (!$product->active)
{
$preview_url = $this->context->link->getProductLink($product, $this->getFieldValue($product, 'link_rewrite', $this->default_form_language), Category::getLinkRewrite($this->getFieldValue($product, 'id_category_default'), $this->context->language->id));
@@ -2195,7 +2195,7 @@ class AdminProductsControllerCore extends AdminController
{
if (Validate::isLoadedObject(($product = new Product((int)Tools::getValue('id_product')))))
{
- $id_shop = $this->context->shop->getID();
+ $id_shop = $this->context->shop->id;
// If zone still exist, then update the database with the new value
if (count($zones = Zone::getZones()))
@@ -2466,7 +2466,7 @@ class AdminProductsControllerCore extends AdminController
else
{
$zones = Zone::getZones();
- $id_shop = $this->context->shop->getID();
+ $id_shop = $this->context->shop->id;
// Set default zone value to the shop and sort it
foreach ($zones as $zone)
@@ -3468,7 +3468,7 @@ class AdminProductsControllerCore extends AdminController
else
{
// if quantities are shared between shops of the group, it's not possible to manage them for a given shop
- if ($group_shop->share_stock && $group_shop->getTotalShops() > 1)
+ if ($group_shop->share_stock)
$show_quantities = false;
}
@@ -3830,7 +3830,7 @@ class AdminProductsControllerCore extends AdminController
{
$id_module = Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \''.pSQL($this->tab_display_module).'\'');
$this->tpl_form_vars['custom_form'] = Hook::exec('displayAdminProductsExtra', array(), (int)$id_module);
- }
+ }
diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php
index 4cbb127fc..bbd33d78e 100644
--- a/controllers/admin/AdminThemesController.php
+++ b/controllers/admin/AdminThemesController.php
@@ -1,6 +1,6 @@
shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO']['tmp_name']) && $_FILES['PS_LOGO']['tmp_name'])
{
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO'], 300000))
@@ -494,7 +494,7 @@ class AdminThemesControllerCore extends AdminController
*/
public function updateOptionPsLogoMail()
{
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) && $_FILES['PS_LOGO_MAIL']['tmp_name'])
{
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_MAIL'], 300000))
@@ -520,7 +520,7 @@ class AdminThemesControllerCore extends AdminController
*/
public function updateOptionPsLogoInvoice()
{
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) && $_FILES['PS_LOGO_INVOICE']['tmp_name'])
{
if ($error = ImageManager::validateUpload($_FILES['PS_LOGO_INVOICE'], 300000))
@@ -546,7 +546,7 @@ class AdminThemesControllerCore extends AdminController
*/
public function updateOptionPsStoresIcon()
{
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if (isset($_FILES['PS_STORES_ICON']['tmp_name']) && $_FILES['PS_STORES_ICON']['tmp_name'])
{
if ($error = ImageManager::validateUpload($_FILES['PS_STORES_ICON'], 300000))
@@ -572,7 +572,7 @@ class AdminThemesControllerCore extends AdminController
*/
public function updateOptionPsFavicon()
{
- $id_shop = Context::getContext()->shop->getID();
+ $id_shop = Context::getContext()->shop->id;
if ($id_shop == Configuration::get('PS_SHOP_DEFAULT'))
$this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico');
if ($this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon-'.(int)$id_shop.'.ico'))
diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php
index e6028322c..2e2c7d881 100644
--- a/controllers/front/ContactController.php
+++ b/controllers/front/ContactController.php
@@ -1,6 +1,6 @@
getValue('
SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm
- WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL(Tools::getValue('token')).'\'')
+ WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL(Tools::getValue('token')).'\'')
) || (
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, (int)Tools::getValue('id_order'))
)))
@@ -80,7 +80,7 @@ class ContactControllerCore extends FrontController
$fields = Db::getInstance()->executeS('
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
FROM '._DB_PREFIX_.'customer_thread cm
- WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND ('.
+ WHERE email = \''.pSQL($from).'\' AND cm.id_shop = '.(int)$this->context->shop->id.' AND ('.
($customer->id ? 'id_customer = '.(int)($customer->id).' OR ' : '').'
id_order = '.(int)(Tools::getValue('id_order')).')');
$score = 0;
@@ -107,7 +107,7 @@ class ContactControllerCore extends FrontController
$old_message = Db::getInstance()->getValue('
SELECT cm.message FROM '._DB_PREFIX_.'customer_message cm
LEFT JOIN '._DB_PREFIX_.'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
- WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->getID(true).'
+ WHERE cc.id_customer_thread = '.(int)($id_customer_thread).' AND cc.id_shop = '.(int)$this->context->shop->id.'
ORDER BY cm.date_add DESC');
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8'))
{
@@ -151,7 +151,7 @@ class ContactControllerCore extends FrontController
$ct = new CustomerThread();
if (isset($customer->id))
$ct->id_customer = (int)($customer->id);
- $ct->id_shop = (int)$this->context->shop->getID(true);
+ $ct->id_shop = (int)$this->context->shop->id;
if ($id_order = (int)Tools::getValue('id_order'))
$ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product'))
@@ -218,7 +218,7 @@ class ContactControllerCore extends FrontController
{
$customerThread = Db::getInstance()->getRow('
SELECT cm.* FROM '._DB_PREFIX_.'customer_thread cm
- WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->getID(true).' AND token = \''.pSQL($token).'\'');
+ WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL($token).'\'');
$this->context->smarty->assign('customerThread', $customerThread);
}
$this->context->smarty->assign(array('contacts' => Contact::getContacts($this->context->language->id),
diff --git a/controllers/front/ManufacturerController.php b/controllers/front/ManufacturerController.php
index 1de2e058f..9d91d2fc9 100644
--- a/controllers/front/ManufacturerController.php
+++ b/controllers/front/ManufacturerController.php
@@ -1,6 +1,6 @@
context->shop->getGroupID();
+ $id_current_group_shop = Shop::getContextGroupShopID();
$data = Manufacturer::getManufacturers(true, $this->context->language->id, true, false, false, false, $id_current_group_shop);
$nbProducts = count($data);
$this->pagination($nbProducts);
diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php
index 53127f10b..eed0eba0e 100644
--- a/controllers/front/OrderDetailController.php
+++ b/controllers/front/OrderDetailController.php
@@ -1,6 +1,6 @@
id_contact = 0;
$ct->id_customer = (int)$order->id_customer;
- $ct->id_shop = (int)$this->context->shop->getId(true);
+ $ct->id_shop = (int)$this->context->shop->id;
if ($id_product = (int)Tools::getValue('id_product') && $order->orderContainProduct((int)$id_product))
$ct->id_product = $id_product;
$ct->id_order = (int)$order->id;
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 31128685b..6036b8e3b 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -1,6 +1,6 @@
context->cookie->id_currency;
$id_product = (int)$this->product->id;
- $id_shop = $this->context->shop->getID(true);
+ $id_shop = $this->context->shop->id;
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true);
foreach ($quantity_discounts as &$quantity_discount)
diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php
index f85ac8a5f..fb2fc7985 100644
--- a/modules/blockadvertising/blockadvertising.php
+++ b/modules/blockadvertising/blockadvertising.php
@@ -67,7 +67,7 @@ class BlockAdvertising extends Module
$this->displayName = $this->l('Block advertising');
$this->description = $this->l('Adds a block to display an advertisement.');
- if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP)
+ if (Shop::getContext() == Shop::CONTEXT_SHOP)
{
if (defined('_PS_ADMIN_DIR_') || file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'-'.(int)$this->context->shop->id.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
{
diff --git a/modules/blockcategories/blockcategories.php b/modules/blockcategories/blockcategories.php
index 73832d619..abfb7e507 100644
--- a/modules/blockcategories/blockcategories.php
+++ b/modules/blockcategories/blockcategories.php
@@ -156,7 +156,7 @@ class BlockCategories extends Module
public function hookLeftColumn($params)
{
- $id_current_shop = $this->context->shop->getID();
+ $id_current_shop = $this->context->shop->id;
$id_customer = (int)($params['cookie']->id_customer);
// Get all groups for this customer and concatenate them as a string: "1,2,3..."
@@ -176,7 +176,7 @@ class BlockCategories extends Module
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.$this->context->shop->addSqlRestrictionOnLang('cl').')
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
- LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).')
+ LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.')
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
AND cg.`id_group` IN ('.pSQL($groups).')
@@ -191,7 +191,7 @@ class BlockCategories extends Module
WHERE (c.`active` = 1 OR c.`id_category` = 1)
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
AND cg.`id_group` IN ('.pSQL($groups).')
- AND cs.`id_shop` = '.(int)Context::getContext()->shop->getID(true).'
+ AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
GROUP BY id_category
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC')))
@@ -241,7 +241,7 @@ class BlockCategories extends Module
public function hookFooter($params)
{
- $id_current_shop = $this->context->shop->getID();
+ $id_current_shop = $this->context->shop->id;
$id_customer = (int)($params['cookie']->id_customer);
// Get all groups for this customer and concatenate them as a string: "1,2,3..."
diff --git a/modules/blockcms/BlockCMSModel.php b/modules/blockcms/BlockCMSModel.php
index 6a8b2ad71..5700158fb 100644
--- a/modules/blockcms/BlockCMSModel.php
+++ b/modules/blockcms/BlockCMSModel.php
@@ -258,7 +258,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSTitlesFooter()
{
$context = Context::getContext();
- $footerCms = Configuration::get('FOOTER_CMS', null, $context->shop->getGroupID(), $context->shop->getID());
+ $footerCms = Configuration::get('FOOTER_CMS');
if (empty($footerCms))
return array();
@@ -339,7 +339,7 @@ class BlockCMSModel extends ObjectModel
WHERE bc.`location` = '.(int)($location).'
AND ccl.`id_lang` = '.(int)$context->language->id.'
AND bcl.`id_lang` = '.(int)$context->language->id.'
- AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).'
+ AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY `position`';
return Db::getInstance()->executeS($sql);
@@ -347,7 +347,7 @@ class BlockCMSModel extends ObjectModel
public static function getCMSPages($id_cms_category, $id_shop = false)
{
- $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
+ $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
$sql = 'SELECT c.`id_cms`, cl.`meta_title`, cl.`link_rewrite`
FROM `'._DB_PREFIX_.'cms` c
@@ -467,7 +467,7 @@ class BlockCMSModel extends ObjectModel
WHERE ccl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bcl.`id_lang` = '.(int)Context::getContext()->language->id.'
AND bc.`location` = '.(int)$location.'
- AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->getID()).'
+ AND bcs.id_shop = '.($id_shop ? (int)$id_shop : (int)$context->shop->id).'
ORDER BY bc.`position`';
return Db::getInstance()->executeS($sql);
@@ -493,7 +493,7 @@ class BlockCMSModel extends ObjectModel
public static function getAllCMSStructure($id_shop = false)
{
$categories = BlockCMSModel::getCMSCategories();
- $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->getID();
+ $id_shop = ($id_shop !== false) ? $id_shop : Context::getContext()->shop->id;
foreach ($categories as $key => $value)
$categories[$key]['cms_pages'] = BlockCMSModel::getCMSPages($value['id_cms_category'], $id_shop);
diff --git a/modules/blockcms/blockcms.php b/modules/blockcms/blockcms.php
index 091dd91a4..4d4f22ac2 100755
--- a/modules/blockcms/blockcms.php
+++ b/modules/blockcms/blockcms.php
@@ -55,9 +55,9 @@ class BlockCms extends Module
if (!parent::install() ||
!$this->registerHooks() ||
!BlockCMSModel::createTables() ||
- !Configuration::updateValue('FOOTER_CMS', '', false, $this->context->shop->getGroupID(), $this->context->shop->getID()) ||
- !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID()) ||
- !Configuration::updateValue('FOOTER_POWEREDBY', 1, false, $this->context->shop->getGroupID(), $this->context->shop->getID()))
+ !Configuration::updateValue('FOOTER_CMS', '') ||
+ !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
+ !Configuration::updateValue('FOOTER_POWEREDBY', 1))
return false;
// Install fixtures for blockcms
@@ -244,19 +244,19 @@ class BlockCms extends Module
);
$this->context->controller->getLanguages();
- $tmp = Configuration::get('FOOTER_CMS', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
+ $tmp = Configuration::get('FOOTER_CMS');
$footer_boxes = explode('|', $tmp);
if ($footer_boxes && is_array($footer_boxes))
foreach ($footer_boxes as $key => $value)
$this->fields_value[$value] = true;
- $this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
- $this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY', null, $this->context->shop->getGroupID(), $this->context->shop->getID());
+ $this->fields_value['cms_footer_on'] = Configuration::get('FOOTER_BLOCK_ACTIVATION');
+ $this->fields_value['cms_footer_powered_by_on'] = Configuration::get('FOOTER_POWEREDBY');
foreach ($this->context->controller->_languages as $language)
{
- $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang'], null, $this->context->shop->getGroupID(), $this->context->shop->getID());
+ $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.$language['id_lang']);
$this->fields_value['footer_text'][$language['id_lang']] = $footer_text;
}
@@ -556,7 +556,7 @@ class BlockCms extends Module
foreach ($this->context->controller->_languages as $language)
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
- BlockCMSModel::insertCMSBlockShop($id_cms_block, $this->context->shop->getGroupID(), $this->context->shop->getID());
+ BlockCMSModel::insertCMSBlockShop($id_cms_block, Shop::getContextGroupShopID(), Shop::getContextShopID());
}
$this->_errors[] = $this->l('New block cannot be created !');
@@ -622,9 +622,9 @@ class BlockCms extends Module
$footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : '';
$block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0;
- Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'), false, $this->context->shop->getGroupID(), $this->context->shop->getID());
- Configuration::updateValue('FOOTER_POWEREDBY', $powered_by, false, $this->context->shop->getGroupID(), $this->context->shop->getID());
- Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation, false, $this->context->shop->getGroupID(), $this->context->shop->getID());
+ Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'));
+ Configuration::updateValue('FOOTER_POWEREDBY', $powered_by);
+ Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', $block_activation);
$this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated'));
}
@@ -688,17 +688,14 @@ class BlockCms extends Module
public function hookFooter()
{
- $context = Context::getContext();
- $shop_id = $context->shop->getID();
- $shop_group_id = $context->shop->getGroupID();
- $block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION', null, $shop_group_id, $shop_id);
+ $block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION');
if ($block_activation)
{
$cms_titles = BlockCMSModel::getCMSTitlesFooter();
- $display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER', null, $shop_group_id, $shop_id);
- $display_poweredby = Configuration::get('FOOTER_POWEREDBY', null, $shop_group_id, $shop_id);
- $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$context->language->id);
+ $display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER');
+ $display_poweredby = Configuration::get('FOOTER_POWEREDBY');
+ $footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id);
$this->smarty->assign(
array(
diff --git a/modules/blocklanguages/blocklanguages.php b/modules/blocklanguages/blocklanguages.php
index 794922447..f3d2aa56a 100644
--- a/modules/blocklanguages/blocklanguages.php
+++ b/modules/blocklanguages/blocklanguages.php
@@ -57,7 +57,7 @@ class BlockLanguages extends Module
*/
public function hookTop($params)
{
- $languages = Language::getLanguages(true, $this->context->shop->getID());
+ $languages = Language::getLanguages(true, $this->context->shop->id);
if (!count($languages))
return;
$link = new Link();
diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php
index 30a2b30b2..05af1ba72 100644
--- a/modules/blocklayered/blocklayered.php
+++ b/modules/blocklayered/blocklayered.php
@@ -1327,7 +1327,7 @@ class BlockLayered extends Module
}
}
else
- $shop_list = array(Context::getContext()->shop->getID(true));
+ $shop_list = array(Context::getContext()->shop->id);
}
else
$shop_list = array(0);
@@ -2221,7 +2221,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>'))
{
$queryFiltersWhere .= ' AND sa.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 ';
- $queryFiltersFrom .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)Context::getContext()->shop->getID(true).') ';
+ $queryFiltersFrom .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)Context::getContext()->shop->id.') ';
}
else
$queryFiltersWhere .= ' AND p.quantity '.(!$selectedFilters['quantity'][0] ? '<=' : '>').' 0 ';
@@ -2376,7 +2376,7 @@ class BlockLayered extends Module
$parent = new Category((int)$id_parent);
if (version_compare(_PS_VERSION_,'1.5','>'))
- $id_shop = (int) Context::getContext()->shop->getId(true);
+ $id_shop = (int) Context::getContext()->shop->id;
else
$id_shop = 0;
@@ -2426,7 +2426,7 @@ class BlockLayered extends Module
AND c.active = 1) ';
if (version_compare(_PS_VERSION_,'1.5','>'))
$sqlQuery['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa
- ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->getID(true).') ';
+ ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->id.') ';
$sqlQuery['where'] = 'WHERE p.`active` = 1 ';
$sqlQuery['group'] = ' GROUP BY p.id_product ';
break;
@@ -3176,7 +3176,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>'))
{
$queryFilters = ' AND sav.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 ';
- $queryFiltersJoin = 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.id_product = p.id_product AND sav.id_shop = '.(int)Context::getContext()->shop->getID(true).') ';
+ $queryFiltersJoin = 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.id_product = p.id_product AND sav.id_shop = '.(int)Context::getContext()->shop->id.') ';
}
else
$queryFilters = ' AND p.quantity '.(!$filterValue[0] ? '<=' : '>').' 0 ';
@@ -3543,7 +3543,7 @@ class BlockLayered extends Module
if (version_compare(_PS_VERSION_,'1.5','>') && !empty($id_layered_filter))
{
- if (Shop::isFeatureActive() && $this->context->shop->getContextType() != Shop::CONTEXT_ALL)
+ if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL)
{
$helper = new HelperForm();
$helper->id = (int)$id_layered_filter;
diff --git a/modules/blocknewsletter/blocknewsletter.php b/modules/blocknewsletter/blocknewsletter.php
index b1fd860d0..d542c62f8 100644
--- a/modules/blocknewsletter/blocknewsletter.php
+++ b/modules/blocknewsletter/blocknewsletter.php
@@ -164,7 +164,7 @@ class Blocknewsletter extends Module
$sql = 'SELECT `email`
FROM '._DB_PREFIX_.'newsletter
WHERE `email` = \''.pSQL($customerEmail).'\'
- AND id_shop = '.$this->context->shop->getID(true);
+ AND id_shop = '.$this->context->shop->id;
if (Db::getInstance()->getRow($sql))
return self::GUEST_REGISTERED;
@@ -172,7 +172,7 @@ class Blocknewsletter extends Module
$sql = 'SELECT `newsletter`
FROM '._DB_PREFIX_.'customer
WHERE `email` = \''.pSQL($customerEmail).'\'
- AND id_shop = '.$this->context->shop->getID(true);
+ AND id_shop = '.$this->context->shop->id;
if (!$registered = Db::getInstance()->getRow($sql))
return self::GUEST_NOT_REGISTERED;
@@ -199,13 +199,13 @@ class Blocknewsletter extends Module
return $this->error = $this->l('E-mail address not registered');
else if ($register_status == self::GUEST_REGISTERED)
{
- if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
+ if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->id))
return $this->error = $this->l('Error during unsubscription');
return $this->valid = $this->l('Unsubscription successful');
}
else if ($register_status == self::CUSTOMER_REGISTERED)
{
- if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->getID(true)))
+ if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'customer SET `newsletter` = 0 WHERE `email` = \''.pSQL($_POST['email']).'\' AND id_shop = '.$this->context->shop->id))
return $this->error = $this->l('Error during unsubscription');
return $this->valid = $this->l('Unsubscription successful');
}
@@ -298,7 +298,7 @@ class Blocknewsletter extends Module
$sql = 'UPDATE '._DB_PREFIX_.'customer
SET `newsletter` = 1, newsletter_date_add = NOW(), `ip_registration_newsletter` = \''.pSQL(Tools::getRemoteAddr()).'\'
WHERE `email` = \''.pSQL($email).'\'
- AND id_shop = '.$this->context->shop->getID(true);
+ AND id_shop = '.$this->context->shop->id;
return Db::getInstance()->execute($sql);
}
@@ -314,8 +314,8 @@ class Blocknewsletter extends Module
{
$sql = 'INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_group_shop, email, newsletter_date_add, ip_registration_newsletter, http_referer, active)
VALUES
- ('.$this->context->shop->getID().',
- '.$this->context->shop->getGroupID().',
+ ('.$this->context->shop->id.',
+ '.$this->context->shop->id_group_shop.',
\''.pSQL($email).'\',
NOW(),
\''.pSQL(Tools::getRemoteAddr()).'\',
diff --git a/modules/blockstore/blockstore.php b/modules/blockstore/blockstore.php
index abcd770b6..3fa6bad79 100644
--- a/modules/blockstore/blockstore.php
+++ b/modules/blockstore/blockstore.php
@@ -86,7 +86,7 @@ class BlockStore extends Module
return $this->displayError($this->l('an error occurred on uploading file'));
else
{
- if (Configuration::hasContext('BLOCKSTORE_IMG', null, $this->context->shop->getContextType()) && Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name'])
+ if (Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::getContext()) && Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name'])
@unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG'));
Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']);
return $this->displayConfirmation($this->l('Settings are updated'));
diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php
index d598ab279..a37590cad 100644
--- a/modules/blocktopmenu/blocktopmenu.php
+++ b/modules/blocktopmenu/blocktopmenu.php
@@ -127,7 +127,7 @@ class blocktopmenu extends Module
$this->_html .= '
- '.$this->l('The modifications will be applied to').' '.(Context::shop() == Shop::CONTEXT_SHOP ? $this->l('shop:').' '.$this->context->shop->name : $this->l('all shops')).'.
+ '.$this->l('The modifications will be applied to').' '.(Shop::getContext() == Shop::CONTEXT_SHOP ? $this->l('shop:').' '.$this->context->shop->name : $this->l('all shops')).'.
'.$this->l('Settings').'