From a51c54db26fb3f7ed8ae97858755f30423d3e07e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Sat, 8 Feb 2014 10:35:20 +0100 Subject: [PATCH] x default position value --- core/lib/Thelia/Model/Base/Product.php | 6 ++++++ core/lib/Thelia/Model/Base/ProductVersion.php | 6 ++++++ core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- .../Model/Map/ProductVersionTableMap.php | 2 +- install/thelia.sql | 4 ++-- local/config/schema.xml | 20 +++++++++---------- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 8b1d07a23..9f93f3f3b 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -109,6 +109,7 @@ abstract class Product implements ActiveRecordInterface /** * The value for the position field. + * Note: this column has a database default value of: 0 * @var int */ protected $position; @@ -364,6 +365,7 @@ abstract class Product implements ActiveRecordInterface public function applyDefaultValues() { $this->visible = 0; + $this->position = 0; $this->version = 0; } @@ -1028,6 +1030,10 @@ abstract class Product implements ActiveRecordInterface return false; } + if ($this->position !== 0) { + return false; + } + if ($this->version !== 0) { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php index fec0aefb5..cf5ea8af9 100644 --- a/core/lib/Thelia/Model/Base/ProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -82,6 +82,7 @@ abstract class ProductVersion implements ActiveRecordInterface /** * The value for the position field. + * Note: this column has a database default value of: 0 * @var int */ protected $position; @@ -145,6 +146,7 @@ abstract class ProductVersion implements ActiveRecordInterface public function applyDefaultValues() { $this->visible = 0; + $this->position = 0; $this->version = 0; } @@ -805,6 +807,10 @@ abstract class ProductVersion implements ActiveRecordInterface return false; } + if ($this->position !== 0) { + return false; + } + if ($this->version !== 0) { return false; } diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index 7b96f06b3..daba44213 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -189,7 +189,7 @@ class ProductTableMap extends TableMap $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, 0); $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php index ef72fbee2..e3e36c8be 100644 --- a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php @@ -180,7 +180,7 @@ class ProductVersionTableMap extends TableMap $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, 0); $this->addColumn('TEMPLATE_ID', 'TemplateId', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); diff --git a/install/thelia.sql b/install/thelia.sql index 3ef2e89c2..b4a0c3eb7 100644 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -37,7 +37,7 @@ CREATE TABLE `product` `tax_rule_id` INTEGER, `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, - `position` INTEGER NOT NULL, + `position` INTEGER DEFAULT 0 NOT NULL, `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, @@ -2298,7 +2298,7 @@ CREATE TABLE `product_version` `tax_rule_id` INTEGER, `ref` VARCHAR(255) NOT NULL, `visible` TINYINT DEFAULT 0 NOT NULL, - `position` INTEGER NOT NULL, + `position` INTEGER DEFAULT 0 NOT NULL, `template_id` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, diff --git a/local/config/schema.xml b/local/config/schema.xml index d6613fa1f..a0f2951d2 100644 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,12 +1,12 @@ - - - - - - - - - + + + + + + +
+ + @@ -37,7 +37,7 @@ - +