+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeTemplateQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_templatecol column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeTemplatecol('fooValue'); // WHERE attribute_templatecol = 'fooValue'
+ * $query->filterByAttributeTemplatecol('%fooValue%'); // WHERE attribute_templatecol LIKE '%fooValue%'
+ *
+ *
+ * @param string $attributeTemplatecol The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeTemplateQuery The current query, for fluid interface
+ */
+ public function filterByAttributeTemplatecol($attributeTemplatecol = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($attributeTemplatecol)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $attributeTemplatecol)) {
+ $attributeTemplatecol = str_replace('*', '%', $attributeTemplatecol);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL, $attributeTemplatecol, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
diff --git a/core/lib/Thelia/Model/Base/FeatureProduct.php b/core/lib/Thelia/Model/Base/FeatureProduct.php
index 4af200d51..039967cee 100644
--- a/core/lib/Thelia/Model/Base/FeatureProduct.php
+++ b/core/lib/Thelia/Model/Base/FeatureProduct.php
@@ -85,10 +85,10 @@ abstract class FeatureProduct implements ActiveRecordInterface
protected $feature_av_id;
/**
- * The value for the by_default field.
+ * The value for the free_text_value field.
* @var string
*/
- protected $by_default;
+ protected $free_text_value;
/**
* The value for the position field.
@@ -430,14 +430,14 @@ abstract class FeatureProduct implements ActiveRecordInterface
}
/**
- * Get the [by_default] column value.
+ * Get the [free_text_value] column value.
*
* @return string
*/
- public function getByDefault()
+ public function getFreeTextValue()
{
- return $this->by_default;
+ return $this->free_text_value;
}
/**
@@ -588,25 +588,25 @@ abstract class FeatureProduct implements ActiveRecordInterface
} // setFeatureAvId()
/**
- * Set the value of [by_default] column.
+ * Set the value of [free_text_value] column.
*
* @param string $v new value
* @return \Thelia\Model\FeatureProduct The current object (for fluent API support)
*/
- public function setByDefault($v)
+ public function setFreeTextValue($v)
{
if ($v !== null) {
$v = (string) $v;
}
- if ($this->by_default !== $v) {
- $this->by_default = $v;
- $this->modifiedColumns[] = FeatureProductTableMap::BY_DEFAULT;
+ if ($this->free_text_value !== $v) {
+ $this->free_text_value = $v;
+ $this->modifiedColumns[] = FeatureProductTableMap::FREE_TEXT_VALUE;
}
return $this;
- } // setByDefault()
+ } // setFreeTextValue()
/**
* Set the value of [position] column.
@@ -720,8 +720,8 @@ abstract class FeatureProduct implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureProductTableMap::translateFieldName('FeatureAvId', TableMap::TYPE_PHPNAME, $indexType)];
$this->feature_av_id = (null !== $col) ? (int) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
- $this->by_default = (null !== $col) ? (string) $col : null;
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('FreeTextValue', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->free_text_value = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
$this->position = (null !== $col) ? (int) $col : null;
@@ -1015,8 +1015,8 @@ abstract class FeatureProduct implements ActiveRecordInterface
if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) {
$modifiedColumns[':p' . $index++] = 'FEATURE_AV_ID';
}
- if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) {
- $modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
+ if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'FREE_TEXT_VALUE';
}
if ($this->isColumnModified(FeatureProductTableMap::POSITION)) {
$modifiedColumns[':p' . $index++] = 'POSITION';
@@ -1050,8 +1050,8 @@ abstract class FeatureProduct implements ActiveRecordInterface
case 'FEATURE_AV_ID':
$stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT);
break;
- case 'BY_DEFAULT':
- $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR);
+ case 'FREE_TEXT_VALUE':
+ $stmt->bindValue($identifier, $this->free_text_value, PDO::PARAM_STR);
break;
case 'POSITION':
$stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
@@ -1137,7 +1137,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
return $this->getFeatureAvId();
break;
case 4:
- return $this->getByDefault();
+ return $this->getFreeTextValue();
break;
case 5:
return $this->getPosition();
@@ -1181,7 +1181,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
$keys[1] => $this->getProductId(),
$keys[2] => $this->getFeatureId(),
$keys[3] => $this->getFeatureAvId(),
- $keys[4] => $this->getByDefault(),
+ $keys[4] => $this->getFreeTextValue(),
$keys[5] => $this->getPosition(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
@@ -1249,7 +1249,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
$this->setFeatureAvId($value);
break;
case 4:
- $this->setByDefault($value);
+ $this->setFreeTextValue($value);
break;
case 5:
$this->setPosition($value);
@@ -1288,7 +1288,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]);
- if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]);
+ if (array_key_exists($keys[4], $arr)) $this->setFreeTextValue($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
@@ -1307,7 +1307,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
if ($this->isColumnModified(FeatureProductTableMap::PRODUCT_ID)) $criteria->add(FeatureProductTableMap::PRODUCT_ID, $this->product_id);
if ($this->isColumnModified(FeatureProductTableMap::FEATURE_ID)) $criteria->add(FeatureProductTableMap::FEATURE_ID, $this->feature_id);
if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) $criteria->add(FeatureProductTableMap::FEATURE_AV_ID, $this->feature_av_id);
- if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) $criteria->add(FeatureProductTableMap::BY_DEFAULT, $this->by_default);
+ if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) $criteria->add(FeatureProductTableMap::FREE_TEXT_VALUE, $this->free_text_value);
if ($this->isColumnModified(FeatureProductTableMap::POSITION)) $criteria->add(FeatureProductTableMap::POSITION, $this->position);
if ($this->isColumnModified(FeatureProductTableMap::CREATED_AT)) $criteria->add(FeatureProductTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(FeatureProductTableMap::UPDATED_AT)) $criteria->add(FeatureProductTableMap::UPDATED_AT, $this->updated_at);
@@ -1377,7 +1377,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
$copyObj->setProductId($this->getProductId());
$copyObj->setFeatureId($this->getFeatureId());
$copyObj->setFeatureAvId($this->getFeatureAvId());
- $copyObj->setByDefault($this->getByDefault());
+ $copyObj->setFreeTextValue($this->getFreeTextValue());
$copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1571,7 +1571,7 @@ abstract class FeatureProduct implements ActiveRecordInterface
$this->product_id = null;
$this->feature_id = null;
$this->feature_av_id = null;
- $this->by_default = null;
+ $this->free_text_value = null;
$this->position = null;
$this->created_at = null;
$this->updated_at = null;
diff --git a/core/lib/Thelia/Model/Base/FeatureProductQuery.php b/core/lib/Thelia/Model/Base/FeatureProductQuery.php
index c6a8f2a73..eb2ee7ec1 100644
--- a/core/lib/Thelia/Model/Base/FeatureProductQuery.php
+++ b/core/lib/Thelia/Model/Base/FeatureProductQuery.php
@@ -25,7 +25,7 @@ use Thelia\Model\Map\FeatureProductTableMap;
* @method ChildFeatureProductQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
* @method ChildFeatureProductQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column
* @method ChildFeatureProductQuery orderByFeatureAvId($order = Criteria::ASC) Order by the feature_av_id column
- * @method ChildFeatureProductQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
+ * @method ChildFeatureProductQuery orderByFreeTextValue($order = Criteria::ASC) Order by the free_text_value column
* @method ChildFeatureProductQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildFeatureProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildFeatureProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
@@ -34,7 +34,7 @@ use Thelia\Model\Map\FeatureProductTableMap;
* @method ChildFeatureProductQuery groupByProductId() Group by the product_id column
* @method ChildFeatureProductQuery groupByFeatureId() Group by the feature_id column
* @method ChildFeatureProductQuery groupByFeatureAvId() Group by the feature_av_id column
- * @method ChildFeatureProductQuery groupByByDefault() Group by the by_default column
+ * @method ChildFeatureProductQuery groupByFreeTextValue() Group by the free_text_value column
* @method ChildFeatureProductQuery groupByPosition() Group by the position column
* @method ChildFeatureProductQuery groupByCreatedAt() Group by the created_at column
* @method ChildFeatureProductQuery groupByUpdatedAt() Group by the updated_at column
@@ -62,7 +62,7 @@ use Thelia\Model\Map\FeatureProductTableMap;
* @method ChildFeatureProduct findOneByProductId(int $product_id) Return the first ChildFeatureProduct filtered by the product_id column
* @method ChildFeatureProduct findOneByFeatureId(int $feature_id) Return the first ChildFeatureProduct filtered by the feature_id column
* @method ChildFeatureProduct findOneByFeatureAvId(int $feature_av_id) Return the first ChildFeatureProduct filtered by the feature_av_id column
- * @method ChildFeatureProduct findOneByByDefault(string $by_default) Return the first ChildFeatureProduct filtered by the by_default column
+ * @method ChildFeatureProduct findOneByFreeTextValue(string $free_text_value) Return the first ChildFeatureProduct filtered by the free_text_value column
* @method ChildFeatureProduct findOneByPosition(int $position) Return the first ChildFeatureProduct filtered by the position column
* @method ChildFeatureProduct findOneByCreatedAt(string $created_at) Return the first ChildFeatureProduct filtered by the created_at column
* @method ChildFeatureProduct findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureProduct filtered by the updated_at column
@@ -71,7 +71,7 @@ use Thelia\Model\Map\FeatureProductTableMap;
* @method array findByProductId(int $product_id) Return ChildFeatureProduct objects filtered by the product_id column
* @method array findByFeatureId(int $feature_id) Return ChildFeatureProduct objects filtered by the feature_id column
* @method array findByFeatureAvId(int $feature_av_id) Return ChildFeatureProduct objects filtered by the feature_av_id column
- * @method array findByByDefault(string $by_default) Return ChildFeatureProduct objects filtered by the by_default column
+ * @method array findByFreeTextValue(string $free_text_value) Return ChildFeatureProduct objects filtered by the free_text_value column
* @method array findByPosition(int $position) Return ChildFeatureProduct objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return ChildFeatureProduct objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildFeatureProduct objects filtered by the updated_at column
@@ -163,7 +163,7 @@ abstract class FeatureProductQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0';
+ $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, FREE_TEXT_VALUE, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -423,32 +423,32 @@ abstract class FeatureProductQuery extends ModelCriteria
}
/**
- * Filter the query on the by_default column
+ * Filter the query on the free_text_value column
*
* Example usage:
*
- * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue'
- * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%'
+ * $query->filterByFreeTextValue('fooValue'); // WHERE free_text_value = 'fooValue'
+ * $query->filterByFreeTextValue('%fooValue%'); // WHERE free_text_value LIKE '%fooValue%'
*
*
- * @param string $byDefault The value to use as filter.
+ * @param string $freeTextValue The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildFeatureProductQuery The current query, for fluid interface
*/
- public function filterByByDefault($byDefault = null, $comparison = null)
+ public function filterByFreeTextValue($freeTextValue = null, $comparison = null)
{
if (null === $comparison) {
- if (is_array($byDefault)) {
+ if (is_array($freeTextValue)) {
$comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $byDefault)) {
- $byDefault = str_replace('*', '%', $byDefault);
+ } elseif (preg_match('/[\%\*]/', $freeTextValue)) {
+ $freeTextValue = str_replace('*', '%', $freeTextValue);
$comparison = Criteria::LIKE;
}
}
- return $this->addUsingAlias(FeatureProductTableMap::BY_DEFAULT, $byDefault, $comparison);
+ return $this->addUsingAlias(FeatureProductTableMap::FREE_TEXT_VALUE, $freeTextValue, $comparison);
}
/**
diff --git a/core/lib/Thelia/Model/Base/FeatureTemplate.php b/core/lib/Thelia/Model/Base/FeatureTemplate.php
index bbccd9251..b8ba55629 100644
--- a/core/lib/Thelia/Model/Base/FeatureTemplate.php
+++ b/core/lib/Thelia/Model/Base/FeatureTemplate.php
@@ -76,6 +76,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface
*/
protected $template_id;
+ /**
+ * The value for the position field.
+ * @var int
+ */
+ protected $position;
+
/**
* The value for the created_at field.
* @var string
@@ -393,6 +399,17 @@ abstract class FeatureTemplate implements ActiveRecordInterface
return $this->template_id;
}
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -504,6 +521,27 @@ abstract class FeatureTemplate implements ActiveRecordInterface
return $this;
} // setTemplateId()
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FeatureTemplateTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -592,13 +630,16 @@ abstract class FeatureTemplate implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)];
$this->template_id = (null !== $col) ? (int) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -611,7 +652,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface
$this->ensureConsistency();
}
- return $startcol + 5; // 5 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS.
+ return $startcol + 6; // 6 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\FeatureTemplate object", 0, $e);
@@ -867,6 +908,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface
if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) {
$modifiedColumns[':p' . $index++] = 'TEMPLATE_ID';
}
+ if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -893,6 +937,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface
case 'TEMPLATE_ID':
$stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT);
break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -971,9 +1018,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface
return $this->getTemplateId();
break;
case 3:
- return $this->getCreatedAt();
+ return $this->getPosition();
break;
case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
return $this->getUpdatedAt();
break;
default:
@@ -1008,8 +1058,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface
$keys[0] => $this->getId(),
$keys[1] => $this->getFeatureId(),
$keys[2] => $this->getTemplateId(),
- $keys[3] => $this->getCreatedAt(),
- $keys[4] => $this->getUpdatedAt(),
+ $keys[3] => $this->getPosition(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1068,9 +1119,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface
$this->setTemplateId($value);
break;
case 3:
- $this->setCreatedAt($value);
+ $this->setPosition($value);
break;
case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1100,8 +1154,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]);
- if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
- if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
}
/**
@@ -1116,6 +1171,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface
if ($this->isColumnModified(FeatureTemplateTableMap::ID)) $criteria->add(FeatureTemplateTableMap::ID, $this->id);
if ($this->isColumnModified(FeatureTemplateTableMap::FEATURE_ID)) $criteria->add(FeatureTemplateTableMap::FEATURE_ID, $this->feature_id);
if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) $criteria->add(FeatureTemplateTableMap::TEMPLATE_ID, $this->template_id);
+ if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) $criteria->add(FeatureTemplateTableMap::POSITION, $this->position);
if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) $criteria->add(FeatureTemplateTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) $criteria->add(FeatureTemplateTableMap::UPDATED_AT, $this->updated_at);
@@ -1183,6 +1239,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface
{
$copyObj->setFeatureId($this->getFeatureId());
$copyObj->setTemplateId($this->getTemplateId());
+ $copyObj->setPosition($this->getPosition());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
if ($makeNew) {
@@ -1323,6 +1380,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface
$this->id = null;
$this->feature_id = null;
$this->template_id = null;
+ $this->position = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
diff --git a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php
index c99c1305f..cccad15ae 100644
--- a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php
+++ b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php
@@ -24,12 +24,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap;
* @method ChildFeatureTemplateQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildFeatureTemplateQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column
* @method ChildFeatureTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column
+ * @method ChildFeatureTemplateQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildFeatureTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildFeatureTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildFeatureTemplateQuery groupById() Group by the id column
* @method ChildFeatureTemplateQuery groupByFeatureId() Group by the feature_id column
* @method ChildFeatureTemplateQuery groupByTemplateId() Group by the template_id column
+ * @method ChildFeatureTemplateQuery groupByPosition() Group by the position column
* @method ChildFeatureTemplateQuery groupByCreatedAt() Group by the created_at column
* @method ChildFeatureTemplateQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -51,12 +53,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap;
* @method ChildFeatureTemplate findOneById(int $id) Return the first ChildFeatureTemplate filtered by the id column
* @method ChildFeatureTemplate findOneByFeatureId(int $feature_id) Return the first ChildFeatureTemplate filtered by the feature_id column
* @method ChildFeatureTemplate findOneByTemplateId(int $template_id) Return the first ChildFeatureTemplate filtered by the template_id column
+ * @method ChildFeatureTemplate findOneByPosition(int $position) Return the first ChildFeatureTemplate filtered by the position column
* @method ChildFeatureTemplate findOneByCreatedAt(string $created_at) Return the first ChildFeatureTemplate filtered by the created_at column
* @method ChildFeatureTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureTemplate filtered by the updated_at column
*
* @method array findById(int $id) Return ChildFeatureTemplate objects filtered by the id column
* @method array findByFeatureId(int $feature_id) Return ChildFeatureTemplate objects filtered by the feature_id column
* @method array findByTemplateId(int $template_id) Return ChildFeatureTemplate objects filtered by the template_id column
+ * @method array findByPosition(int $position) Return ChildFeatureTemplate objects filtered by the position column
* @method array findByCreatedAt(string $created_at) Return ChildFeatureTemplate objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildFeatureTemplate objects filtered by the updated_at column
*
@@ -147,7 +151,7 @@ abstract class FeatureTemplateQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0';
+ $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, POSITION, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -363,6 +367,47 @@ abstract class FeatureTemplateQuery extends ModelCriteria
return $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId, $comparison);
}
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureTemplateQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php
index fa887dc8a..eb6aa2b1a 100644
--- a/core/lib/Thelia/Model/Base/ProductSaleElements.php
+++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php
@@ -103,10 +103,18 @@ abstract class ProductSaleElements implements ActiveRecordInterface
/**
* The value for the weight field.
+ * Note: this column has a database default value of: 0
* @var double
*/
protected $weight;
+ /**
+ * The value for the is_default field.
+ * Note: this column has a database default value of: false
+ * @var boolean
+ */
+ protected $is_default;
+
/**
* The value for the created_at field.
* @var string
@@ -178,6 +186,8 @@ abstract class ProductSaleElements implements ActiveRecordInterface
{
$this->promo = 0;
$this->newness = 0;
+ $this->weight = 0;
+ $this->is_default = false;
}
/**
@@ -513,6 +523,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->weight;
}
+ /**
+ * Get the [is_default] column value.
+ *
+ * @return boolean
+ */
+ public function getIsDefault()
+ {
+
+ return $this->is_default;
+ }
+
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -704,6 +725,35 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this;
} // setWeight()
+ /**
+ * Sets the value of the [is_default] column.
+ * 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 boolean|integer|string $v The new value
+ * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support)
+ */
+ public function setIsDefault($v)
+ {
+ if ($v !== null) {
+ if (is_string($v)) {
+ $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
+ } else {
+ $v = (boolean) $v;
+ }
+ }
+
+ if ($this->is_default !== $v) {
+ $this->is_default = $v;
+ $this->modifiedColumns[] = ProductSaleElementsTableMap::IS_DEFAULT;
+ }
+
+
+ return $this;
+ } // setIsDefault()
+
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -764,6 +814,14 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return false;
}
+ if ($this->weight !== 0) {
+ return false;
+ }
+
+ if ($this->is_default !== false) {
+ return false;
+ }
+
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -812,13 +870,16 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
$this->weight = (null !== $col) ? (double) $col : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->is_default = (null !== $col) ? (boolean) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
- $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -831,7 +892,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->ensureConsistency();
}
- return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
+ return $startcol + 10; // 10 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e);
@@ -1145,6 +1206,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) {
$modifiedColumns[':p' . $index++] = 'WEIGHT';
}
+ if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) {
+ $modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
+ }
if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1183,6 +1247,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
case 'WEIGHT':
$stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
break;
+ case 'IS_DEFAULT':
+ $stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
+ break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1273,9 +1340,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->getWeight();
break;
case 7:
- return $this->getCreatedAt();
+ return $this->getIsDefault();
break;
case 8:
+ return $this->getCreatedAt();
+ break;
+ case 9:
return $this->getUpdatedAt();
break;
default:
@@ -1314,8 +1384,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$keys[4] => $this->getPromo(),
$keys[5] => $this->getNewness(),
$keys[6] => $this->getWeight(),
- $keys[7] => $this->getCreatedAt(),
- $keys[8] => $this->getUpdatedAt(),
+ $keys[7] => $this->getIsDefault(),
+ $keys[8] => $this->getCreatedAt(),
+ $keys[9] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1392,9 +1463,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->setWeight($value);
break;
case 7:
- $this->setCreatedAt($value);
+ $this->setIsDefault($value);
break;
case 8:
+ $this->setCreatedAt($value);
+ break;
+ case 9:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1428,8 +1502,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if (array_key_exists($keys[4], $arr)) $this->setPromo($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]);
- if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
- if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[7], $arr)) $this->setIsDefault($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]);
}
/**
@@ -1448,6 +1523,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo);
if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness);
if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) $criteria->add(ProductSaleElementsTableMap::WEIGHT, $this->weight);
+ if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) $criteria->add(ProductSaleElementsTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_at);
@@ -1519,6 +1595,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$copyObj->setPromo($this->getPromo());
$copyObj->setNewness($this->getNewness());
$copyObj->setWeight($this->getWeight());
+ $copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -2445,6 +2522,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->promo = null;
$this->newness = null;
$this->weight = null;
+ $this->is_default = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
diff --git a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php
index 6e9068002..c8201ed0b 100644
--- a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php
+++ b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php
@@ -28,6 +28,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
* @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column
* @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column
* @method ChildProductSaleElementsQuery orderByWeight($order = Criteria::ASC) Order by the weight column
+ * @method ChildProductSaleElementsQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
* @method ChildProductSaleElementsQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildProductSaleElementsQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -38,6 +39,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
* @method ChildProductSaleElementsQuery groupByPromo() Group by the promo column
* @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column
* @method ChildProductSaleElementsQuery groupByWeight() Group by the weight column
+ * @method ChildProductSaleElementsQuery groupByIsDefault() Group by the is_default column
* @method ChildProductSaleElementsQuery groupByCreatedAt() Group by the created_at column
* @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -71,6 +73,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
* @method ChildProductSaleElements findOneByPromo(int $promo) Return the first ChildProductSaleElements filtered by the promo column
* @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column
* @method ChildProductSaleElements findOneByWeight(double $weight) Return the first ChildProductSaleElements filtered by the weight column
+ * @method ChildProductSaleElements findOneByIsDefault(boolean $is_default) Return the first ChildProductSaleElements filtered by the is_default column
* @method ChildProductSaleElements findOneByCreatedAt(string $created_at) Return the first ChildProductSaleElements filtered by the created_at column
* @method ChildProductSaleElements findOneByUpdatedAt(string $updated_at) Return the first ChildProductSaleElements filtered by the updated_at column
*
@@ -81,6 +84,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
* @method array findByPromo(int $promo) Return ChildProductSaleElements objects filtered by the promo column
* @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column
* @method array findByWeight(double $weight) Return ChildProductSaleElements objects filtered by the weight column
+ * @method array findByIsDefault(boolean $is_default) Return ChildProductSaleElements objects filtered by the is_default column
* @method array findByCreatedAt(string $created_at) Return ChildProductSaleElements objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildProductSaleElements objects filtered by the updated_at column
*
@@ -171,7 +175,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
+ $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -537,6 +541,33 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison);
}
+ /**
+ * Filter the query on the is_default column
+ *
+ * Example usage:
+ *
+ * $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 ChildProductSaleElementsQuery 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(ProductSaleElementsTableMap::IS_DEFAULT, $isDefault, $comparison);
+ }
+
/**
* Filter the query on the created_at column
*
diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php
index 5724e2df1..0917ab30c 100755
--- a/core/lib/Thelia/Model/CategoryDocument.php
+++ b/core/lib/Thelia/Model/CategoryDocument.php
@@ -25,4 +25,28 @@ class CategoryDocument extends BaseCategoryDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setCategoryId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getCategoryId();
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Model/CategoryImage.php b/core/lib/Thelia/Model/CategoryImage.php
index 5bf964e10..17ee387b5 100755
--- a/core/lib/Thelia/Model/CategoryImage.php
+++ b/core/lib/Thelia/Model/CategoryImage.php
@@ -2,6 +2,8 @@
namespace Thelia\Model;
+use Symfony\Component\Filesystem\Filesystem;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
use Thelia\Model\Base\CategoryImage as BaseCategoryImage;
use Propel\Runtime\Connection\ConnectionInterface;
@@ -25,4 +27,29 @@ class CategoryImage extends BaseCategoryImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setCategoryId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getCategoryId();
+ }
+
}
diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php
index 8ecf3a3a9..1409b2713 100755
--- a/core/lib/Thelia/Model/ContentDocument.php
+++ b/core/lib/Thelia/Model/ContentDocument.php
@@ -25,4 +25,28 @@ class ContentDocument extends BaseContentDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setContentId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getContentId();
+ }
}
diff --git a/core/lib/Thelia/Model/ContentImage.php b/core/lib/Thelia/Model/ContentImage.php
index ac1dcf755..b6a3085d4 100755
--- a/core/lib/Thelia/Model/ContentImage.php
+++ b/core/lib/Thelia/Model/ContentImage.php
@@ -25,4 +25,28 @@ class ContentImage extends BaseContentImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setContentId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getContentId();
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Model/FeatureProduct.php b/core/lib/Thelia/Model/FeatureProduct.php
index 35a9b2ddc..fe6c5d8c1 100755
--- a/core/lib/Thelia/Model/FeatureProduct.php
+++ b/core/lib/Thelia/Model/FeatureProduct.php
@@ -3,8 +3,66 @@
namespace Thelia\Model;
use Thelia\Model\Base\FeatureProduct as BaseFeatureProduct;
+use Thelia\Core\Event\TheliaEvents;
+use Propel\Runtime\Connection\ConnectionInterface;
+use Thelia\Core\Event\FeatureProductEvent;
- class FeatureProduct extends BaseFeatureProduct
+class FeatureProduct extends BaseFeatureProduct
{
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_CREATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_UPDATEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::BEFORE_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this));
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+ $this->dispatchEvent(TheliaEvents::AFTER_DELETEFEATURE_PRODUCT, new FeatureProductEvent($this));
+ }
}
diff --git a/core/lib/Thelia/Model/FeatureTemplate.php b/core/lib/Thelia/Model/FeatureTemplate.php
index 47a33027a..3f28a3a10 100644
--- a/core/lib/Thelia/Model/FeatureTemplate.php
+++ b/core/lib/Thelia/Model/FeatureTemplate.php
@@ -3,8 +3,30 @@
namespace Thelia\Model;
use Thelia\Model\Base\FeatureTemplate as BaseFeatureTemplate;
+use Propel\Runtime\Connection\ConnectionInterface;
- class FeatureTemplate extends BaseFeatureTemplate
+class FeatureTemplate extends BaseFeatureTemplate
{
+ use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+ use \Thelia\Model\Tools\PositionManagementTrait;
+
+ /**
+ * Calculate next position relative to our template
+ */
+ protected function addCriteriaToPositionQuery($query)
+ {
+ $query->filterByTemplateId($this->getTemplateId());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ // Set the current position for the new object
+ $this->setPosition($this->getNextPosition());
+
+ return true;
+ }
}
diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php
index 0a86995d2..1d84d9e55 100755
--- a/core/lib/Thelia/Model/FolderDocument.php
+++ b/core/lib/Thelia/Model/FolderDocument.php
@@ -25,4 +25,28 @@ class FolderDocument extends BaseFolderDocument
return true;
}
+
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setFolderId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getFolderId();
+ }
}
diff --git a/core/lib/Thelia/Model/FolderImage.php b/core/lib/Thelia/Model/FolderImage.php
index 58d8f928e..f9491c9a5 100755
--- a/core/lib/Thelia/Model/FolderImage.php
+++ b/core/lib/Thelia/Model/FolderImage.php
@@ -25,4 +25,28 @@ class FolderImage extends BaseFolderImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setFolderId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getFolderId();
+ }
}
diff --git a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php
index 04d3a9a4a..c0df89d8f 100644
--- a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php
+++ b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php
@@ -57,7 +57,7 @@ class AttributeTemplateTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 5;
+ const NUM_COLUMNS = 7;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class AttributeTemplateTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 5;
+ const NUM_HYDRATE_COLUMNS = 7;
/**
* the column name for the ID field
@@ -84,6 +84,16 @@ class AttributeTemplateTableMap extends TableMap
*/
const TEMPLATE_ID = 'attribute_template.TEMPLATE_ID';
+ /**
+ * the column name for the POSITION field
+ */
+ const POSITION = 'attribute_template.POSITION';
+
+ /**
+ * the column name for the ATTRIBUTE_TEMPLATECOL field
+ */
+ const ATTRIBUTE_TEMPLATECOL = 'attribute_template.ATTRIBUTE_TEMPLATECOL';
+
/**
* the column name for the CREATED_AT field
*/
@@ -106,12 +116,12 @@ class AttributeTemplateTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'Position', 'AttributeTemplatecol', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'position', 'attributeTemplatecol', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::POSITION, AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'POSITION', 'ATTRIBUTE_TEMPLATECOL', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'position', 'attribute_templatecol', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
@@ -121,12 +131,12 @@ class AttributeTemplateTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
- self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::CREATED_AT => 3, AttributeTemplateTableMap::UPDATED_AT => 4, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'Position' => 3, 'AttributeTemplatecol' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'position' => 3, 'attributeTemplatecol' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::POSITION => 3, AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL => 4, AttributeTemplateTableMap::CREATED_AT => 5, AttributeTemplateTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'ATTRIBUTE_TEMPLATECOL' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'position' => 3, 'attribute_templatecol' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
@@ -149,6 +159,8 @@ class AttributeTemplateTableMap extends TableMap
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
$this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('ATTRIBUTE_TEMPLATECOL', 'AttributeTemplatecol', 'VARCHAR', false, 45, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -316,12 +328,16 @@ class AttributeTemplateTableMap extends TableMap
$criteria->addSelectColumn(AttributeTemplateTableMap::ID);
$criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_ID);
$criteria->addSelectColumn(AttributeTemplateTableMap::TEMPLATE_ID);
+ $criteria->addSelectColumn(AttributeTemplateTableMap::POSITION);
+ $criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL);
$criteria->addSelectColumn(AttributeTemplateTableMap::CREATED_AT);
$criteria->addSelectColumn(AttributeTemplateTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
$criteria->addSelectColumn($alias . '.TEMPLATE_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_TEMPLATECOL');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
diff --git a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php
index f0263b47c..9db4ec441 100644
--- a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php
+++ b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php
@@ -90,9 +90,9 @@ class FeatureProductTableMap extends TableMap
const FEATURE_AV_ID = 'feature_product.FEATURE_AV_ID';
/**
- * the column name for the BY_DEFAULT field
+ * the column name for the FREE_TEXT_VALUE field
*/
- const BY_DEFAULT = 'feature_product.BY_DEFAULT';
+ const FREE_TEXT_VALUE = 'feature_product.FREE_TEXT_VALUE';
/**
* the column name for the POSITION field
@@ -121,11 +121,11 @@ class FeatureProductTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::BY_DEFAULT, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'FreeTextValue', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'freeTextValue', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::FREE_TEXT_VALUE, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'FREE_TEXT_VALUE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'free_text_value', 'position', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
@@ -136,11 +136,11 @@ class FeatureProductTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
- self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::BY_DEFAULT => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'FreeTextValue' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'freeTextValue' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::FREE_TEXT_VALUE => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'FREE_TEXT_VALUE' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'free_text_value' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
@@ -164,7 +164,7 @@ class FeatureProductTableMap extends TableMap
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
$this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
$this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null);
- $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null);
+ $this->addColumn('FREE_TEXT_VALUE', 'FreeTextValue', 'LONGVARCHAR', false, null, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
@@ -335,7 +335,7 @@ class FeatureProductTableMap extends TableMap
$criteria->addSelectColumn(FeatureProductTableMap::PRODUCT_ID);
$criteria->addSelectColumn(FeatureProductTableMap::FEATURE_ID);
$criteria->addSelectColumn(FeatureProductTableMap::FEATURE_AV_ID);
- $criteria->addSelectColumn(FeatureProductTableMap::BY_DEFAULT);
+ $criteria->addSelectColumn(FeatureProductTableMap::FREE_TEXT_VALUE);
$criteria->addSelectColumn(FeatureProductTableMap::POSITION);
$criteria->addSelectColumn(FeatureProductTableMap::CREATED_AT);
$criteria->addSelectColumn(FeatureProductTableMap::UPDATED_AT);
@@ -344,7 +344,7 @@ class FeatureProductTableMap extends TableMap
$criteria->addSelectColumn($alias . '.PRODUCT_ID');
$criteria->addSelectColumn($alias . '.FEATURE_ID');
$criteria->addSelectColumn($alias . '.FEATURE_AV_ID');
- $criteria->addSelectColumn($alias . '.BY_DEFAULT');
+ $criteria->addSelectColumn($alias . '.FREE_TEXT_VALUE');
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php
index 067a242a3..c6a29e2f4 100644
--- a/core/lib/Thelia/Model/Map/FeatureTableMap.php
+++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php
@@ -156,7 +156,7 @@ class FeatureTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0);
- $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
diff --git a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php
index abb1a98b7..68f3b9a24 100644
--- a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php
+++ b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php
@@ -57,7 +57,7 @@ class FeatureTemplateTableMap 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 FeatureTemplateTableMap 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 FeatureTemplateTableMap extends TableMap
*/
const TEMPLATE_ID = 'feature_template.TEMPLATE_ID';
+ /**
+ * the column name for the POSITION field
+ */
+ const POSITION = 'feature_template.POSITION';
+
/**
* the column name for the CREATED_AT field
*/
@@ -106,12 +111,12 @@ class FeatureTemplateTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::POSITION, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -121,12 +126,12 @@ class FeatureTemplateTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
- self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::CREATED_AT => 3, FeatureTemplateTableMap::UPDATED_AT => 4, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::POSITION => 3, FeatureTemplateTableMap::CREATED_AT => 4, FeatureTemplateTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
@@ -149,6 +154,7 @@ class FeatureTemplateTableMap extends TableMap
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
$this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -316,12 +322,14 @@ class FeatureTemplateTableMap extends TableMap
$criteria->addSelectColumn(FeatureTemplateTableMap::ID);
$criteria->addSelectColumn(FeatureTemplateTableMap::FEATURE_ID);
$criteria->addSelectColumn(FeatureTemplateTableMap::TEMPLATE_ID);
+ $criteria->addSelectColumn(FeatureTemplateTableMap::POSITION);
$criteria->addSelectColumn(FeatureTemplateTableMap::CREATED_AT);
$criteria->addSelectColumn(FeatureTemplateTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.FEATURE_ID');
$criteria->addSelectColumn($alias . '.TEMPLATE_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php
index fc23ae569..1e894ef24 100644
--- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php
+++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php
@@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap
/**
* The total number of columns
*/
- const NUM_COLUMNS = 9;
+ const NUM_COLUMNS = 10;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
- const NUM_HYDRATE_COLUMNS = 9;
+ const NUM_HYDRATE_COLUMNS = 10;
/**
* the column name for the ID field
@@ -104,6 +104,11 @@ class ProductSaleElementsTableMap extends TableMap
*/
const WEIGHT = 'product_sale_elements.WEIGHT';
+ /**
+ * the column name for the IS_DEFAULT field
+ */
+ const IS_DEFAULT = 'product_sale_elements.IS_DEFAULT';
+
/**
* the column name for the CREATED_AT field
*/
@@ -126,12 +131,12 @@ class ProductSaleElementsTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ),
- self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ),
- self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
- self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ),
- self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'isDefault', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::IS_DEFAULT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'is_default', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -141,12 +146,12 @@ class ProductSaleElementsTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
- self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
- self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 8, ),
- self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
- self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'created_at' => 7, 'updated_at' => 8, ),
- self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'IsDefault' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'isDefault' => 7, 'createdAt' => 8, 'updatedAt' => 9, ),
+ self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::IS_DEFAULT => 7, ProductSaleElementsTableMap::CREATED_AT => 8, ProductSaleElementsTableMap::UPDATED_AT => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'IS_DEFAULT' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'is_default' => 7, 'created_at' => 8, 'updated_at' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
@@ -167,11 +172,12 @@ class ProductSaleElementsTableMap extends TableMap
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
- $this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
$this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
$this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
- $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null);
+ $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, 0);
+ $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()
@@ -355,6 +361,7 @@ class ProductSaleElementsTableMap extends TableMap
$criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO);
$criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS);
$criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT);
+ $criteria->addSelectColumn(ProductSaleElementsTableMap::IS_DEFAULT);
$criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT);
$criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT);
} else {
@@ -365,6 +372,7 @@ class ProductSaleElementsTableMap extends TableMap
$criteria->addSelectColumn($alias . '.PROMO');
$criteria->addSelectColumn($alias . '.NEWNESS');
$criteria->addSelectColumn($alias . '.WEIGHT');
+ $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 cbb6c0051..2348a9c0d 100755
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -87,12 +87,46 @@ class Product extends BaseProduct
return $this;
}
+ public function updateDefaultCategory($defaultCategoryId) {
+
+ // Allow uncategorized products (NULL instead of 0, to bypass delete cascade constraint)
+ if ($defaultCategoryId <= 0) $defaultCategoryId = NULL;
+
+ // Update the default category
+ $productCategory = ProductCategoryQuery::create()
+ ->filterByProductId($this->getId())
+ ->filterByDefaultCategory(true)
+ ->findOne()
+ ;
+
+ if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) {
+ exit;
+ // Delete the old default category
+ if ($productCategory !== null) $productCategory->delete();
+
+ // Add the new default category
+ $productCategory = new ProductCategory();
+
+ $productCategory
+ ->setProduct($this)
+ ->setCategoryId($defaultCategoryId)
+ ->setDefaultCategory(true)
+ ->save()
+ ;
+ }
+ }
+
/**
* Create a new product, along with the default category ID
*
* @param int $defaultCategoryId the default category ID of this product
+ * @param float $basePrice the product base price
+ * @param int $priceCurrencyId the price currency Id
+ * @param int $taxRuleId the product tax rule ID
+ * @param float $baseWeight base weight in Kg
*/
- public function create($defaultCategoryId) {
+
+ public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) {
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
@@ -105,18 +139,13 @@ class Product extends BaseProduct
$this->save($con);
// Add the default category
- $pc = new ProductCategory();
-
- $pc
- ->setProduct($this)
- ->setCategoryId($defaultCategoryId)
- ->setDefaultCategory(true)
- ->save($con)
- ;
+ $this->updateDefaultCategory($defaultCategoryId);
// Set the position
$this->setPosition($this->getNextPosition())->save($con);
+ $this->setTaxRuleId($taxRuleId);
+
// Create an empty product sale element
$sale_elements = new ProductSaleElements();
@@ -125,7 +154,8 @@ class Product extends BaseProduct
->setRef($this->getRef())
->setPromo(0)
->setNewness(0)
- ->setWeight(0)
+ ->setWeight($baseWeight)
+ ->setIsDefault(true)
->save($con)
;
@@ -134,9 +164,9 @@ class Product extends BaseProduct
$product_price
->setProductSaleElements($sale_elements)
- ->setPromoPrice(0)
- ->setPrice(0)
- ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true))
+ ->setPromoPrice($basePrice)
+ ->setPrice($basePrice)
+ ->setCurrencyId($priceCurrencyId)
->save($con)
;
diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php
index e07ee2cd6..843d76ba1 100644
--- a/core/lib/Thelia/Model/ProductAssociatedContent.php
+++ b/core/lib/Thelia/Model/ProductAssociatedContent.php
@@ -11,11 +11,22 @@ class ProductAssociatedContent extends BaseProductAssociatedContent {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
+ use \Thelia\Model\Tools\PositionManagementTrait;
+
+ /**
+ * Calculate next position relative to our product
+ */
+ protected function addCriteriaToPositionQuery($query) {
+ $query->filterByProductId($this->getProductId());
+ }
+
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
+ $this->setPosition($this->getNextPosition());
+
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
return true;
diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php
index 53515ff3c..b0f8032da 100755
--- a/core/lib/Thelia/Model/ProductDocument.php
+++ b/core/lib/Thelia/Model/ProductDocument.php
@@ -26,4 +26,28 @@ class ProductDocument extends BaseProductDocument
return true;
}
+ /**
+ * Set Document parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setProductId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Document parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getProductId();
+ }
+
}
diff --git a/core/lib/Thelia/Model/ProductImage.php b/core/lib/Thelia/Model/ProductImage.php
index 4bf0c40a6..6cc3ddd8c 100755
--- a/core/lib/Thelia/Model/ProductImage.php
+++ b/core/lib/Thelia/Model/ProductImage.php
@@ -25,4 +25,28 @@ class ProductImage extends BaseProductImage
return true;
}
+
+ /**
+ * Set Image parent id
+ *
+ * @param int $parentId parent id
+ *
+ * @return $this
+ */
+ public function setParentId($parentId)
+ {
+ $this->setProductId($parentId);
+
+ return $this;
+ }
+
+ /**
+ * Get Image parent id
+ *
+ * @return int parent id
+ */
+ public function getParentId()
+ {
+ return $this->getProductId();
+ }
}
diff --git a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
index 70da830ac..642d07402 100644
--- a/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
+++ b/core/lib/Thelia/Model/Tools/PositionManagementTrait.php
@@ -126,7 +126,8 @@ trait PositionManagementTrait {
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save();
$cnx->commit();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
$cnx->rollback();
}
}
@@ -179,7 +180,10 @@ trait PositionManagementTrait {
try {
foreach ($results as $result) {
- $result->setDispatcher($this->getDispatcher())->setPosition($result->getPosition() + $delta)->save($cnx);
+
+ $objNewPosition = $result->getPosition() + $delta;
+
+ $result->setDispatcher($this->getDispatcher())->setPosition($objNewPosition)->save($cnx);
}
$this
@@ -188,7 +192,8 @@ trait PositionManagementTrait {
;
$cnx->commit();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
$cnx->rollback();
}
}
diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
new file mode 100644
index 000000000..8dce5afcc
--- /dev/null
+++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php
@@ -0,0 +1,906 @@
+
+ */
+
+namespace Thelia\Tests\Type;
+
+
+use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
+use Thelia\Core\Event\ImageCreateOrUpdateEvent;
+use Thelia\Core\Translation\Translator;
+use Thelia\Exception\ImageException;
+use Thelia\Model\Admin;
+use Thelia\Tools\FileManager;
+
+/**
+ * Class FileManagerTest
+ *
+ * @package Thelia\Tests\Type
+ */
+class FileManagerTest extends \PHPUnit_Framework_TestCase {
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::copyUploadedFile
+ */
+ public function testCopyUploadedFile()
+ {
+ $this->markTestIncomplete(
+ 'Mock issue'
+ );
+
+ $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubTranslator->expects($this->any())
+ ->method('trans')
+ ->will($this->returnValue('translated'));
+
+ $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubSecurity->expects($this->any())
+ ->method('getAdminUser')
+ ->will($this->returnValue(new Admin()));
+
+
+
+ // Create a map of arguments to return values.
+ $map = array(
+ array('thelia.translator', $stubTranslator),
+ array('request', $stubRequest),
+ array('thelia.securityContext', $stubSecurity)
+ );
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContainer->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($map));
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('getUploadDir')
+ ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
+ $stubProductImage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(42));
+ $stubProductImage->expects($this->any())
+ ->method('setFile')
+ ->will($this->returnValue(true));
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('goodName'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('png'));
+ $stubUploadedFile->expects($this->any())
+ ->method('move')
+ ->will($this->returnValue($stubUploadedFile));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $newUploadedFiles = array();
+
+ $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_IMAGES);
+
+ $this->assertCount(1, $actual);
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::copyUploadedFile
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testCopyUploadedFileExceptionImageException()
+ {
+ $this->markTestIncomplete(
+ 'Mock issue'
+ );
+
+ $stubTranslator = $this->getMockBuilder('\Thelia\Core\Translation\Translator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubTranslator->expects($this->any())
+ ->method('trans')
+ ->will($this->returnValue('translated'));
+
+ $stubRequest = $this->getMockBuilder('\Thelia\Core\HttpFoundation\Request')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubSecurity = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubSecurity->expects($this->any())
+ ->method('getAdminUser')
+ ->will($this->returnValue(new Admin()));
+
+
+
+ // Create a map of arguments to return values.
+ $map = array(
+ array('thelia.translator', $stubTranslator),
+ array('request', $stubRequest),
+ array('thelia.securityContext', $stubSecurity)
+ );
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContainer->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($map));
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('getUploadDir')
+ ->will($this->returnValue(THELIA_LOCAL_DIR . 'media/images/product'));
+ $stubProductImage->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(42));
+ $stubProductImage->expects($this->any())
+ ->method('setFile')
+ ->will($this->returnValue(true));
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('goodName'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('png'));
+ $stubUploadedFile->expects($this->any())
+ ->method('move')
+ ->will($this->returnValue($stubUploadedFile));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $newUploadedFiles = array();
+
+ $actual = $fileManager->copyUploadedFile(24, FileManager::TYPE_PRODUCT, $stubProductImage, $stubUploadedFile, $newUploadedFiles, FileManager::FILE_TYPE_DOCUMENTS);
+
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageProductImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubProductImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentProductDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubProductDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageCategoryImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubCategoryImage = $this->getMockBuilder('\Thelia\Model\CategoryImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubCategoryImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubCategoryImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubCategoryImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentCategoryDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubCategoryDocument = $this->getMockBuilder('\Thelia\Model\CategoryDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubCategoryDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubCategoryDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CATEGORY, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubCategoryDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageFolderImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubFolderImage = $this->getMockBuilder('\Thelia\Model\FolderImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubFolderImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubFolderImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubFolderImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentFolderDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubFolderDocument = $this->getMockBuilder('\Thelia\Model\FolderDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubFolderDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubFolderDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_FOLDER, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubFolderDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ */
+ public function testSaveImageContentImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubContentImage = $this->getMockBuilder('\Thelia\Model\ContentImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContentImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubContentImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveImage($event, $stubContentImage);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ */
+ public function testSaveDocumentContentDocument()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubContentDocument = $this->getMockBuilder('\Thelia\Model\ContentDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubContentDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubContentDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $fileManager = new FileManager($stubContainer);
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_CONTENT, 24);
+
+ $expected = 10;
+ $actual = $fileManager->saveDocument($event, $stubContentDocument);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testSaveImageExceptionImageException()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new ImageCreateOrUpdateEvent('bad', 24);
+
+ $fileManager->saveImage($event, $stubProductImage);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ * @expectedException \Thelia\Model\Exception\InvalidArgumentException
+ */
+ public function testSaveDocumentExceptionDocumentException()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(10));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new DocumentCreateOrUpdateEvent('bad', 24);
+
+ $fileManager->saveDocument($event, $stubProductDocument);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveImage
+ * @expectedException \Thelia\Exception\ImageException
+ */
+ public function testSaveImageExceptionImageException2()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductImage = $this->getMockBuilder('\Thelia\Model\ProductImage')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductImage->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+ $stubProductImage->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new ImageCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $fileManager->saveImage($event, $stubProductImage);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::saveDocument
+ * @expectedException \Thelia\Model\Exception\InvalidArgumentException
+ */
+ public function testSaveDocumentExceptionDocumentException2()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $fileManager = new FileManager($stubContainer);
+
+ $stubProductDocument = $this->getMockBuilder('\Thelia\Model\ProductDocument')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubProductDocument->expects($this->any())
+ ->method('save')
+ ->will($this->returnValue(0));
+ $stubProductDocument->expects($this->any())
+ ->method('getFile')
+ ->will($this->returnValue('file'));
+
+ $event = new DocumentCreateOrUpdateEvent(FileManager::TYPE_PRODUCT, 24);
+
+ $fileManager->saveDocument($event, $stubProductDocument);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::sanitizeFileName
+ */
+ public function testSanitizeFileName()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $badFileName = 'azeéràçè§^"$*+-_°)(&é<>@#ty';
+
+ $expected = 'azeyryZyy-_yty';
+ $actual = $fileManager->sanitizeFileName($badFileName);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageModel
+ */
+ public function testGetImageModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentImage', $actual);
+ $actual = $fileManager->getImageModel(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderImage', $actual);
+ $actual = $fileManager->getImageModel('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentModel
+ */
+ public function testGetDocumentModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentDocument', $actual);
+ $actual = $fileManager->getDocumentModel(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderDocument', $actual);
+ $actual = $fileManager->getDocumentModel('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageModelQuery
+ */
+ public function testGetImageModelQuery()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderImageQuery', $actual);
+ $actual = $fileManager->getImageModelQuery('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentModelQuery
+ */
+ public function testGetDocumentModelQuery()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_PRODUCT);
+ $this->assertInstanceOf('\Thelia\Model\ProductDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CATEGORY);
+ $this->assertInstanceOf('\Thelia\Model\CategoryDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_CONTENT);
+ $this->assertInstanceOf('\Thelia\Model\ContentDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery(FileManager::TYPE_FOLDER);
+ $this->assertInstanceOf('\Thelia\Model\FolderDocumentQuery', $actual);
+ $actual = $fileManager->getDocumentModelQuery('bad');
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getParentFileModel
+ */
+ public function testGetParentFileModel()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_PRODUCT, 1);
+ $this->assertInstanceOf('\Thelia\Model\Product', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_CATEGORY, 1);
+ $this->assertInstanceOf('\Thelia\Model\Category', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_CONTENT, 1);
+ $this->assertInstanceOf('\Thelia\Model\Content', $actual);
+ $actual = $fileManager->getParentFileModel(FileManager::TYPE_FOLDER, 1);
+ $this->assertInstanceOf('\Thelia\Model\Folder', $actual, 1);
+ $actual = $fileManager->getParentFileModel('bad', 1);
+ $this->assertNull($actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getImageForm
+ */
+ public function testGetImageForm()
+ {
+ // Mock issue
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ /**
+ * @covers Thelia\Tools\FileManager::getDocumentForm
+ */
+ public function testGetDocumentForm()
+ {
+ // Mock issue
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getUploadDir
+ */
+ public function testGetUploadDir()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/product', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/category', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/content', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/images/folder', $actual);
+ $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/product', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/category', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/content', $actual);
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(THELIA_LOCAL_DIR . 'media/documents/folder', $actual);
+ $actual = $fileManager->getUploadDir('bad', FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getUploadDir(FileManager::TYPE_FOLDER, 'bad');
+ $this->assertEquals(false, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::getRedirectionUrl
+ */
+ public function testGetRedirectionUrl()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/products/update?product_id=1¤t_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/content/update/1?current_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('/admin/folders/update/1?current_tab=images', $actual);
+ $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_PRODUCT, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/products/update?product_id=1¤t_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CATEGORY, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/categories/update?category_id=1¤t_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_CONTENT, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/content/update/1?current_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('/admin/folders/update/1?current_tab=documents', $actual);
+ $actual = $fileManager->getRedirectionUrl('bad', 1, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getRedirectionUrl(FileManager::TYPE_FOLDER, 1, 'bad');
+ $this->assertEquals(false, $actual);
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::getFormId
+ */
+ public function testGetFormId()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.product.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.category.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.content.image.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals('thelia.admin.folder.image.modification', $actual);
+ $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_IMAGES);
+ $this->assertEquals(false, $actual);
+
+ $actual = $fileManager->getFormId(FileManager::TYPE_PRODUCT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.product.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CATEGORY, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.category.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_CONTENT, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.content.document.modification', $actual);
+ $actual = $fileManager->getFormId(FileManager::TYPE_FOLDER, FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals('thelia.admin.folder.document.modification', $actual);
+ $actual = $fileManager->getFormId('bad', FileManager::FILE_TYPE_DOCUMENTS);
+ $this->assertEquals(false, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::renameFile
+ */
+ public function testRenameFile()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue('yml'));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
+
+
+ $fileManager = new FileManager($stubContainer);
+
+ $expected = 'or1-g_nalyfilenme-1.yml';
+ $actual = $fileManager->renameFile(1, $stubUploadedFile);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::renameFile
+ */
+ public function testRenameFileWithoutExtension()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stubUploadedFile = $this->getMockBuilder('\Symfony\Component\HttpFoundation\File\UploadedFile')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalExtension')
+ ->will($this->returnValue(''));
+ $stubUploadedFile->expects($this->any())
+ ->method('getClientOriginalName')
+ ->will($this->returnValue('or1-g_n?al*/&é"filen@me#'));
+
+
+ $fileManager = new FileManager($stubContainer);
+
+ $expected = 'or1-g_nalyfilenme-1';
+ $actual = $fileManager->renameFile(1, $stubUploadedFile);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::isImage
+ */
+ public function testIsImage()
+ {
+ $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerInterface')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $fileManager = new FileManager($stubContainer);
+
+ $actual = $fileManager->isImage('image/jpeg');
+ $this->assertTrue($actual);
+ $actual = $fileManager->isImage('image/png');
+ $this->assertTrue($actual);
+ $actual = $fileManager->isImage('image/gif');
+ $this->assertTrue($actual);
+
+ $actual = $fileManager->isImage('bad');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('image/jpg');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('application/x-msdownload');
+ $this->assertFalse($actual);
+ $actual = $fileManager->isImage('application/x-sh');
+ $this->assertFalse($actual);
+
+ }
+
+
+ /**
+ * @covers Thelia\Tools\FileManager::getAvailableTypes
+ */
+ public function testGetAvailableTypes()
+ {
+ $expected = array(
+ FileManager::TYPE_CATEGORY,
+ FileManager::TYPE_CONTENT,
+ FileManager::TYPE_FOLDER,
+ FileManager::TYPE_PRODUCT,
+ FileManager::TYPE_MODULE,
+ );
+ $actual = FileManager::getAvailableTypes();
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::adminLogAppend
+ */
+ public function testAdminLogAppend()
+ {
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Thelia\Tools\FileManager::deleteFile
+ */
+ public function testDeleteFile()
+ {
+ // @todo see http://tech.vg.no/2011/03/09/mocking-the-file-system-using-phpunit-and-vfsstream/
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+}
diff --git a/core/lib/Thelia/Tools/FileManager.php b/core/lib/Thelia/Tools/FileManager.php
new file mode 100644
index 000000000..6c06fb416
--- /dev/null
+++ b/core/lib/Thelia/Tools/FileManager.php
@@ -0,0 +1,731 @@
+. */
+/* */
+/**********************************************************************************/
+namespace Thelia\Tools;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Thelia\Core\Event\DocumentCreateOrUpdateEvent;
+use Thelia\Core\Event\ImageCreateOrUpdateEvent;
+use Thelia\Core\HttpFoundation\Request;
+use Thelia\Core\Translation\Translator;
+use Thelia\Exception\ImageException;
+use Thelia\Form\CategoryDocumentModification;
+use Thelia\Form\CategoryImageModification;
+use Thelia\Form\ContentDocumentModification;
+use Thelia\Form\ContentImageModification;
+use Thelia\Form\FolderDocumentModification;
+use Thelia\Form\FolderImageModification;
+use Thelia\Form\ProductDocumentModification;
+use Thelia\Form\ProductImageModification;
+use Thelia\Model\AdminLog;
+use Thelia\Model\CategoryDocument;
+use Thelia\Model\CategoryDocumentQuery;
+use Thelia\Model\CategoryImage;
+use Thelia\Model\CategoryImageQuery;
+use Thelia\Model\CategoryQuery;
+use Thelia\Model\ContentDocument;
+use Thelia\Model\ContentDocumentQuery;
+use Thelia\Model\ContentImage;
+use Thelia\Model\ContentImageQuery;
+use Thelia\Model\ContentQuery;
+use Thelia\Model\Exception\InvalidArgumentException;
+use Thelia\Model\FolderDocument;
+use Thelia\Model\FolderDocumentQuery;
+use Thelia\Model\FolderImage;
+use Thelia\Model\FolderImageQuery;
+use Thelia\Model\FolderQuery;
+use Thelia\Model\ProductDocument;
+use Thelia\Model\ProductDocumentQuery;
+use Thelia\Model\ProductImage;
+use Thelia\Model\ProductImageQuery;
+use Thelia\Model\ProductQuery;
+
+/**
+ * Created by JetBrains PhpStorm.
+ * Date: 9/19/13
+ * Time: 3:24 PM
+ *
+ * File Manager
+ *
+ * @package File
+ * @author Guillaume MOREL | {intl l='ID'} | + +{intl l='Content title'} | + +{intl l='Position'} | + + {module_include location='product_contents_table_header'} + +{intl l="Actions"} | +
|---|---|---|---|
| {$ID} | + ++ {$TITLE} + | + ++ {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-content-position' product_id=$product_id current_tab="related"} + url_parameter="content_id" + in_place_edit_class="contentPositionChange" + position=$POSITION + id=$ID + } + | + + {module_include location='product_contents_table_row'} + +
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.content.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product contains no contents"}
+
+ |
+ |||
| {intl l='ID'} | + +{intl l='Accessory title'} | + +{intl l='Position'} | + + {module_include location='product_accessories_table_header'} + +{intl l="Actions"} | +
|---|---|---|---|
| {$ID} | + ++ {$TITLE} + | + ++ {admin_position_block + permission="admin.products.edit" + path={url path='/admin/product/update-accessory-position' product_id=$product_id current_tab="related"} + url_parameter="accessory_id" + in_place_edit_class="accessoryPositionChange" + position=$POSITION + id=$ID + } + | + + {module_include location='product_accessories_table_row'} + +
+
+ {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.product.accessory.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product contains no accessories"}
+
+ |
+ |||
| {intl l='ID'} | + +{intl l='Category title'} | + + {module_include location='product_categories_table_header'} + +{intl l="Actions"} | +
|---|---|---|
| {$ID} | + ++ {$TITLE} + | + + {module_include location='product_categories_table_row'} + +
+
+ {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.product.category.delete"}
+
+
+
+ {/loop}
+
+ |
+
|
+
+ {intl l="This product doesn't belong to any additional category."}
+
+ |
+ ||