+ * $query->filterByIsDefault(true); // WHERE is_default = true
+ * $query->filterByIsDefault('yes'); // WHERE is_default = true
+ *
+ *
+ * @param boolean|string $isDefault The value to use as filter.
+ * Non-boolean arguments are converted using the following rules:
+ * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
+ * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
+ * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByIsDefault($isDefault = null, $comparison = null)
+ {
+ if (is_string($isDefault)) {
+ $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ }
+
+ return $this->addUsingAlias(TaxTableMap::IS_DEFAULT, $isDefault, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
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 042864de0..204896674 100755
--- a/core/lib/Thelia/Model/Category.php
+++ b/core/lib/Thelia/Model/Category.php
@@ -28,7 +28,7 @@ class Category extends BaseCategory
/**
* {@inheritDoc}
*/
- protected function getRewritenUrlViewName() {
+ protected function getRewrittenUrlViewName() {
return 'category';
}
@@ -69,8 +69,6 @@ class Category extends BaseCategory
{
$this->setPosition($this->getNextPosition());
- $this->generateRewritenUrl($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 79660f93a..4d9cf9f3a 100755
--- a/core/lib/Thelia/Model/Content.php
+++ b/core/lib/Thelia/Model/Content.php
@@ -17,7 +17,7 @@ class Content extends BaseContent
/**
* {@inheritDoc}
*/
- protected function getRewritenUrlViewName() {
+ protected function getRewrittenUrlViewName() {
return 'content';
}
@@ -37,8 +37,11 @@ class Content extends BaseContent
{
$this->setPosition($this->getNextPosition());
- $this->generateRewritenUrl($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 1e73e7e23..e32505d9d 100755
--- a/core/lib/Thelia/Model/Folder.php
+++ b/core/lib/Thelia/Model/Folder.php
@@ -17,7 +17,7 @@ class Folder extends BaseFolder
/**
* {@inheritDoc}
*/
- protected function getRewritenUrlViewName() {
+ protected function getRewrittenUrlViewName() {
return 'folder';
}
@@ -67,8 +67,12 @@ class Folder extends BaseFolder
{
$this->setPosition($this->getNextPosition());
- $this->generateRewritenUrl($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/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php
index 6ca89ae85..eebde0ca0 100644
--- a/core/lib/Thelia/Model/Map/TaxTableMap.php
+++ b/core/lib/Thelia/Model/Map/TaxTableMap.php
@@ -57,7 +57,7 @@ class TaxTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 5;
+ const NUM_COLUMNS = 6;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class TaxTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 5;
+ const NUM_HYDRATE_COLUMNS = 6;
/**
* the column name for the ID field
@@ -84,6 +84,11 @@ class TaxTableMap extends TableMap
*/
const SERIALIZED_REQUIREMENTS = 'tax.SERIALIZED_REQUIREMENTS';
+ /**
+ * the column name for the IS_DEFAULT field
+ */
+ const IS_DEFAULT = 'tax.IS_DEFAULT';
+
/**
* the column name for the CREATED_AT field
*/
@@ -115,12 +120,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'isDefault', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::IS_DEFAULT, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'is_default', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -130,12 +135,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
- self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::CREATED_AT => 3, TaxTableMap::UPDATED_AT => 4, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'created_at' => 3, 'updated_at' => 4, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'IsDefault' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'isDefault' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::IS_DEFAULT => 3, TaxTableMap::CREATED_AT => 4, TaxTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'IS_DEFAULT' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'is_default' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -157,6 +162,7 @@ class TaxTableMap extends TableMap
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
$this->addColumn('SERIALIZED_REQUIREMENTS', 'SerializedRequirements', 'LONGVARCHAR', true, null, null);
+ $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -335,12 +341,14 @@ class TaxTableMap extends TableMap
$criteria->addSelectColumn(TaxTableMap::ID);
$criteria->addSelectColumn(TaxTableMap::TYPE);
$criteria->addSelectColumn(TaxTableMap::SERIALIZED_REQUIREMENTS);
+ $criteria->addSelectColumn(TaxTableMap::IS_DEFAULT);
$criteria->addSelectColumn(TaxTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.SERIALIZED_REQUIREMENTS');
+ $criteria->addSelectColumn($alias . '.IS_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php
index ef000e820..13600351a 100755
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -21,12 +21,10 @@ class Product extends BaseProduct
use \Thelia\Model\Tools\UrlRewritingTrait;
- protected $defaultCategory = null;
-
/**
* {@inheritDoc}
*/
- protected function getRewritenUrlViewName() {
+ protected function getRewrittenUrlViewName() {
return 'product';
}
@@ -45,7 +43,8 @@ class Product extends BaseProduct
public function getTaxedPrice(Country $country)
{
$taxCalculator = new Calculator();
- return round($taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()), 2);
+
+ return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice());
}
/**
@@ -99,10 +98,12 @@ class Product extends BaseProduct
$con->beginTransaction();
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
+
try {
// Create the product
$this->save($con);
-
+echo "1";
// Add the default category
$pc = new ProductCategory();
@@ -113,13 +114,44 @@ class Product extends BaseProduct
->save($con)
;
+ // Set the position
+ $this->setPosition($this->getNextPosition())->save($con);
+ echo "2";
+ // Create an empty product sale element
+ $sale_elements = new ProductSaleElements();
+
+ $sale_elements
+ ->setProduct($this)
+ ->setRef('')
+ ->setPromo(0)
+ ->setNewness(0)
+ ->setWeight(0)
+ ->save($con)
+ ;
+ echo "3";
+ // Create an empty product price in the default currency
+ $product_price = new ProductPrice();
+
+ $product_price
+ ->setProductSaleElements($sale_elements)
+ ->setPromoPrice(0)
+ ->setPrice(0)
+ ->setCurrency(CurrencyQuery::create()->findByByDefault(true))
+ ->save($con)
+ ;
+ echo "4";
// Store all the stuff !
$con->commit();
+echo "commited !!!: ".$this->getId();
+
+
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
}
catch(PropelException $ex) {
$con->rollback();
-
+echo("error !");
+exit;
throw $ex;
}
}
@@ -140,30 +172,6 @@ class Product extends BaseProduct
if ($produits != null) $query->filterById($produits, Criteria::IN);
}
- /**
- * {@inheritDoc}
- */
- public function preInsert(ConnectionInterface $con = null)
- {
- $this->generateRewritenUrl($this->getLocale());
-
- $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT, new ProductEvent($this));
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public function postInsert(ConnectionInterface $con = null)
- {
- $this->setPosition($this->getNextPosition());
-
- $this->save();
-
- $this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
- }
-
/**
* {@inheritDoc}
*/
@@ -199,5 +207,4 @@ class Product extends BaseProduct
{
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
}
-
}
diff --git a/core/lib/Thelia/Model/Rewriting.php b/core/lib/Thelia/Model/Rewriting.php
deleted file mode 100644
index 8d6f75fab..000000000
--- a/core/lib/Thelia/Model/Rewriting.php
+++ /dev/null
@@ -1,9 +0,0 @@
-getRedirected()) {
+ //check if rewriting url alredy exists and put redirect to the new one
+ RewritingUrlQuery::create()
+ ->filterByView($this->getView())
+ ->filterByViewId($this->getViewId())
+ ->filterByViewLocale($this->getViewLocale())
+ ->filterByRedirected($this->getId(), Criteria::NOT_IN)
+ ->update(array(
+ "Redirected" => $this->getId()
+ ));
+ }
+ }
}
diff --git a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php
index 6ab24fbc4..1b9087626 100644
--- a/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php
+++ b/core/lib/Thelia/Model/Tools/UrlRewritingTrait.php
@@ -23,6 +23,9 @@
namespace Thelia\Model\Tools;
+use Thelia\Exception\UrlRewritingException;
+use Thelia\Model\RewritingUrlQuery;
+use Thelia\Model\RewritingUrl;
use Thelia\Tools\URL;
/**
* A trait for managing Rewriten URLs from model classes
@@ -32,7 +35,7 @@ trait UrlRewritingTrait {
/**
* @returns string the view name of the rewriten object (e.g., 'category', 'product')
*/
- protected abstract function getRewritenUrlViewName();
+ protected abstract function getRewrittenUrlViewName();
/**
* Get the object URL for the given locale, rewriten if rewriting is enabled.
@@ -41,7 +44,7 @@ trait UrlRewritingTrait {
*/
public function getUrl($locale)
{
- return URL::getInstance()->retrieve($this->getRewritenUrlViewName(), $this->getId(), $locale)->toString();
+ return URL::getInstance()->retrieve($this->getRewrittenUrlViewName(), $this->getId(), $locale)->toString();
}
/**
@@ -49,27 +52,79 @@ trait UrlRewritingTrait {
*
* @param string $locale a valid locale (e.g. en_US)
*/
- public function generateRewritenUrl($locale)
+ public function generateRewrittenUrl($locale)
{
- URL::getInstance()->generateRewritenUrl($this->getRewritenUrlViewName(), $this->getId(), $locale, $this->getTitle());
+ if ($this->isNew()) {
+ throw new \RuntimeException(sprintf('Object %s must be saved before generating url', $this->getRewrittenUrlViewName()));
+ }
+ // Borrowed from http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe
+
+ $this->setLocale($locale);
+
+ $title = $this->getTitle() ?: $this->getRef();
+ // Replace all weird characters with dashes
+ $string = preg_replace('/[^\w\-~_\.]+/u', '-', $title);
+
+ // Only allow one dash separator at a time (and make string lowercase)
+ $cleanString = mb_strtolower(preg_replace('/--+/u', '-', $string), 'UTF-8');
+
+ $urlFilePart = $cleanString . ".html";
+
+ // TODO :
+ // check if URL url already exists, and add a numeric suffix, or the like
+ try{
+ $i=0;
+ while(URL::getInstance()->resolve($urlFilePart)) {
+ $i++;
+ $urlFilePart = sprintf("%s-%d.html",$cleanString, $i);
+ }
+ } catch (UrlRewritingException $e) {
+ $rewritingUrl = new RewritingUrl();
+ $rewritingUrl->setUrl($urlFilePart)
+ ->setView($this->getRewrittenUrlViewName())
+ ->setViewId($this->getId())
+ ->setViewLocale($locale)
+ ->save()
+ ;
+ }
+
+ return $urlFilePart;
+
}
/**
* return the rewriten URL for the given locale
*
* @param string $locale a valid locale (e.g. en_US)
+ * @return null
*/
- public function getRewritenUrl($locale)
+ public function getRewrittenUrl($locale)
{
- return "fake url - TODO";
+ $rewritingUrl = RewritingUrlQuery::create()
+ ->filterByViewLocale($locale)
+ ->filterByView($this->getRewrittenUrlViewName())
+ ->filterByViewId($this->getId())
+ ->filterByRedirected(0)
+ ->findOne()
+ ;
+
+ if($rewritingUrl) {
+ $url = $rewritingUrl->getUrl();
+ } else {
+ $url = null;
+ }
+
+ return $url;
}
/**
* Set the rewriten URL for the given locale
*
* @param string $locale a valid locale (e.g. en_US)
+ * @param $url the wanted url
+ * @return $this
*/
- public function setRewritenUrl($locale, $url)
+ public function setRewrittenUrl($locale, $url)
{
// TODO - code me !
diff --git a/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php
new file mode 100644
index 000000000..c38773814
--- /dev/null
+++ b/core/lib/Thelia/Tests/Rewriting/ProductRewriteTest.php
@@ -0,0 +1,88 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Tests\Rewriting;
+use Thelia\Model\Product;
+use Thelia\Model\ProductQuery;
+
+
+/**
+ * Class ProductRewriteTest
+ * @package Thelia\Tests\Rewriting
+ * @author Manuel Raynaud | - {admin_sortable_header - current_order=$category_order - order='id' - reverse_order='id_reverse' - path={url path='/admin/categories' id_category=$category_id} - request_parameter_name='category_order' - label="{intl l='ID'}" - } - | + {ifloop rel="category_list"} + +|||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| + {admin_sortable_header + current_order=$category_order + order='id' + reverse_order='id_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='ID'}" + } + | -+ | - | - {admin_sortable_header - current_order=$category_order - order='alpha' - reverse_order='alpha_reverse' - path={url path='/admin/categories' id_category=$category_id} - request_parameter_name='category_order' - label="{intl l='Category title'}" - } - | ++ {admin_sortable_header + current_order=$category_order + order='alpha' + reverse_order='alpha_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Category title'}" + } + | - {module_include location='category_list_header'} + {module_include location='category_list_header'} -- {admin_sortable_header - current_order=$category_order - order='visible' - reverse_order='visible_reverse' - path={url path='/admin/categories' id_category=$category_id} - request_parameter_name='category_order' - label="{intl l='Online'}" - } - | ++ {admin_sortable_header + current_order=$category_order + order='visible' + reverse_order='visible_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Online'}" + } + | -- {admin_sortable_header - current_order=$category_order - order='manual' - reverse_order='manual_reverse' - path={url path='/admin/categories' id_category=$category_id} - request_parameter_name='category_order' - label="{intl l='Position'}" - } - | ++ {admin_sortable_header + current_order=$category_order + order='manual' + reverse_order='manual_reverse' + path={url path='/admin/categories' id_category=$category_id} + request_parameter_name='category_order' + label="{intl l='Position'}" + } + | -{intl l='Actions'} | -{intl l='Actions'} | +|
| {$ID} | +|||||||||||
| {$ID} | -
- {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
- |
+
+ {loop type="image" name="cat_image" source="category" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
+ |
- - - {$TITLE} - - | ++ + {$TITLE} + + | - {module_include location='category_list_row'} + {module_include location='category_list_row'} -
- {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
-
-
-
- {/loop}
+ |
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
+
+
+
+ {/loop}
- {elseloop rel="can_change"}
-
-
-
- {/elseloop}
- |
+ {elseloop rel="can_change"}
+ - {admin_position_block - permission="admin.categories.edit" - path={url path='admin/categories/update-position' category_id=$ID} - url_parameter="category_id" - in_place_edit_class="categoryPositionChange" - position=$POSITION - id=$ID - } - | ++ {admin_position_block + permission="admin.categories.edit" + path={url path='admin/categories/update-position' category_id=$ID} + url_parameter="category_id" + in_place_edit_class="categoryPositionChange" + position=$POSITION + id=$ID + } + | -
-
-
+
+ |
-
+
- {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
-
- {/loop}
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.categories.edit"}
+
+ {/loop}
- {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.categories.delete"}
-
- {/loop}
-
- | |
- {admin_sortable_header
- current_order=$product_order
- order='id'
- reverse_order='id_reverse'
- path={url path='/admin/categories' id_category=$category_id target='products'}
- label="{intl l='ID'}"
- }
+ {ifloop rel="product_list"}
+
+ |
+ {admin_sortable_header
+ current_order=$product_order
+ order='id'
+ reverse_order='id_reverse'
+ path={url path='/admin/categories' id_category=$category_id target='products'}
+ label="{intl l='ID'}"
+ }
- | |
+ |
-
- {admin_sortable_header
- current_order=$product_order
- order='ref'
- reverse_order='ref_reverse'
- path={url path='/admin/categories' id_category=$category_id target='products'}
- label="{intl l='Reference'}"
- }
- |
+
+ {admin_sortable_header
+ current_order=$product_order
+ order='ref'
+ reverse_order='ref_reverse'
+ path={url path='/admin/categories' id_category=$category_id target='products'}
+ label="{intl l='Reference'}"
+ }
+ |
-
- {admin_sortable_header
- current_order=$product_order
- order='alpha'
- reverse_order='alpha_reverse'
- path={url path='/admin/categories' id_category=$category_id target='products'}
- label="{intl l='Product title'}"
- }
+ |
+ {admin_sortable_header
+ current_order=$product_order
+ order='alpha'
+ reverse_order='alpha_reverse'
+ path={url path='/admin/categories' id_category=$category_id target='products'}
+ label="{intl l='Product title'}"
+ }
- {module_include location='product_list_header'}
+ {module_include location='product_list_header'}
- |
- {admin_sortable_header
- current_order=$product_order
- order='visible'
- reverse_order='visible_reverse'
- path={url path='/admin/categories' id_category=$category_id target='products'}
- label="{intl l='Online'}"
- }
- |
+
+ {admin_sortable_header
+ current_order=$product_order
+ order='visible'
+ reverse_order='visible_reverse'
+ path={url path='/admin/categories' id_category=$category_id target='products'}
+ label="{intl l='Online'}"
+ }
+ |
-
- {admin_sortable_header
- current_order=$product_order
- order='manual'
- reverse_order='manual_reverse'
- path={url path='/admin/categories' id_category=$category_id target='products'}
- label="{intl l='Position'}"
- }
- |
+
+ {admin_sortable_header
+ current_order=$product_order
+ order='manual'
+ reverse_order='manual_reverse'
+ path={url path='/admin/categories' id_category=$category_id target='products'}
+ label="{intl l='Position'}"
+ }
+ |
- |
- | + |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {$ID} | +|||||||||||||
| {$ID} | -
- {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
-
- |
+ {loop type="image" name="cat_image" source="product" source_id="$ID" limit="1" width="50" height="50" resize_mode="crop" backend_context="1"}
+
+ | {$REF} | +{$REF} | -{$TITLE} | +{$TITLE} | - {module_include location='product_list_row'} + {module_include location='product_list_row'} -
- {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
-
-
-
- {/loop}
+ |
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.products.edit"}
+
+
+
+ {/loop}
- {elseloop rel="can_delete"}
-
-
-
- {/elseloop}
- |
+ {elseloop rel="can_change"}
+ - {admin_position_block - permission="admin.product.edit" - path={url path='admin/product' category_id=$ID} - url_parameter="product_id" - in_place_edit_class="productPositionChange" - position=$POSITION - id=$ID - } - | ++ {admin_position_block + permission="admin.product.edit" + path={url path='/admin/products/update-position' product_id=$ID} + url_parameter="product_id" + in_place_edit_class="productPositionChange" + position=$POSITION + id=$ID + } + | -- | ||