From 233caca6e6111d02e6365f50973dcd3981fd68df Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 21 May 2012 18:57:51 +0000 Subject: [PATCH] // Fix default context in shop git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15576 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/shop/Shop.php | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/classes/shop/Shop.php b/classes/shop/Shop.php index 2be28a2a5..fa7dccbc2 100644 --- a/classes/shop/Shop.php +++ b/classes/shop/Shop.php @@ -651,30 +651,36 @@ class ShopCore extends ObjectModel { // Always use global context for mono-shop mode if (!Shop::isFeatureActive()) - $type = self::CONTEXT_ALL; - - switch ($type) { - case self::CONTEXT_ALL : - self::$context_id_shop = null; - self::$context_id_shop_group = null; - break; - - case self::CONTEXT_GROUP : - self::$context_id_shop = null; - self::$context_id_shop_group = (int)$id; - break; - - case self::CONTEXT_SHOP : - self::$context_id_shop = (int)$id; - self::$context_id_shop_group = Shop::getGroupFromShop($id); - break; - - default : - throw new PrestaShopException('Unknown context for shop'); + self::$context_id_shop = (int)Context::getContext()->shop->id; + self::$context_id_shop_group = (int)Context::getContext()->shop->id_shop_group; + self::$context = self::CONTEXT_ALL; } + else + { + switch ($type) + { + case self::CONTEXT_ALL : + self::$context_id_shop = null; + self::$context_id_shop_group = null; + break; - self::$context = $type; + case self::CONTEXT_GROUP : + self::$context_id_shop = null; + self::$context_id_shop_group = (int)$id; + break; + + case self::CONTEXT_SHOP : + self::$context_id_shop = (int)$id; + self::$context_id_shop_group = Shop::getGroupFromShop($id); + break; + + default : + throw new PrestaShopException('Unknown context for shop'); + } + + self::$context = $type; + } } public static function getContext() @@ -700,8 +706,6 @@ class ShopCore extends ObjectModel */ public static function addSqlRestriction($share = false, $alias = null) { - if (!Shop::isFeatureActive()) - return; if ($alias) $alias .= '.'; @@ -747,8 +751,6 @@ class ShopCore extends ObjectModel */ public static function addSqlRestrictionOnLang($alias = null, $id_shop = null) { - if (!Shop::isFeatureActive()) - return; if (is_null($id_shop)) $id_shop = Context::getContext()->shop->id; return ' AND '.(($alias) ? $alias.'.' : '').'id_shop = '.$id_shop.' ';