Finished product feature values

This commit is contained in:
franck
2013-09-20 23:10:31 +02:00
parent 1cf8c87d1a
commit f6530f0bfc
16 changed files with 440 additions and 321 deletions

View File

@@ -54,6 +54,10 @@ use Thelia\Model\FeatureQuery;
use Thelia\Core\Event\FeatureProductDeleteEvent; use Thelia\Core\Event\FeatureProductDeleteEvent;
use Thelia\Model\FeatureProductQuery; use Thelia\Model\FeatureProductQuery;
use Thelia\Model\ProductCategoryQuery; use Thelia\Model\ProductCategoryQuery;
use Thelia\Core\Event\ProductSetTemplateEvent;
use Thelia\Model\AttributeCombinationQuery;
use Thelia\Core\Template\Loop\ProductSaleElements;
use Thelia\Model\ProductSaleElementsQuery;
class Product extends BaseAction implements EventSubscriberInterface class Product extends BaseAction implements EventSubscriberInterface
{ {
@@ -235,6 +239,24 @@ class Product extends BaseAction implements EventSubscriberInterface
; ;
} }
public function setProductTemplate(ProductSetTemplateEvent $event) {
$product = $event->getProduct();
// Delete all product feature relations
FeatureProductQuery::create()->filterByProduct($product)->delete();
// Delete all product attributes sale elements
ProductSaleElementsQuery::create()->filterByProduct($product)->delete();
// Update the product template
$template_id = $event->getTemplateId();
// Set it to null if it's zero.
if ($template_id <= 0) $template_id = NULL;
$product->setTemplateId($template_id)->save();
}
/** /**
* Changes position, selecting absolute ou relative change. * Changes position, selecting absolute ou relative change.
@@ -308,19 +330,13 @@ echo "value=".$event->getFeatureValue();
public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) { public function deleteFeatureProductValue(FeatureProductDeleteEvent $event) {
$featureProduct = new FeatureProduct(); $featureProduct = FeatureProductQuery::create()
->filterByProductId($event->getProductId())
$featureProduct ->filterByFeatureId($event->getFeatureId())
->setDispatcher($this->getDispatcher()) ->delete()
->setProductId($event->getProductId())
->setFeatureId($event->getFeatureId())
->delete();
; ;
echo "<br/>Delete p=".$event->getProductId().", f=".$event->getFeatureId();
$event->setFeatureProduct($featureProduct); echo "<br/>Delete p=".$event->getProductId().", f=".$event->getFeatureId();
} }
/** /**
@@ -343,8 +359,11 @@ echo "<br/>Delete p=".$event->getProductId().", f=".$event->getFeatureId();
TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128), TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128),
TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128), TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128),
TheliaEvents::PRODUCT_SET_TEMPLATE => array("setProductTemplate", 128),
TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128), TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128),
TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128), TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE => array("deleteFeatureProductValue", 128),
); );
} }
} }

View File

@@ -185,6 +185,9 @@
</route> </route>
<!--Features and attributes --> <!--Features and attributes -->
<route id="admin.products.set-product-template" path="/admin/product/{productId}/set-product-template">
<default key="_controller">Thelia\Controller\Admin\ProductController::setProductTemplateAction</default>
</route>
<route id="admin.products.update-attributes-and-features" path="/admin/product/{productId}/update-attributes-and-features"> <route id="admin.products.update-attributes-and-features" path="/admin/product/{productId}/update-attributes-and-features">
<default key="_controller">Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction</default> <default key="_controller">Thelia\Controller\Admin\ProductController::updateAttributesAndFeaturesAction</default>

View File

@@ -47,6 +47,7 @@ use Thelia\Core\Event\FeatureProductUpdateEvent;
use Thelia\Model\FeatureQuery; use Thelia\Model\FeatureQuery;
use Thelia\Core\Event\FeatureProductDeleteEvent; use Thelia\Core\Event\FeatureProductDeleteEvent;
use Thelia\Model\FeatureTemplateQuery; use Thelia\Model\FeatureTemplateQuery;
use Thelia\Core\Event\ProductSetTemplateEvent;
/** /**
* Manages products * Manages products
@@ -479,12 +480,36 @@ class ProductController extends AbstractCrudController
$this->redirectToEditionTemplate(); $this->redirectToEditionTemplate();
} }
/**
* Change product template for a given product.
*
* @param unknown $productId
*/
public function setProductTemplateAction($productId) {
// Check current user authorization
if (null !== $response = $this->checkAuth('admin.products.update')) return $response;
$product = ProductQuery::create()->findPk($productId);
if ($product != null) {
$template_id = intval($this->getRequest()->get('template_id', 0));
$this->dispatch(
TheliaEvents::PRODUCT_SET_TEMPLATE,
new ProductSetTemplateEvent($product, $template_id)
);
}
$this->redirectToEditionTemplate();
}
/** /**
* Update product attributes and features * Update product attributes and features
*/ */
public function updateAttributesAndFeaturesAction($productId) { public function updateAttributesAndFeaturesAction($productId) {
// et all features for the product's template
$product = ProductQuery::create()->findPk($productId); $product = ProductQuery::create()->findPk($productId);
if ($product != null) { if ($product != null) {
@@ -492,6 +517,7 @@ class ProductController extends AbstractCrudController
$featureTemplate = FeatureTemplateQuery::create()->filterByTemplateId($product->getTemplateId())->find(); $featureTemplate = FeatureTemplateQuery::create()->filterByTemplateId($product->getTemplateId())->find();
if ($featureTemplate !== null) { if ($featureTemplate !== null) {
// Get all features for the template attached to this product // Get all features for the template attached to this product
$allFeatures = FeatureQuery::create() $allFeatures = FeatureQuery::create()
->filterByFeatureTemplate($featureTemplate) ->filterByFeatureTemplate($featureTemplate)
@@ -499,17 +525,17 @@ class ProductController extends AbstractCrudController
$updatedFeatures = array(); $updatedFeatures = array();
// Update all features values // Update all features values, starting with feature av. values
$featureValues = $this->getRequest()->get('feature_value', array()); $featureValues = $this->getRequest()->get('feature_value', array());
echo "<br />list: "; print_r($featureValues);
foreach($featureValues as $featureId => $featureValueList) { foreach($featureValues as $featureId => $featureValueList) {
// Delete all values for this feature. // Delete all features av. for this feature.
$event = new FeatureProductDeleteEvent($productId, $featureId); $event = new FeatureProductDeleteEvent($productId, $featureId);
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event); $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
// Add all selected values // Add then all selected values
foreach($featureValueList as $featureValue) { foreach($featureValueList as $featureValue) {
$event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue); $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue);
@@ -521,7 +547,7 @@ echo "<br />list: "; print_r($featureValues);
// Update then features text values // Update then features text values
$featureTextValues = $this->getRequest()->get('feature_text_value', array()); $featureTextValues = $this->getRequest()->get('feature_text_value', array());
echo "<br />free text"; print_r($featureTextValues);
foreach($featureTextValues as $featureId => $featureValue) { foreach($featureTextValues as $featureId => $featureValue) {
// considere empty text as empty feature value (e.g., we will delete it) // considere empty text as empty feature value (e.g., we will delete it)
@@ -536,16 +562,23 @@ echo "<br />free text"; print_r($featureTextValues);
// Delete features which don't have any values // Delete features which don't have any values
foreach($allFeatures as $feature) { foreach($allFeatures as $feature) {
if (! in_array($feature->getId(), $updatedFeatures)) { if (! in_array($feature->getId(), $updatedFeatures)) {
$event = new FeatureProductDeleteEvent($productId, $feature->getId()); $event = new FeatureProductDeleteEvent($productId, $feature->getId());
echo "<br />delete $productId, ".$feature->getId()." - ";
$this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event); $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
} }
} }
} }
exit;
} }
$this->redirectToEditionTemplate(); // If we have to stay on the same page, do not redirect to the succesUrl,
// just redirect to the edit page again.
if ($this->getRequest()->get('save_mode') == 'stay') {
$this->redirectToEditionTemplate($this->getRequest());
}
// Redirect to the category/product list
$this->redirectToListTemplate();
} }
} }

