diff --git a/classes/Carrier.php b/classes/Carrier.php index 1f6ae0097..f3d1cad6c 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -110,8 +110,6 @@ class CarrierCore extends ObjectModel /** @var int grade of the shipping delay (0 for longest, 9 for shortest) */ public $grade; - protected $langMultiShop = true; - protected $fieldsRequired = array('name', 'active'); protected $fieldsSize = array('name' => 64, 'grade' => 1); protected $fieldsValidate = array('id_tax_rules_group' => 'isInt', 'name' => 'isCarrierName', 'active' => 'isBool', @@ -126,6 +124,7 @@ class CarrierCore extends ObjectModel 'table' => 'carrier', 'primary' => 'id_carrier', 'multilang' => true, + 'multishop' => true, ); protected static $price_by_weight = array(); diff --git a/classes/Category.php b/classes/Category.php index 061ccc725..c3d554814 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -74,8 +74,6 @@ class CategoryCore extends ObjectModel /** @var string Object last modification date */ public $date_upd; - protected $langMultiShop = true; - public $groupBox; protected static $_links = array(); @@ -107,6 +105,7 @@ class CategoryCore extends ObjectModel 'table' => 'category', 'primary' => 'id_category', 'multilang' => true, + 'multishop' => true, ); /** @var string id_image is the category ID when an image exists and 'default' otherwise */ diff --git a/classes/Meta.php b/classes/Meta.php index f01bae43c..735747a02 100644 --- a/classes/Meta.php +++ b/classes/Meta.php @@ -42,12 +42,11 @@ class MetaCore extends ObjectModel protected $fieldsSizeLang = array('title' => 128, 'description' => 255, 'keywords' => 255, 'url_rewrite' => 255); protected $fieldsValidateLang = array('title' => 'isGenericName', 'description' => 'isGenericName', 'keywords' => 'isGenericName', 'url_rewrite' => 'isLinkRewrite'); - protected $langMultiShop = true; - public static $definition = array( 'table' => 'meta', 'primary' => 'id_meta', 'multilang' => true, + 'multishop' => true, ); public function getFields() diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 9e3ddce63..24ded5b09 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -70,8 +70,6 @@ abstract class ObjectModelCore /** @var array Multilingual fields validity functions for admin panel forms */ protected $fieldsValidateLang = array(); - protected $langMultiShop = false; - /** @var array tables */ protected $tables = array(); @@ -92,6 +90,11 @@ abstract class ObjectModelCore */ public static $definition = array(); + /** + * @var array Contain current object definition + */ + protected $def; + /** * Returns object validation rules (fields validity) * @@ -128,23 +131,23 @@ abstract class ObjectModelCore { // For retrocompatibility, we continue to use $this->table and $this->identifier property. // When all objects will implement $definition static in 1.6, we will remove it. - $definition = self::getDefinition($this); - if (isset($definition['table'])) - $this->table = $definition['table']; - if (isset($definition['primary'])) - $this->identifier = $definition['primary']; + $this->def = self::getDefinition($this); + if (isset($this->def['table'])) + $this->table = $this->def['table']; + if (isset($this->def['primary'])) + $this->identifier = $this->def['primary']; if (!is_null($id_lang)) $this->id_lang = (Language::getLanguage($id_lang) !== false) ? $id_lang : Configuration::get('PS_LANG_DEFAULT'); - if ($id_shop && $this->langMultiShop) + if ($id_shop && $this->isLangMultishop()) { $this->id_shop = (int)$id_shop; $this->getShopFromContext = false; } - if ($this->langMultiShop && !$this->id_shop) + if ($this->isLangMultishop() && !$this->id_shop) $this->id_shop = Context::getContext()->shop->getID(true); if (!Validate::isTableOrIdentifier($this->identifier) || !Validate::isTableOrIdentifier($this->table)) @@ -326,7 +329,7 @@ abstract class ObjectModelCore throw new PrestashopException('key '.$key.' is not a valid table or identifier'); // If this table is linked to multishop system, update / insert for all shops from context - if ($this->langMultiShop) + if ($this->isLangMultishop()) { $listShops = ($this->id_shop && !$this->getShopFromContext) ? array($this->id_shop) : Context::getContext()->shop->getListOfID(); foreach ($listShops as $shop) @@ -469,7 +472,7 @@ abstract class ObjectModelCore { $fields[$id_language]['id_lang'] = $id_language; $fields[$id_language][$this->identifier] = (int)($this->id); - if ($this->id_shop AND $this->langMultiShop) + if ($this->id_shop && $this->isLangMultishop()) $fields[$id_language]['id_shop'] = (int)$this->id_shop; foreach ($fieldsArray as $k => $field) { @@ -908,7 +911,7 @@ abstract class ObjectModelCore public function isLangMultishop() { - return (int)$this->langMultiShop; + return isset($this->def['multishop']) && $this->def['multishop'] && isset($this->def['multilang']) && $this->def['multilang']; } /** diff --git a/classes/Product.php b/classes/Product.php index 625617a39..e79d9eb11 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -190,8 +190,6 @@ class ProductCore extends ObjectModel public $isFullyLoaded = false; - protected $langMultiShop = true; - public $cache_is_pack; public $cache_has_attachments; public $is_virtual; @@ -265,6 +263,7 @@ class ProductCore extends ObjectModel 'table' => 'product', 'primary' => 'id_product', 'multilang' => true, + 'multishop' => true, ); protected $webserviceParameters = array(