Пример #1
0
 /**
  * Change the current shop context
  *
  * @param int $type Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP
  * @param int $id ID shop if CONTEXT_SHOP or id shop group if CONTEXT_GROUP
  */
 public static function setContext($type, $id = null)
 {
     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 = $type;
 }
Пример #2
0
 /**
  * Change the current shop context
  *
  * @param int $type Shop::CONTEXT_ALL | Shop::CONTEXT_GROUP | Shop::CONTEXT_SHOP
  * @param int $id ID shop if CONTEXT_SHOP or id shop group if CONTEXT_GROUP
  */
 public static function setContext($type, $id = null)
 {
     // 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 = $type;
 }