template is not mandatory in product table.

This commit is contained in:
Manuel Raynaud
2013-09-17 19:19:52 +02:00
parent 9020de5b9a
commit e1e383707b
11 changed files with 1225 additions and 1217 deletions

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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));
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));
}

View File

@@ -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,
`version` INTEGER DEFAULT 0 NOT NULL,

View File

@@ -28,7 +28,7 @@
<column name="description" type="CLOB" />
<column name="chapo" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<column name="template_id" type="INTEGER" />
<foreign-key foreignTable="tax_rule" name="fk_product_tax_rule_id" onDelete="SET NULL" onUpdate="RESTRICT">
<reference foreign="id" local="tax_rule_id" />
</foreign-key>