diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php
index 9b1710f03..9c3b0759c 100644
--- a/core/lib/Thelia/Model/Base/ProductQuery.php
+++ b/core/lib/Thelia/Model/Base/ProductQuery.php
@@ -857,7 +857,7 @@ abstract class ProductQuery extends ModelCriteria
*
* @return ChildProductQuery The current query, for fluid interface
*/
- public function joinTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinTemplate($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Template');
@@ -892,7 +892,7 @@ abstract class ProductQuery extends ModelCriteria
*
* @return \Thelia\Model\TemplateQuery A secondary query class using the current class as primary query
*/
- public function useTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useTemplateQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinTemplate($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/Base/Template.php b/core/lib/Thelia/Model/Base/Template.php
index 77efa7ba0..08bb0f3a0 100644
--- a/core/lib/Thelia/Model/Base/Template.php
+++ b/core/lib/Thelia/Model/Base/Template.php
@@ -864,9 +864,10 @@ abstract class Template implements ActiveRecordInterface
if ($this->productsScheduledForDeletion !== null) {
if (!$this->productsScheduledForDeletion->isEmpty()) {
- \Thelia\Model\ProductQuery::create()
- ->filterByPrimaryKeys($this->productsScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
+ foreach ($this->productsScheduledForDeletion as $product) {
+ // need to save related object because we set the relation to null
+ $product->save($con);
+ }
$this->productsScheduledForDeletion = null;
}
}
@@ -1553,7 +1554,7 @@ abstract class Template implements ActiveRecordInterface
$this->productsScheduledForDeletion = clone $this->collProducts;
$this->productsScheduledForDeletion->clear();
}
- $this->productsScheduledForDeletion[]= clone $product;
+ $this->productsScheduledForDeletion[]= $product;
$product->setTemplate(null);
}
diff --git a/core/lib/Thelia/Model/Base/TemplateQuery.php b/core/lib/Thelia/Model/Base/TemplateQuery.php
index 506d7d943..98c588dd8 100644
--- a/core/lib/Thelia/Model/Base/TemplateQuery.php
+++ b/core/lib/Thelia/Model/Base/TemplateQuery.php
@@ -395,7 +395,7 @@ abstract class TemplateQuery extends ModelCriteria
*
* @return ChildTemplateQuery The current query, for fluid interface
*/
- public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Product');
@@ -430,7 +430,7 @@ abstract class TemplateQuery extends ModelCriteria
*
* @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
*/
- public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinProduct($relationAlias, $joinType)
diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php
index 91b32eec7..204896674 100755
--- a/core/lib/Thelia/Model/Category.php
+++ b/core/lib/Thelia/Model/Category.php
@@ -69,8 +69,6 @@ class Category extends BaseCategory
{
$this->setPosition($this->getNextPosition());
- $this->generateRewrittenUrl($this->getLocale());
-
$this->dispatchEvent(TheliaEvents::BEFORE_CREATECATEGORY, new CategoryEvent($this));
return true;
@@ -81,6 +79,7 @@ class Category extends BaseCategory
*/
public function postInsert(ConnectionInterface $con = null)
{
+ //$this->generateRewrittenUrl($this->getLocale());
$this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY, new CategoryEvent($this));
}
diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php
index d626bfb10..4d9cf9f3a 100755
--- a/core/lib/Thelia/Model/Content.php
+++ b/core/lib/Thelia/Model/Content.php
@@ -37,8 +37,11 @@ class Content extends BaseContent
{
$this->setPosition($this->getNextPosition());
- $this->generateRewrittenUrl($this->getLocale());
-
return true;
}
+
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ //$this->generateRewrittenUrl($this->getLocale());
+ }
}
diff --git a/core/lib/Thelia/Model/Folder.php b/core/lib/Thelia/Model/Folder.php
index 318edb7ac..e32505d9d 100755
--- a/core/lib/Thelia/Model/Folder.php
+++ b/core/lib/Thelia/Model/Folder.php
@@ -67,8 +67,12 @@ class Folder extends BaseFolder
{
$this->setPosition($this->getNextPosition());
- $this->generateRewrittenUrl($this->getLocale());
return true;
}
+
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ //$this->generateRewrittenUrl($this->getLocale());
+ }
}
diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php
index 17c4585f0..59ac236ac 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->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
- $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null);
+ $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);
$this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php
index 4e84b4db8..14d38a764 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('REF', 'Ref', 'VARCHAR', true, 255, null);
$this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
- $this->addColumn('TEMPLATE_ID', 'TemplateId', 'INTEGER', true, null, null);
+ $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);
$this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php
index 2be99958c..be534298e 100755
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -107,7 +107,7 @@ class Product extends BaseProduct
{
$this->setPosition($this->getNextPosition());
- $this->generateRewrittenUrl($this->getLocale());
+
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
@@ -119,6 +119,7 @@ class Product extends BaseProduct
*/
public function postInsert(ConnectionInterface $con = null)
{
+ //$this->generateRewrittenUrl($this->getLocale());
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
}
diff --git a/install/thelia.sql b/install/thelia.sql
index 3dc5d0454..b49840d9b 100755
--- a/install/thelia.sql
+++ b/install/thelia.sql
@@ -36,7 +36,7 @@ CREATE TABLE `product`
`ref` VARCHAR(255) NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`position` INTEGER NOT NULL,
- `template_id` INTEGER NOT NULL,
+ `template_id` INTEGER,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
@@ -2167,7 +2167,7 @@ CREATE TABLE `product_version`
`ref` VARCHAR(255) NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`position` INTEGER NOT NULL,
- `template_id` INTEGER NOT NULL,
+ `template_id` INTEGER,
`created_at` DATETIME,
`updated_at` DATETIME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