// Improve multishop API
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13566 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -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 '<div class="preference_default_multishop">
|
||||
<label>
|
||||
<input type="checkbox" name="configUseDefault['.$key.']" value="1" '.(($isDisabled) ? 'checked="checked"' : '').' onclick="checkMultishopDefaultValue(this, \''.$key.'\')" /> '.$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')
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+28
-44
@@ -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;
|
||||
|
||||
|
||||
+2
-2
@@ -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')
|
||||
));
|
||||
|
||||
@@ -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') ||
|
||||
|
||||
+53
-17
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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`
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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'];
|
||||
}
|
||||
|
||||
@@ -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`
|
||||
|
||||
+3
-3
@@ -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,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
+6
-6
@@ -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))
|
||||
|
||||
+4
-4
@@ -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.')').'
|
||||
|
||||
@@ -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).'))';
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+48
-90
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user