// Fix context in multishop
This commit is contained in:
1 parent
3ef2627ad7
commit
9d0f116680
1 file changed
+22
-28
+22
-28
@@ -660,36 +660,30 @@ class ShopCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
// Always use global context for mono-shop mode
|
// Always use global context for mono-shop mode
|
||||||
if (!Shop::isFeatureActive())
|
if (!Shop::isFeatureActive())
|
||||||
|
$type = self::CONTEXT_ALL;
|
||||||
|
|
||||||
|
switch ($type)
|
||||||
{
|
{
|
||||||
self::$context_id_shop = (int)Context::getContext()->shop->id;
|
case self::CONTEXT_ALL :
|
||||||
self::$context_id_shop_group = (int)Context::getContext()->shop->id_shop_group;
|
self::$context_id_shop = null;
|
||||||
self::$context = self::CONTEXT_ALL;
|
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');
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
switch ($type)
|
|
||||||
{
|
|
||||||
case self::CONTEXT_ALL :
|
|
||||||
self::$context_id_shop = null;
|
|
||||||
self::$context_id_shop_group = null;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::CONTEXT_GROUP :
|
self::$context = $type;
|
||||||
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()
|
public static function getContext()
|
||||||
@@ -718,7 +712,7 @@ class ShopCore extends ObjectModel
|
|||||||
if ($alias)
|
if ($alias)
|
||||||
$alias .= '.';
|
$alias .= '.';
|
||||||
|
|
||||||
if ($share == Shop::SHARE_CUSTOMER)
|
if ($share == Shop::SHARE_CUSTOMER && Shop::getContext() == Shop::CONTEXT_SHOP)
|
||||||
$restriction = ' AND '.$alias.'id_shop_group = '.(int)Shop::getContextShopGroupID();
|
$restriction = ' AND '.$alias.'id_shop_group = '.(int)Shop::getContextShopGroupID();
|
||||||
else
|
else
|
||||||
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', Shop::getContextListShopID($share)).') ';
|
$restriction = ' AND '.$alias.'id_shop IN ('.implode(', ', Shop::getContextListShopID($share)).') ';
|
||||||
|
|||||||
Reference in new issue
Block a user