View File

@@ -0,0 +1,51 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Event;
use Thelia\Model\Product;
use Thelia\Core\Event\ActionEvent;
class ProductSetTemplateEvent extends ProductEvent
{
public $template_id = null;
public function __construct(Product $product = null, $template_id)
{
parent::__construct($product);
$this->template_id = $template_id;
}
public function getTemplateId()
{
return $this->template_id;
}
public function setTemplateId($template_id)
{
$this->template_id = $template_id;
return $this;
}
}

View File

@@ -187,6 +187,8 @@ final class TheliaEvents
const PRODUCT_ADD_CONTENT = "action.productAddContent"; const PRODUCT_ADD_CONTENT = "action.productAddContent";
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
const PRODUCT_SET_TEMPLATE = "action.productSetTemplate";
const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory"; const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory";
const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory"; const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory";
const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition"; const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition";

View File

@@ -78,13 +78,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
*/ */
protected $product_sale_elements_id; protected $product_sale_elements_id;
/**
* 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. * The value for the created_at field.
* @var string * @var string
@@ -120,24 +113,11 @@ abstract class AttributeCombination implements ActiveRecordInterface
*/ */
protected $alreadyInSave = false; protected $alreadyInSave = false;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->is_default = false;
}
/** /**
* Initializes internal state of Thelia\Model\Base\AttributeCombination object. * Initializes internal state of Thelia\Model\Base\AttributeCombination object.
* @see applyDefaults()
*/ */
public function __construct() public function __construct()
{ {
$this->applyDefaultValues();
} }
/** /**
@@ -420,17 +400,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
return $this->product_sale_elements_id; return $this->product_sale_elements_id;
} }
/**
* Get the [is_default] column value.
*
* @return boolean
*/
public function getIsDefault()
{
return $this->is_default;
}
/** /**
* Get the [optionally formatted] temporal [created_at] column value. * Get the [optionally formatted] temporal [created_at] column value.
* *
@@ -546,35 +515,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
return $this; return $this;
} // setProductSaleElementsId() } // setProductSaleElementsId()
/**
* 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\AttributeCombination 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[] = AttributeCombinationTableMap::IS_DEFAULT;
}
return $this;
} // setIsDefault()
/** /**
* Sets the value of [created_at] column to a normalized version of the date/time value specified. * Sets the value of [created_at] column to a normalized version of the date/time value specified.
* *
@@ -627,10 +567,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
*/ */
public function hasOnlyDefaultValues() public function hasOnlyDefaultValues()
{ {
if ($this->is_default !== false) {
return false;
}
// otherwise, everything was equal, so return TRUE // otherwise, everything was equal, so return TRUE
return true; return true;
} // hasOnlyDefaultValues() } // hasOnlyDefaultValues()
@@ -667,16 +603,13 @@ abstract class AttributeCombination implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCombinationTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)]; $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCombinationTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)];
$this->product_sale_elements_id = (null !== $col) ? (int) $col : null; $this->product_sale_elements_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCombinationTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_default = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') { if ($col === '0000-00-00 00:00:00') {
$col = null; $col = null;
} }
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') { if ($col === '0000-00-00 00:00:00') {
$col = null; $col = null;
} }
@@ -689,7 +622,7 @@ abstract class AttributeCombination implements ActiveRecordInterface
$this->ensureConsistency(); $this->ensureConsistency();
} }
return $startcol + 6; // 6 = AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. return $startcol + 5; // 5 = AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\AttributeCombination object", 0, $e); throw new PropelException("Error populating \Thelia\Model\AttributeCombination object", 0, $e);
@@ -952,9 +885,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
if ($this->isColumnModified(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID)) { if ($this->isColumnModified(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID)) {
$modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID';
} }
if ($this->isColumnModified(AttributeCombinationTableMap::IS_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
}
if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) { if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT'; $modifiedColumns[':p' . $index++] = 'CREATED_AT';
} }
@@ -981,9 +911,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
case 'PRODUCT_SALE_ELEMENTS_ID': case 'PRODUCT_SALE_ELEMENTS_ID':
$stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT); $stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT);
break; break;
case 'IS_DEFAULT':
$stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
break;
case 'CREATED_AT': case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break; break;
@@ -1055,12 +982,9 @@ abstract class AttributeCombination implements ActiveRecordInterface
return $this->getProductSaleElementsId(); return $this->getProductSaleElementsId();
break; break;
case 3: case 3:
return $this->getIsDefault();
break;
case 4:
return $this->getCreatedAt(); return $this->getCreatedAt();
break; break;
case 5: case 4:
return $this->getUpdatedAt(); return $this->getUpdatedAt();
break; break;
default: default:
@@ -1095,9 +1019,8 @@ abstract class AttributeCombination implements ActiveRecordInterface
$keys[0] => $this->getAttributeId(), $keys[0] => $this->getAttributeId(),
$keys[1] => $this->getAttributeAvId(), $keys[1] => $this->getAttributeAvId(),
$keys[2] => $this->getProductSaleElementsId(), $keys[2] => $this->getProductSaleElementsId(),
$keys[3] => $this->getIsDefault(), $keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(),
$keys[5] => $this->getUpdatedAt(),
); );
$virtualColumns = $this->virtualColumns; $virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn) foreach($virtualColumns as $key => $virtualColumn)
@@ -1159,12 +1082,9 @@ abstract class AttributeCombination implements ActiveRecordInterface
$this->setProductSaleElementsId($value); $this->setProductSaleElementsId($value);
break; break;
case 3: case 3:
$this->setIsDefault($value);
break;
case 4:
$this->setCreatedAt($value); $this->setCreatedAt($value);
break; break;
case 5: case 4:
$this->setUpdatedAt($value); $this->setUpdatedAt($value);
break; break;
} // switch() } // switch()
@@ -1194,9 +1114,8 @@ abstract class AttributeCombination implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setAttributeId($arr[$keys[0]]); if (array_key_exists($keys[0], $arr)) $this->setAttributeId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setAttributeAvId($arr[$keys[1]]); if (array_key_exists($keys[1], $arr)) $this->setAttributeAvId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setProductSaleElementsId($arr[$keys[2]]); if (array_key_exists($keys[2], $arr)) $this->setProductSaleElementsId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setIsDefault($arr[$keys[3]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
} }
/** /**
@@ -1211,7 +1130,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id); if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id);
if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id); if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id);
if ($this->isColumnModified(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); if ($this->isColumnModified(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id);
if ($this->isColumnModified(AttributeCombinationTableMap::IS_DEFAULT)) $criteria->add(AttributeCombinationTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) $criteria->add(AttributeCombinationTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) $criteria->add(AttributeCombinationTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) $criteria->add(AttributeCombinationTableMap::UPDATED_AT, $this->updated_at); if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) $criteria->add(AttributeCombinationTableMap::UPDATED_AT, $this->updated_at);
@@ -1290,7 +1208,6 @@ abstract class AttributeCombination implements ActiveRecordInterface
$copyObj->setAttributeId($this->getAttributeId()); $copyObj->setAttributeId($this->getAttributeId());
$copyObj->setAttributeAvId($this->getAttributeAvId()); $copyObj->setAttributeAvId($this->getAttributeAvId());
$copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); $copyObj->setProductSaleElementsId($this->getProductSaleElementsId());
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt());
if ($makeNew) { if ($makeNew) {
@@ -1481,12 +1398,10 @@ abstract class AttributeCombination implements ActiveRecordInterface
$this->attribute_id = null; $this->attribute_id = null;
$this->attribute_av_id = null; $this->attribute_av_id = null;
$this->product_sale_elements_id = null; $this->product_sale_elements_id = null;
$this->is_default = null;
$this->created_at = null; $this->created_at = null;
$this->updated_at = null; $this->updated_at = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->clearAllReferences(); $this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified(); $this->resetModified();
$this->setNew(true); $this->setNew(true);
$this->setDeleted(false); $this->setDeleted(false);

View File

@@ -24,14 +24,12 @@ use Thelia\Model\Map\AttributeCombinationTableMap;
* @method ChildAttributeCombinationQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column * @method ChildAttributeCombinationQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column
* @method ChildAttributeCombinationQuery orderByAttributeAvId($order = Criteria::ASC) Order by the attribute_av_id column * @method ChildAttributeCombinationQuery orderByAttributeAvId($order = Criteria::ASC) Order by the attribute_av_id column
* @method ChildAttributeCombinationQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column * @method ChildAttributeCombinationQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column
* @method ChildAttributeCombinationQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
* @method ChildAttributeCombinationQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAttributeCombinationQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildAttributeCombinationQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @method ChildAttributeCombinationQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* *
* @method ChildAttributeCombinationQuery groupByAttributeId() Group by the attribute_id column * @method ChildAttributeCombinationQuery groupByAttributeId() Group by the attribute_id column
* @method ChildAttributeCombinationQuery groupByAttributeAvId() Group by the attribute_av_id column * @method ChildAttributeCombinationQuery groupByAttributeAvId() Group by the attribute_av_id column
* @method ChildAttributeCombinationQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildAttributeCombinationQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column
* @method ChildAttributeCombinationQuery groupByIsDefault() Group by the is_default column
* @method ChildAttributeCombinationQuery groupByCreatedAt() Group by the created_at column * @method ChildAttributeCombinationQuery groupByCreatedAt() Group by the created_at column
* @method ChildAttributeCombinationQuery groupByUpdatedAt() Group by the updated_at column * @method ChildAttributeCombinationQuery groupByUpdatedAt() Group by the updated_at column
* *
@@ -57,14 +55,12 @@ use Thelia\Model\Map\AttributeCombinationTableMap;
* @method ChildAttributeCombination findOneByAttributeId(int $attribute_id) Return the first ChildAttributeCombination filtered by the attribute_id column * @method ChildAttributeCombination findOneByAttributeId(int $attribute_id) Return the first ChildAttributeCombination filtered by the attribute_id column
* @method ChildAttributeCombination findOneByAttributeAvId(int $attribute_av_id) Return the first ChildAttributeCombination filtered by the attribute_av_id column * @method ChildAttributeCombination findOneByAttributeAvId(int $attribute_av_id) Return the first ChildAttributeCombination filtered by the attribute_av_id column
* @method ChildAttributeCombination findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildAttributeCombination filtered by the product_sale_elements_id column * @method ChildAttributeCombination findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildAttributeCombination filtered by the product_sale_elements_id column
* @method ChildAttributeCombination findOneByIsDefault(boolean $is_default) Return the first ChildAttributeCombination filtered by the is_default column
* @method ChildAttributeCombination findOneByCreatedAt(string $created_at) Return the first ChildAttributeCombination filtered by the created_at column * @method ChildAttributeCombination findOneByCreatedAt(string $created_at) Return the first ChildAttributeCombination filtered by the created_at column
* @method ChildAttributeCombination findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeCombination filtered by the updated_at column * @method ChildAttributeCombination findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeCombination filtered by the updated_at column
* *
* @method array findByAttributeId(int $attribute_id) Return ChildAttributeCombination objects filtered by the attribute_id column * @method array findByAttributeId(int $attribute_id) Return ChildAttributeCombination objects filtered by the attribute_id column
* @method array findByAttributeAvId(int $attribute_av_id) Return ChildAttributeCombination objects filtered by the attribute_av_id column * @method array findByAttributeAvId(int $attribute_av_id) Return ChildAttributeCombination objects filtered by the attribute_av_id column
* @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildAttributeCombination objects filtered by the product_sale_elements_id column * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildAttributeCombination objects filtered by the product_sale_elements_id column
* @method array findByIsDefault(boolean $is_default) Return ChildAttributeCombination objects filtered by the is_default column
* @method array findByCreatedAt(string $created_at) Return ChildAttributeCombination objects filtered by the created_at column * @method array findByCreatedAt(string $created_at) Return ChildAttributeCombination objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildAttributeCombination objects filtered by the updated_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAttributeCombination objects filtered by the updated_at column
* *
@@ -155,7 +151,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria
*/ */
protected function findPkSimple($key, $con) protected function findPkSimple($key, $con)
{ {
$sql = 'SELECT ATTRIBUTE_ID, ATTRIBUTE_AV_ID, PRODUCT_SALE_ELEMENTS_ID, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM attribute_combination WHERE ATTRIBUTE_ID = :p0 AND ATTRIBUTE_AV_ID = :p1 AND PRODUCT_SALE_ELEMENTS_ID = :p2'; $sql = 'SELECT ATTRIBUTE_ID, ATTRIBUTE_AV_ID, PRODUCT_SALE_ELEMENTS_ID, CREATED_AT, UPDATED_AT FROM attribute_combination WHERE ATTRIBUTE_ID = :p0 AND ATTRIBUTE_AV_ID = :p1 AND PRODUCT_SALE_ELEMENTS_ID = :p2';
try { try {
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
@@ -389,33 +385,6 @@ abstract class AttributeCombinationQuery extends ModelCriteria
return $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison); return $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison);
} }
/**
* Filter the query on the is_default column
*
* Example usage:
* <code>
* $query->filterByIsDefault(true); // WHERE is_default = true
* $query->filterByIsDefault('yes'); // WHERE is_default = true
* </code>
*
* @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 ChildAttributeCombinationQuery 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(AttributeCombinationTableMap::IS_DEFAULT, $isDefault, $comparison);
}
/** /**
* Filter the query on the created_at column * Filter the query on the created_at column
* *

View File

@@ -103,10 +103,18 @@ abstract class ProductSaleElements implements ActiveRecordInterface
/** /**
* The value for the weight field. * The value for the weight field.
* Note: this column has a database default value of: 0
* @var double * @var double
*/ */
protected $weight; 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. * The value for the created_at field.
* @var string * @var string
@@ -178,6 +186,8 @@ abstract class ProductSaleElements implements ActiveRecordInterface
{ {
$this->promo = 0; $this->promo = 0;
$this->newness = 0; $this->newness = 0;
$this->weight = 0;
$this->is_default = false;
} }
/** /**
@@ -513,6 +523,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->weight; 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. * Get the [optionally formatted] temporal [created_at] column value.
* *
@@ -704,6 +725,35 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this; return $this;
} // setWeight() } // 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. * 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; return false;
} }
if ($this->weight !== 0) {
return false;
}
if ($this->is_default !== false) {
return false;
}
// otherwise, everything was equal, so return TRUE // otherwise, everything was equal, so return TRUE
return true; return true;
} // hasOnlyDefaultValues() } // 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)]; $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
$this->weight = (null !== $col) ? (double) $col : null; $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') { if ($col === '0000-00-00 00:00:00') {
$col = null; $col = null;
} }
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : 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') { if ($col === '0000-00-00 00:00:00') {
$col = null; $col = null;
} }
@@ -831,7 +892,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->ensureConsistency(); $this->ensureConsistency();
} }
return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. return $startcol + 10; // 10 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $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)) { if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) {
$modifiedColumns[':p' . $index++] = 'WEIGHT'; $modifiedColumns[':p' . $index++] = 'WEIGHT';
} }
if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
}
if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT'; $modifiedColumns[':p' . $index++] = 'CREATED_AT';
} }
@@ -1183,6 +1247,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
case 'WEIGHT': case 'WEIGHT':
$stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
break; break;
case 'IS_DEFAULT':
$stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
break;
case 'CREATED_AT': case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break; break;
@@ -1273,9 +1340,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
return $this->getWeight(); return $this->getWeight();
break; break;
case 7: case 7:
return $this->getCreatedAt(); return $this->getIsDefault();
break; break;
case 8: case 8:
return $this->getCreatedAt();
break;
case 9:
return $this->getUpdatedAt(); return $this->getUpdatedAt();
break; break;
default: default:
@@ -1314,8 +1384,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$keys[4] => $this->getPromo(), $keys[4] => $this->getPromo(),
$keys[5] => $this->getNewness(), $keys[5] => $this->getNewness(),
$keys[6] => $this->getWeight(), $keys[6] => $this->getWeight(),
$keys[7] => $this->getCreatedAt(), $keys[7] => $this->getIsDefault(),
$keys[8] => $this->getUpdatedAt(), $keys[8] => $this->getCreatedAt(),
$keys[9] => $this->getUpdatedAt(),
); );
$virtualColumns = $this->virtualColumns; $virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn) foreach($virtualColumns as $key => $virtualColumn)
@@ -1392,9 +1463,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->setWeight($value); $this->setWeight($value);
break; break;
case 7: case 7:
$this->setCreatedAt($value); $this->setIsDefault($value);
break; break;
case 8: case 8:
$this->setCreatedAt($value);
break;
case 9:
$this->setUpdatedAt($value); $this->setUpdatedAt($value);
break; break;
} // switch() } // 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[4], $arr)) $this->setPromo($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]); 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[6], $arr)) $this->setWeight($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); if (array_key_exists($keys[7], $arr)) $this->setIsDefault($arr[$keys[7]]);
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); 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::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo);
if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness); 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::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::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_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->setPromo($this->getPromo());
$copyObj->setNewness($this->getNewness()); $copyObj->setNewness($this->getNewness());
$copyObj->setWeight($this->getWeight()); $copyObj->setWeight($this->getWeight());
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -2445,6 +2522,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
$this->promo = null; $this->promo = null;
$this->newness = null; $this->newness = null;
$this->weight = null; $this->weight = null;
$this->is_default = null;
$this->created_at = null; $this->created_at = null;
$this->updated_at = null; $this->updated_at = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;

View File

@@ -28,6 +28,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
* @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column * @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column
* @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness 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 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 orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildProductSaleElementsQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_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 groupByPromo() Group by the promo column
* @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column * @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column
* @method ChildProductSaleElementsQuery groupByWeight() Group by the weight 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 groupByCreatedAt() Group by the created_at column
* @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_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 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 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 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 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 * @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 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 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 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 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 * @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) 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 { try {
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -537,6 +541,33 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison); return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison);
} }
/**
* Filter the query on the is_default column
*
* Example usage:
* <code>
* $query->filterByIsDefault(true); // WHERE is_default = true
* $query->filterByIsDefault('yes'); // WHERE is_default = true
* </code>
*
* @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 * Filter the query on the created_at column
* *

View File

@@ -57,7 +57,7 @@ class AttributeCombinationTableMap extends TableMap
/** /**
* The total number of columns * The total number of columns
*/ */
const NUM_COLUMNS = 6; const NUM_COLUMNS = 5;
/** /**
* The number of lazy-loaded columns * The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class AttributeCombinationTableMap extends TableMap
/** /**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/ */
const NUM_HYDRATE_COLUMNS = 6; const NUM_HYDRATE_COLUMNS = 5;
/** /**
* the column name for the ATTRIBUTE_ID field * the column name for the ATTRIBUTE_ID field
@@ -84,11 +84,6 @@ class AttributeCombinationTableMap extends TableMap
*/ */
const PRODUCT_SALE_ELEMENTS_ID = 'attribute_combination.PRODUCT_SALE_ELEMENTS_ID'; const PRODUCT_SALE_ELEMENTS_ID = 'attribute_combination.PRODUCT_SALE_ELEMENTS_ID';
/**
* the column name for the IS_DEFAULT field
*/
const IS_DEFAULT = 'attribute_combination.IS_DEFAULT';
/** /**
* the column name for the CREATED_AT field * the column name for the CREATED_AT field
*/ */
@@ -111,12 +106,12 @@ class AttributeCombinationTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
protected static $fieldNames = array ( protected static $fieldNames = array (
self::TYPE_PHPNAME => array('AttributeId', 'AttributeAvId', 'ProductSaleElementsId', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), self::TYPE_PHPNAME => array('AttributeId', 'AttributeAvId', 'ProductSaleElementsId', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('attributeId', 'attributeAvId', 'productSaleElementsId', 'isDefault', 'createdAt', 'updatedAt', ), self::TYPE_STUDLYPHPNAME => array('attributeId', 'attributeAvId', 'productSaleElementsId', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID, AttributeCombinationTableMap::ATTRIBUTE_AV_ID, AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, AttributeCombinationTableMap::IS_DEFAULT, AttributeCombinationTableMap::CREATED_AT, AttributeCombinationTableMap::UPDATED_AT, ), self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID, AttributeCombinationTableMap::ATTRIBUTE_AV_ID, AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, AttributeCombinationTableMap::CREATED_AT, AttributeCombinationTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID', 'ATTRIBUTE_AV_ID', 'PRODUCT_SALE_ELEMENTS_ID', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID', 'ATTRIBUTE_AV_ID', 'PRODUCT_SALE_ELEMENTS_ID', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('attribute_id', 'attribute_av_id', 'product_sale_elements_id', 'is_default', 'created_at', 'updated_at', ), self::TYPE_FIELDNAME => array('attribute_id', 'attribute_av_id', 'product_sale_elements_id', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) self::TYPE_NUM => array(0, 1, 2, 3, 4, )
); );
/** /**
@@ -126,12 +121,12 @@ class AttributeCombinationTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/ */
protected static $fieldKeys = array ( protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('AttributeId' => 0, 'AttributeAvId' => 1, 'ProductSaleElementsId' => 2, 'IsDefault' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), self::TYPE_PHPNAME => array('AttributeId' => 0, 'AttributeAvId' => 1, 'ProductSaleElementsId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
self::TYPE_STUDLYPHPNAME => array('attributeId' => 0, 'attributeAvId' => 1, 'productSaleElementsId' => 2, 'isDefault' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), self::TYPE_STUDLYPHPNAME => array('attributeId' => 0, 'attributeAvId' => 1, 'productSaleElementsId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID => 0, AttributeCombinationTableMap::ATTRIBUTE_AV_ID => 1, AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID => 2, AttributeCombinationTableMap::IS_DEFAULT => 3, AttributeCombinationTableMap::CREATED_AT => 4, AttributeCombinationTableMap::UPDATED_AT => 5, ), self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID => 0, AttributeCombinationTableMap::ATTRIBUTE_AV_ID => 1, AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID => 2, AttributeCombinationTableMap::CREATED_AT => 3, AttributeCombinationTableMap::UPDATED_AT => 4, ),
self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID' => 0, 'ATTRIBUTE_AV_ID' => 1, 'PRODUCT_SALE_ELEMENTS_ID' => 2, 'IS_DEFAULT' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID' => 0, 'ATTRIBUTE_AV_ID' => 1, 'PRODUCT_SALE_ELEMENTS_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
self::TYPE_FIELDNAME => array('attribute_id' => 0, 'attribute_av_id' => 1, 'product_sale_elements_id' => 2, 'is_default' => 3, 'created_at' => 4, 'updated_at' => 5, ), self::TYPE_FIELDNAME => array('attribute_id' => 0, 'attribute_av_id' => 1, 'product_sale_elements_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) self::TYPE_NUM => array(0, 1, 2, 3, 4, )
); );
/** /**
@@ -153,7 +148,6 @@ class AttributeCombinationTableMap extends TableMap
$this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null); $this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null);
$this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null); $this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
$this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null); $this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null);
$this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize() } // initialize()
@@ -371,14 +365,12 @@ class AttributeCombinationTableMap extends TableMap
$criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_ID); $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_ID);
$criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_AV_ID); $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_AV_ID);
$criteria->addSelectColumn(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID);
$criteria->addSelectColumn(AttributeCombinationTableMap::IS_DEFAULT);
$criteria->addSelectColumn(AttributeCombinationTableMap::CREATED_AT); $criteria->addSelectColumn(AttributeCombinationTableMap::CREATED_AT);
$criteria->addSelectColumn(AttributeCombinationTableMap::UPDATED_AT); $criteria->addSelectColumn(AttributeCombinationTableMap::UPDATED_AT);
} else { } else {
$criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
$criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID');
$criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID');
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT');
} }

View File

@@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap
/** /**
* The total number of columns * The total number of columns
*/ */
const NUM_COLUMNS = 9; const NUM_COLUMNS = 10;
/** /**
* The number of lazy-loaded columns * 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) * 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 * the column name for the ID field
@@ -104,6 +104,11 @@ class ProductSaleElementsTableMap extends TableMap
*/ */
const WEIGHT = 'product_sale_elements.WEIGHT'; 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 * 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' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
protected static $fieldNames = array ( protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ), 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', '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::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), 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', 'CREATED_AT', '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', '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, ) 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 * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/ */
protected static $fieldKeys = array ( 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_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, 'createdAt' => 7, 'updatedAt' => 8, ), 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::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 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::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, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), 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, '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, 'is_default' => 7, 'created_at' => 8, 'updated_at' => 9, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
); );
/** /**
@@ -171,7 +176,8 @@ class ProductSaleElementsTableMap extends TableMap
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
$this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0); $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
$this->addColumn('NEWNESS', 'Newness', '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('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize() } // initialize()
@@ -355,6 +361,7 @@ class ProductSaleElementsTableMap extends TableMap
$criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO); $criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO);
$criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS); $criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS);
$criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT); $criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT);
$criteria->addSelectColumn(ProductSaleElementsTableMap::IS_DEFAULT);
$criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT); $criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT);
$criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT); $criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT);
} else { } else {
@@ -365,6 +372,7 @@ class ProductSaleElementsTableMap extends TableMap
$criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.PROMO');
$criteria->addSelectColumn($alias . '.NEWNESS'); $criteria->addSelectColumn($alias . '.NEWNESS');
$criteria->addSelectColumn($alias . '.WEIGHT'); $criteria->addSelectColumn($alias . '.WEIGHT');
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT');
} }

View File

@@ -108,7 +108,7 @@ class Product extends BaseProduct
->setProduct($this) ->setProduct($this)
->setCategoryId($defaultCategoryId) ->setCategoryId($defaultCategoryId)
->setDefaultCategory(true) ->setDefaultCategory(true)
->save($con) ->save()
; ;
} }
} }

View File

@@ -325,7 +325,6 @@ CREATE TABLE `attribute_combination`
`attribute_id` INTEGER NOT NULL, `attribute_id` INTEGER NOT NULL,
`attribute_av_id` INTEGER NOT NULL, `attribute_av_id` INTEGER NOT NULL,
`product_sale_elements_id` INTEGER NOT NULL, `product_sale_elements_id` INTEGER NOT NULL,
`is_default` TINYINT(1) DEFAULT 0,
`created_at` DATETIME, `created_at` DATETIME,
`updated_at` DATETIME, `updated_at` DATETIME,
PRIMARY KEY (`attribute_id`,`attribute_av_id`,`product_sale_elements_id`), PRIMARY KEY (`attribute_id`,`attribute_av_id`,`product_sale_elements_id`),
@@ -363,7 +362,8 @@ CREATE TABLE `product_sale_elements`
`quantity` FLOAT NOT NULL, `quantity` FLOAT NOT NULL,
`promo` TINYINT DEFAULT 0, `promo` TINYINT DEFAULT 0,
`newness` TINYINT DEFAULT 0, `newness` TINYINT DEFAULT 0,
`weight` FLOAT, `weight` FLOAT DEFAULT 0,
`is_default` TINYINT(1) DEFAULT 0,
`created_at` DATETIME, `created_at` DATETIME,
`updated_at` DATETIME, `updated_at` DATETIME,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),

View File

@@ -55,7 +55,7 @@
</behavior> </behavior>
</table> </table>
<table isCrossRef="true" name="product_category" namespace="Thelia\Model"> <table isCrossRef="true" name="product_category" namespace="Thelia\Model">
<column name="product_id" primaryKey="true" required="true" type="INTEGER" /> <column name="product_id" primaryKey="true" required="true" type="INTEGER" />
<column name="category_id" primaryKey="true" type="INTEGER" /> <column name="category_id" primaryKey="true" type="INTEGER" />
<column name="default_category" type="BOOLEAN" /> <column name="default_category" type="BOOLEAN" />
<foreign-key foreignTable="product" name="fk_product_has_category_product1" onDelete="CASCADE" onUpdate="RESTRICT"> <foreign-key foreignTable="product" name="fk_product_has_category_product1" onDelete="CASCADE" onUpdate="RESTRICT">
@@ -254,7 +254,6 @@
<table name="attribute_combination" namespace="Thelia\Model"> <table name="attribute_combination" namespace="Thelia\Model">
<column name="attribute_id" primaryKey="true" required="true" type="INTEGER" /> <column name="attribute_id" primaryKey="true" required="true" type="INTEGER" />
<column name="attribute_av_id" primaryKey="true" required="true" type="INTEGER" /> <column name="attribute_av_id" primaryKey="true" required="true" type="INTEGER" />
<column name="product_sale_elements_id" primaryKey="true" required="true" type="INTEGER" />
<column name="product_sale_elements_id" primaryKey="true" required="true" type="INTEGER" /> <column name="product_sale_elements_id" primaryKey="true" required="true" type="INTEGER" />
<foreign-key foreignTable="attribute" name="fk_attribute_combination_attribute_id" onDelete="CASCADE" onUpdate="RESTRICT"> <foreign-key foreignTable="attribute" name="fk_attribute_combination_attribute_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="attribute_id" /> <reference foreign="id" local="attribute_id" />
@@ -282,7 +281,8 @@
<column name="ref" required="true" size="255" type="VARCHAR" /> <column name="ref" required="true" size="255" type="VARCHAR" />
<column name="quantity" required="true" type="FLOAT" /> <column name="quantity" required="true" type="FLOAT" />
<column defaultValue="0" name="promo" type="TINYINT" /> <column defaultValue="0" name="promo" type="TINYINT" />
<column defaultValue="0" name="newness" type="TINYINT" /> <column defaultValue="0" name="newness" type="TINYINT" />
<column defaultValue="0" name="weight" type="FLOAT" />
<column defaultValue="0" name="is_default" type="BOOLEAN" /> <column defaultValue="0" name="is_default" type="BOOLEAN" />
<foreign-key foreignTable="product" name="fk_product_sale_element_product_id" onDelete="CASCADE" onUpdate="RESTRICT"> <foreign-key foreignTable="product" name="fk_product_sale_element_product_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="product_id" /> <reference foreign="id" local="product_id" />

View File

@@ -1,157 +1,175 @@
<div class="form-container"> <div class="form-container">
<form method="POST" action="{url path="/admin/product/$ID/update-attributes-and-features"}" id="attribute_form">
<input type="hidden" name="product_id" value="{$product_id}" /> <div class="row">
<input type="hidden" name="current_tab" value="attributes" /> <div class="col-md-12">
<form method="POST" class="clearfix" action="{url path="/admin/product/$ID/set-product-template"}" id="product_template_form">
{include <input type="hidden" name="product_id" value="{$product_id}" />
file="includes/inner-form-toolbar.html" <input type="hidden" name="current_tab" value="attributes" />
hide_submit_buttons=false
close_url="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
<div class="alert alert-info"> <div class="row">
{intl l="To use features or attributes on this product, please select a product template. You can define product templates in the Configuration section of the administration."} <div class="col-md-12">
</div> <div class="well">
<p>{intl l="To use features or attributes on this product, please select a product template. You can define product templates in the Configuration section of the administration."}</p>
<div class="row"> <label for="template_id" class="control-label">
<div class="col-md-6"> {intl l='Current product template'} :
<label for="template_id" class="control-label"> </label>
{intl l='Product template'} :
</label>
<div class="input-group"> <div class="input-group">
<select required="required" name="template_id" id="template_id" class="form-control"> <select required="required" name="template_id" id="template_id" class="form-control">
<option value="">{intl l='Select a product template...'}</option> <option value="0">{intl l='Do not use a product template'}</option>
{loop name="product_template_select" type="template"} {loop name="product_template_select" type="template"}
<option value="{$ID}" {if $TEMPLATE == $ID}selected="selected"{/if}>{$NAME}</option> <option value="{$ID}" {if $TEMPLATE == $ID}selected="selected"{/if}>{$NAME}</option>
{/loop} {/loop}
</select> </select>
<span class="input-group-btn" id="apply_template_button"> <span class="input-group-btn" id="apply_template_button">
<button class="btn btn-default btn-primary action-btn" type="button">{intl l="Apply this template"}</button> <button class="btn btn-default btn-primary action-btn" type="submit">{intl l="Apply this template"}</button>
</span> </span>
</div> </div>
</div> </div>
</div>
{ifloop rel="product_template"}
{* -- Begin attributes management ------------------------------- *}
<div class="row">
{loop name="product_template" type="template" id={$TEMPLATE|default:0}}{/loop}
<div class="col-md-12">
<div class="form-group">
<p class="title title-without-tabs">{intl l='Product Attributes'}</p>
</div> </div>
</div> </div>
</div> </form>
</div>
</div>
{* -- End attributes management ---------------------------------- *} {* Check if a product template is defined *}
{* -- Begin features management ---------------------------------- *} {loop name="product_template" type="template" id={$TEMPLATE|default:0}}{/loop}
<div class="row"> {ifloop rel="product_template"}
<div class="col-md-12"> <div class="row">
<div class="form-group"> <div class="col-md-12">
<p class="title title-without-tabs">{intl l='Product Attributes and Features'}</p>
<p class="title title-without-tabs">{intl l='Product Features'}</p> <form method="POST" action="{url path="/admin/product/$ID/update-attributes-and-features"}" id="attribute_form">
<p>{intl l='Enter here product features'}</p>
<div class="table-responsive"> <input type="hidden" name="product_id" value="{$product_id}" />
<table class="table table-striped table-condensed table-left-aligned"> <input type="hidden" name="current_tab" value="attributes" />
<thead>
<tr>
<th>{intl l='Feature Name'}</th>
<th>{intl l='Feature value for this product'}</th>
{module_include location='product_features_table_header'} {include
file="includes/inner-form-toolbar.html"
hide_submit_buttons=false
close_url="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
</tr>
</thead>
<tbody> {* -- Begin attributes management ------------------------------- *}
{loop name="product-features" type="feature" order="manual" product="$product_id" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$TITLE}</td>
<td> <div class="row">
{* Multiple values *} <div class="col-md-12">
<div class="form-group">
<p class="title title-without-tabs">{intl l='Product Attributes'}</p>
{ifloop rel="product-features-av"} <div class="alert alert-danger">Please code me baby, oh yeah ! Code me NOW !</div>
</div>
</div>
</div>
{loop name="free-text-value" exclude_free_text="true" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"} {* -- Begin features management ---------------------------------- *}
value={$FEATURE_AV_ID}: {$TITLE}<br />
{/loop}
{capture "select_options"} <div class="row">
{loop name="product-features-av" type="feature-availability" feature=$ID order="manual" backend_context="1" lang="$edit_language_id"} <div class="col-md-12">
<option value="{$ID}">{$TITLE}</option> <div class="form-group">
{$options_count = $LOOP_COUNT} {* LOOP_COUNT is only available inside the loop ! *} <p class="title title-without-tabs">{intl l='Product Features'}</p>
{/loop}
{/capture}
<div class="input-form"> <div class="table-responsive">
<select multiple="multiple" name="feature_value[{$ID}][]" id="feature_value_{$ID}" size="{$options_count}" class="form-control"> <table class="table table-striped table-condensed table-left-aligned">
{$smarty.capture.select_options nofilter} <thead>
</select> <tr>
</div> <th>{intl l='Feature Name'}</th>
<th>{intl l='Feature value for this product'}</th>
<span class="help-block text-right"> {module_include location='product_features_table_header'}
{intl l='Use ctrl+clic to select more than one value. You can also <a href="#" class="clear_feature_value" data-id="%id">clear selected values</a>.' id=$ID}
</span>
{/ifloop} </tr>
</thead>
{* Free feature *} <tbody>
{loop name="product-features" type="feature" order="manual" product="$product_id" backend_context="1" lang="$edit_language_id"}
<tr>
<td>{$TITLE}</td>
{elseloop rel="product-features-av"} <td>
{* Get the free text value *} {* Multiple values *}
{loop name="free-text-value" exclude_feature_availability="1" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"} {ifloop rel="product-features-av"}
{$feature_value=$FREE_TEXT_VALUE}
{/loop}
<input type="text" id="feature_text_value_{$ID}" name="feature_text_value[{$ID}]" title="{intl l='Enter here the feature value as free text'}" placeholder="{intl l='Feature value'}" class="form-control" value="{$feature_value|default:''}"> {* load all selected values in an array to speed up things a little *}
{/elseloop}
</td>
{module_include location='product_features_table_row'} {$selected = array()}
</tr> {loop name="free-text-value" exclude_free_text="true" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"}
{/loop} {$selected[] = $FEATURE_AV_ID}
{/loop}
{elseloop rel="product-features"} {capture "select_options"}
<tr> {loop name="product-features-av" type="feature-availability" feature=$ID order="manual" backend_context="1" lang="$edit_language_id"}
<td> <option value="{$ID}" {if in_array($ID, $selected)}selected="selected"{/if}>{$TITLE}</option>
<div class="alert alert-info">
{intl l="This product contains no features"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</div>
{* -- End features management ------------------------------- *} {$options_count = $LOOP_COUNT} {* LOOP_COUNT is only available inside the loop ! *}
</div> {/loop}
{/ifloop} {/capture}
{elseloop rel="product_template"} <div class="input-form">
<div class="row"> <select multiple="multiple" name="feature_value[{$ID}][]" id="feature_value_{$ID}" size="{$options_count}" class="form-control">
<div class="col-md-12"> {$smarty.capture.select_options nofilter}
</select>
</div>
<div class="alert alert-info"> <span class="help-block text-right">
{intl l="This product is not attached to any product template. If you want to use features or attributes on this product, please select the proper template. You can define product templates in the Configuration section."} {intl l='Use ctrl+clic to select more than one value. You can also <a href="#" class="clear_feature_value" data-id="%id">clear selected values</a>.' id=$ID}
</div> </span>
</div> {/ifloop}
{* Free text *}
{elseloop rel="product-features-av"}
{* Get the free text value *}
{loop name="free-text-value" exclude_feature_availability="1" type="feature_value" product=$product_id feature=$ID backend_context="1" lang="$edit_language_id"}
{$feature_value=$FREE_TEXT_VALUE}
{/loop}
<input type="text" id="feature_text_value_{$ID}" name="feature_text_value[{$ID}]" title="{intl l='Enter here the feature value as free text'}" placeholder="{intl l='Feature value'}" class="form-control" value="{$feature_value|default:''}">
{/elseloop}
</td>
{module_include location='product_features_table_row'}
</tr>
{/loop}
{elseloop rel="product-features"}
<tr>
<td>
<div class="alert alert-info">
{intl l="This product contains no features"}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
</div> </div>
{/elseloop} </div>
{/ifloop}
</form> {elseloop rel="product_template"}
<div class="row">
<div class="col-md-12">
<p></p> {* bouuuuuh ! *}
<div class="alert alert-info">
{intl l="This product is not attached to any product template. If you want to use features or attributes on this product, please select the proper template. You can define product templates in the Configuration section."}
</div>
</div>
</div>
{/elseloop}
</div> </div>

View File

@@ -17,7 +17,7 @@
{/form_field} {/form_field}
{form_field form=$form field='success_url'} {form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/product' product_id={$product_d}}" /> <input type="hidden" name="{$name}" value="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" />
{/form_field} {/form_field}
{form_field form=$form field='locale'} {form_field form=$form field='locale'}