diff --git a/.travis.yml b/.travis.yml index 8e2c7321a..1ed4aba4a 100755 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - DB_USER=root before_script: + - composer self-update - composer install --prefer-dist --dev - sh -c "mysql -u$DB_USER -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS thelia;SET FOREIGN_KEY_CHECKS = 1;'; fi" - php Thelia thelia:install --db_host=localhost --db_username=$DB_USER --db_name=thelia diff --git a/composer.json b/composer.json index 585a66318..5e86dad43 100755 --- a/composer.json +++ b/composer.json @@ -27,9 +27,9 @@ "symfony-cmf/routing": "1.0.0", "symfony/form": "2.2.*", - "symfony/validator": "2.2.*", + "symfony/validator": "2.3.*", - "smarty/smarty": "v3.1.13", + "smarty/smarty": "v3.1.14", "kriswallsmith/assetic": "1.2.*@dev", "leafo/lessphp": "0.3.*@dev", "ptachoire/cssembed": "dev-master", diff --git a/composer.lock b/composer.lock index 49b274719..45044d90c 100755 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "8ccfaf90277960280975fa78b6c7d3a1", + "hash": "b20fbb4995fbf676a7028034f21cfbe0", "packages": [ { "name": "ezyang/htmlpurifier", @@ -395,11 +395,11 @@ }, { "name": "smarty/smarty", - "version": "v3.1.13", + "version": "v3.1.14", "source": { "type": "svn", "url": "http://smarty-php.googlecode.com/svn", - "reference": "/tags/v3.1.13/@4699" + "reference": "/tags/v3.1.14/@4752" }, "require": { "php": ">=5.2" @@ -408,7 +408,8 @@ "autoload": { "classmap": [ "distribution/libs/Smarty.class.php", - "distribution/libs/SmartyBC.class.php" + "distribution/libs/SmartyBC.class.php", + "distribution/libs/sysplugins/smarty_security.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -434,7 +435,7 @@ "keywords": [ "templating" ], - "time": "2013-01-26 12:03:52" + "time": "2013-07-02 16:38:47" }, { "name": "symfony-cmf/routing", @@ -1455,17 +1456,17 @@ }, { "name": "symfony/validator", - "version": "v2.2.4", + "version": "v2.3.2", "target-dir": "Symfony/Component/Validator", "source": { "type": "git", "url": "https://github.com/symfony/Validator.git", - "reference": "v2.2.4" + "reference": "v2.3.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.4", - "reference": "v2.2.4", + "url": "https://api.github.com/repos/symfony/Validator/zipball/v2.3.2", + "reference": "v2.3.2", "shasum": "" }, "require": { @@ -1473,22 +1474,22 @@ "symfony/translation": "~2.0" }, "require-dev": { - "symfony/config": ">=2.2,<2.3-dev", + "symfony/config": "~2.2", "symfony/http-foundation": "~2.1", - "symfony/locale": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.0" }, "suggest": { - "doctrine/common": "~2.2", - "symfony/config": "2.2.*", - "symfony/http-foundation": "2.2.*", - "symfony/locale": "2.2.*", - "symfony/yaml": "2.2.*" + "doctrine/common": "", + "symfony/config": "", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1512,7 +1513,7 @@ ], "description": "Symfony Validator Component", "homepage": "http://symfony.com", - "time": "2013-07-02 07:41:45" + "time": "2013-07-08 13:36:15" }, { "name": "symfony/yaml", diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 61629bde8..8634feabb 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -23,10 +23,12 @@ namespace Thelia\Action; +use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; use Thelia\Core\HttpFoundation\Session\Session; +use Thelia\Form\CartAdd; use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\Customer; @@ -42,9 +44,33 @@ class Cart implements EventSubscriberInterface */ public function addArticle(ActionEvent $event) { + $request = $event->getRequest(); + if ($request->isMethod("post")) { + $cartAdd = new CartAdd($request); + } else { + $cartAdd = new CartAdd( + $request, + "form", + array(), + array( + 'csrf_protection' => false, + ) + ); + } + + $form = $cartAdd->getForm(); + + $form->bind($request); + + if($form->isValid()) { + + } else { + var_dump($form->createView()); + } } + /** * * Delete specify article present into cart diff --git a/core/lib/Thelia/Action/Exception/ActionException.php b/core/lib/Thelia/Action/Exception/ActionException.php new file mode 100644 index 000000000..88213df94 --- /dev/null +++ b/core/lib/Thelia/Action/Exception/ActionException.php @@ -0,0 +1,29 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Action\Exception; + + +class ActionException extends \RuntimeException +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Exception/ProductNotFoundException.php b/core/lib/Thelia/Action/Exception/ProductNotFoundException.php new file mode 100644 index 000000000..67df9fd6f --- /dev/null +++ b/core/lib/Thelia/Action/Exception/ProductNotFoundException.php @@ -0,0 +1,29 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action\Exception; + + +class ProductNotFoundException extends ActionException { + +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Exception/StockNotFoundException.php b/core/lib/Thelia/Action/Exception/StockNotFoundException.php new file mode 100644 index 000000000..d47979273 --- /dev/null +++ b/core/lib/Thelia/Action/Exception/StockNotFoundException.php @@ -0,0 +1,30 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action\Exception; + + +class StockNotFoundException extends ActionException +{ + +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 0b2304704..0816f9958 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -6,9 +6,7 @@ - Thelia\Core\Event\CartEvent - Thelia\Core\Event\CartEvent - Thelia\Core\Event\CartEvent + diff --git a/core/lib/Thelia/Core/Event/CartEvent.php b/core/lib/Thelia/Core/Event/CartEvent.php new file mode 100644 index 000000000..92092f154 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CartEvent.php @@ -0,0 +1,58 @@ +. */ +/* */ +/*************************************************************************************/ + + +namespace Thelia\Core\Event; + + +use Thelia\Model\Cart; + +class CartEvent extends InternalEvent { + + protected $cart; + protected $modified; + + public function __construct(Cart $cart) + { + $this->cart = $cart; + $this->modified = false; + } + + public function setCart(Cart $cart) + { + $this->cart = $cart; + $this->modified = true; + } + + public function getCart() + { + return $this->cart; + } + + public function isModified() + { + return $this->modified; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/DefaultActionEvent.php b/core/lib/Thelia/Core/Event/DefaultActionEvent.php index 0f041dfeb..af7477840 100755 --- a/core/lib/Thelia/Core/Event/DefaultActionEvent.php +++ b/core/lib/Thelia/Core/Event/DefaultActionEvent.php @@ -1,11 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Core\Event; diff --git a/core/lib/Thelia/Core/Event/InternalEvent.php b/core/lib/Thelia/Core/Event/InternalEvent.php new file mode 100644 index 000000000..3452a8f0d --- /dev/null +++ b/core/lib/Thelia/Core/Event/InternalEvent.php @@ -0,0 +1,37 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +use Symfony\Component\EventDispatcher\Event; + +/** + * Base class used for internal event like creating new Customer, adding item to cart, etc + * + * Class InternalEvent + * @package Thelia\Core\Event + */ +abstract class InternalEvent extends Event { + +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 81864121e..96807c449 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -66,19 +66,22 @@ abstract class BaseForm { $options["attr"]["thelia_name"] = $this->getName(); } - $this->formBuilder = Forms::createFormFactoryBuilder() - ->addExtension(new HttpFoundationExtension()) - ->addExtension( + $builder = Forms::createFormFactoryBuilder() + ->addExtension(new HttpFoundationExtension()); + if(!isset($options["csrf_protection"]) || $options["csrf_protection"] !== false) { + $builder->addExtension( new CsrfExtension( new SessionCsrfProvider( $request->getSession(), isset($options["secret"]) ? $options["secret"] : ConfigQuery::read("form.secret", md5(__DIR__)) ) ) - ) + ); + } + $this->formBuilder = $builder ->addExtension(new ValidatorExtension($validator)) ->getFormFactory() - ->createNamedBuilder($this->getName(), $type, $data, $options); + ->createNamedBuilder($this->getName(), $type, $data, $this->cleanOptions($options)); ; $this->buildForm(); @@ -91,6 +94,13 @@ abstract class BaseForm { $this->form = $this->formBuilder->getForm(); } + protected function cleanOptions($options) + { + unset($options["csrf_protection"]); + + return $options; + } + /** * Returns the absolute URL to redirect the user to if the form is successfully processed. * diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php new file mode 100644 index 000000000..36f10f2ec --- /dev/null +++ b/core/lib/Thelia/Form/CartAdd.php @@ -0,0 +1,138 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Action\Exception\StockNotFoundException; +use Thelia\Action\Exception\ProductNotFoundException; +use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Model\ProductQuery; + +class CartAdd extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder + ->add("product", "hidden", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array($this, "checkProduct") + )) + ) + )) + ->add("product_sale_elements_id", "hidden", array( + "constraints" => array( + new Constraints\Callback(array( + "methods" => array($this, "checkStockAvailability") + )) + ) + + )) + ->add("quantity", "text", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array($this, "checkStock") + )), + new Constraints\GreaterThanOrEqual(array( + "value" => 0 + )) + ) + )) + ->add("append", "hidden") + ->add("newness", "hidden") + ; + } + + protected function checkProduct($value, ExecutionContextInterface $context) + { + $product = ProductQuery::create()->findPk($value); + + if (is_null($product) || $product->getVisible() == 0) { + throw new ProductNotFoundException(sprintf("this product id does not exists : %d", $value)); + } + } + + protected function checkStockAvailability($value, ExecutionContextInterface $context) + { + if ($value) { + $data = $context->getRoot()->getData(); + + $productSaleElements = ProductSaleElementsQuery::create() + ->filterById($value) + ->filterByProductId($data["product"]) + ->count(); + + if ($productSaleElements == 0) { + throw new StockNotFoundException(sprintf("This product_sale_elements_id does not exists for this product : %d", $value)); + } + } + } + + protected function checkStock($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + $productSaleElements = ProductSaleElementsQuery::create() + ->filterById($data["product_sale_elements_id"]) + ->filterByProductId($data["product"]) + ->findOne(); + + if ($productSaleElements->getQuantity() < $value && ConfigQuery::read("verifyStock", 1) == 1) { + $context->addViolation("quantity value is not valid"); + } + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "thelia_cart_add"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Base/Accessory.php b/core/lib/Thelia/Model/Base/Accessory.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AccessoryQuery.php b/core/lib/Thelia/Model/Base/AccessoryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AdminGroupQuery.php b/core/lib/Thelia/Model/Base/AdminGroupQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AdminLogQuery.php b/core/lib/Thelia/Model/Base/AdminLogQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php old mode 100755 new mode 100644 index 6fc82b13a..efe4a631d --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -1839,10 +1839,10 @@ abstract class Attribute implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinStock($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinProductSaleElements($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Stock', $joinBehavior); + $query->joinWith('ProductSaleElements', $joinBehavior); return $this->getAttributeCombinations($query, $con); } diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php old mode 100755 new mode 100644 index d5491f065..43a1be294 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -1628,10 +1628,10 @@ abstract class AttributeAv implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinStock($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinProductSaleElements($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildAttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Stock', $joinBehavior); + $query->joinWith('ProductSaleElements', $joinBehavior); return $this->getAttributeCombinations($query, $con); } diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php old mode 100755 new mode 100644 index e474c4340..ea2ade03c --- a/core/lib/Thelia/Model/Base/AttributeCombination.php +++ b/core/lib/Thelia/Model/Base/AttributeCombination.php @@ -22,8 +22,8 @@ use Thelia\Model\AttributeAvQuery as ChildAttributeAvQuery; use Thelia\Model\AttributeCombination as ChildAttributeCombination; use Thelia\Model\AttributeCombinationQuery as ChildAttributeCombinationQuery; use Thelia\Model\AttributeQuery as ChildAttributeQuery; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\Map\AttributeCombinationTableMap; abstract class AttributeCombination implements ActiveRecordInterface @@ -73,10 +73,10 @@ abstract class AttributeCombination implements ActiveRecordInterface protected $attribute_av_id; /** - * The value for the stock_id field. + * The value for the product_sale_elements_id field. * @var int */ - protected $stock_id; + protected $product_sale_elements_id; /** * The value for the created_at field. @@ -101,9 +101,9 @@ abstract class AttributeCombination implements ActiveRecordInterface protected $aAttributeAv; /** - * @var Stock + * @var ProductSaleElements */ - protected $aStock; + protected $aProductSaleElements; /** * Flag to prevent endless save loop, if this object is referenced @@ -390,14 +390,14 @@ abstract class AttributeCombination implements ActiveRecordInterface } /** - * Get the [stock_id] column value. + * Get the [product_sale_elements_id] column value. * * @return int */ - public function getStockId() + public function getProductSaleElementsId() { - return $this->stock_id; + return $this->product_sale_elements_id; } /** @@ -491,29 +491,29 @@ abstract class AttributeCombination implements ActiveRecordInterface } // setAttributeAvId() /** - * Set the value of [stock_id] column. + * Set the value of [product_sale_elements_id] column. * * @param int $v new value * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) */ - public function setStockId($v) + public function setProductSaleElementsId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->stock_id !== $v) { - $this->stock_id = $v; - $this->modifiedColumns[] = AttributeCombinationTableMap::STOCK_ID; + if ($this->product_sale_elements_id !== $v) { + $this->product_sale_elements_id = $v; + $this->modifiedColumns[] = AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID; } - if ($this->aStock !== null && $this->aStock->getId() !== $v) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->aProductSaleElements->getId() !== $v) { + $this->aProductSaleElements = null; } return $this; - } // setStockId() + } // setProductSaleElementsId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -600,8 +600,8 @@ abstract class AttributeCombination implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCombinationTableMap::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)]; $this->attribute_av_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCombinationTableMap::translateFieldName('StockId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->stock_id = (null !== $col) ? (int) $col : null; + $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; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -650,8 +650,8 @@ abstract class AttributeCombination implements ActiveRecordInterface if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) { $this->aAttributeAv = null; } - if ($this->aStock !== null && $this->stock_id !== $this->aStock->getId()) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->product_sale_elements_id !== $this->aProductSaleElements->getId()) { + $this->aProductSaleElements = null; } } // ensureConsistency @@ -694,7 +694,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $this->aAttribute = null; $this->aAttributeAv = null; - $this->aStock = null; + $this->aProductSaleElements = null; } // if (deep) } @@ -836,11 +836,11 @@ abstract class AttributeCombination implements ActiveRecordInterface $this->setAttributeAv($this->aAttributeAv); } - if ($this->aStock !== null) { - if ($this->aStock->isModified() || $this->aStock->isNew()) { - $affectedRows += $this->aStock->save($con); + if ($this->aProductSaleElements !== null) { + if ($this->aProductSaleElements->isModified() || $this->aProductSaleElements->isNew()) { + $affectedRows += $this->aProductSaleElements->save($con); } - $this->setStock($this->aStock); + $this->setProductSaleElements($this->aProductSaleElements); } if ($this->isNew() || $this->isModified()) { @@ -882,8 +882,8 @@ abstract class AttributeCombination implements ActiveRecordInterface if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) { $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_ID'; } - if ($this->isColumnModified(AttributeCombinationTableMap::STOCK_ID)) { - $modifiedColumns[':p' . $index++] = 'STOCK_ID'; + if ($this->isColumnModified(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; } if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -908,8 +908,8 @@ abstract class AttributeCombination implements ActiveRecordInterface case 'ATTRIBUTE_AV_ID': $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT); break; - case 'STOCK_ID': - $stmt->bindValue($identifier, $this->stock_id, PDO::PARAM_INT); + case 'PRODUCT_SALE_ELEMENTS_ID': + $stmt->bindValue($identifier, $this->product_sale_elements_id, 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); @@ -979,7 +979,7 @@ abstract class AttributeCombination implements ActiveRecordInterface return $this->getAttributeAvId(); break; case 2: - return $this->getStockId(); + return $this->getProductSaleElementsId(); break; case 3: return $this->getCreatedAt(); @@ -1018,7 +1018,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $result = array( $keys[0] => $this->getAttributeId(), $keys[1] => $this->getAttributeAvId(), - $keys[2] => $this->getStockId(), + $keys[2] => $this->getProductSaleElementsId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1035,8 +1035,8 @@ abstract class AttributeCombination implements ActiveRecordInterface if (null !== $this->aAttributeAv) { $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aStock) { - $result['Stock'] = $this->aStock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aProductSaleElements) { + $result['ProductSaleElements'] = $this->aProductSaleElements->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1079,7 +1079,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $this->setAttributeAvId($value); break; case 2: - $this->setStockId($value); + $this->setProductSaleElementsId($value); break; case 3: $this->setCreatedAt($value); @@ -1113,7 +1113,7 @@ abstract class AttributeCombination implements ActiveRecordInterface 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[2], $arr)) $this->setStockId($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setProductSaleElementsId($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]]); } @@ -1129,7 +1129,7 @@ abstract class AttributeCombination implements ActiveRecordInterface 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::STOCK_ID)) $criteria->add(AttributeCombinationTableMap::STOCK_ID, $this->stock_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::CREATED_AT)) $criteria->add(AttributeCombinationTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) $criteria->add(AttributeCombinationTableMap::UPDATED_AT, $this->updated_at); @@ -1149,7 +1149,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $criteria = new Criteria(AttributeCombinationTableMap::DATABASE_NAME); $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id); $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id); - $criteria->add(AttributeCombinationTableMap::STOCK_ID, $this->stock_id); + $criteria->add(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); return $criteria; } @@ -1164,7 +1164,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $pks = array(); $pks[0] = $this->getAttributeId(); $pks[1] = $this->getAttributeAvId(); - $pks[2] = $this->getStockId(); + $pks[2] = $this->getProductSaleElementsId(); return $pks; } @@ -1179,7 +1179,7 @@ abstract class AttributeCombination implements ActiveRecordInterface { $this->setAttributeId($keys[0]); $this->setAttributeAvId($keys[1]); - $this->setStockId($keys[2]); + $this->setProductSaleElementsId($keys[2]); } /** @@ -1189,7 +1189,7 @@ abstract class AttributeCombination implements ActiveRecordInterface public function isPrimaryKeyNull() { - return (null === $this->getAttributeId()) && (null === $this->getAttributeAvId()) && (null === $this->getStockId()); + return (null === $this->getAttributeId()) && (null === $this->getAttributeAvId()) && (null === $this->getProductSaleElementsId()); } /** @@ -1207,7 +1207,7 @@ abstract class AttributeCombination implements ActiveRecordInterface { $copyObj->setAttributeId($this->getAttributeId()); $copyObj->setAttributeAvId($this->getAttributeAvId()); - $copyObj->setStockId($this->getStockId()); + $copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1340,24 +1340,24 @@ abstract class AttributeCombination implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildStock object. + * Declares an association between this object and a ChildProductSaleElements object. * - * @param ChildStock $v + * @param ChildProductSaleElements $v * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) * @throws PropelException */ - public function setStock(ChildStock $v = null) + public function setProductSaleElements(ChildProductSaleElements $v = null) { if ($v === null) { - $this->setStockId(NULL); + $this->setProductSaleElementsId(NULL); } else { - $this->setStockId($v->getId()); + $this->setProductSaleElementsId($v->getId()); } - $this->aStock = $v; + $this->aProductSaleElements = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildStock object, it will not be re-added. + // If this object has already been added to the ChildProductSaleElements object, it will not be re-added. if ($v !== null) { $v->addAttributeCombination($this); } @@ -1368,26 +1368,26 @@ abstract class AttributeCombination implements ActiveRecordInterface /** - * Get the associated ChildStock object + * Get the associated ChildProductSaleElements object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildStock The associated ChildStock object. + * @return ChildProductSaleElements The associated ChildProductSaleElements object. * @throws PropelException */ - public function getStock(ConnectionInterface $con = null) + public function getProductSaleElements(ConnectionInterface $con = null) { - if ($this->aStock === null && ($this->stock_id !== null)) { - $this->aStock = ChildStockQuery::create()->findPk($this->stock_id, $con); + if ($this->aProductSaleElements === null && ($this->product_sale_elements_id !== null)) { + $this->aProductSaleElements = ChildProductSaleElementsQuery::create()->findPk($this->product_sale_elements_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aStock->addAttributeCombinations($this); + $this->aProductSaleElements->addAttributeCombinations($this); */ } - return $this->aStock; + return $this->aProductSaleElements; } /** @@ -1397,7 +1397,7 @@ abstract class AttributeCombination implements ActiveRecordInterface { $this->attribute_id = null; $this->attribute_av_id = null; - $this->stock_id = null; + $this->product_sale_elements_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1423,7 +1423,7 @@ abstract class AttributeCombination implements ActiveRecordInterface $this->aAttribute = null; $this->aAttributeAv = null; - $this->aStock = null; + $this->aProductSaleElements = null; } /** diff --git a/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php old mode 100755 new mode 100644 index 808b3c2fd..291ff7725 --- a/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php @@ -23,13 +23,13 @@ use Thelia\Model\Map\AttributeCombinationTableMap; * * @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 orderByStockId($order = Criteria::ASC) Order by the stock_id column + * @method ChildAttributeCombinationQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id 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 groupByAttributeId() Group by the attribute_id column * @method ChildAttributeCombinationQuery groupByAttributeAvId() Group by the attribute_av_id column - * @method ChildAttributeCombinationQuery groupByStockId() Group by the stock_id column + * @method ChildAttributeCombinationQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildAttributeCombinationQuery groupByCreatedAt() Group by the created_at column * @method ChildAttributeCombinationQuery groupByUpdatedAt() Group by the updated_at column * @@ -45,22 +45,22 @@ use Thelia\Model\Map\AttributeCombinationTableMap; * @method ChildAttributeCombinationQuery rightJoinAttributeAv($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeAv relation * @method ChildAttributeCombinationQuery innerJoinAttributeAv($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeAv relation * - * @method ChildAttributeCombinationQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation - * @method ChildAttributeCombinationQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation - * @method ChildAttributeCombinationQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation + * @method ChildAttributeCombinationQuery leftJoinProductSaleElements($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductSaleElements relation + * @method ChildAttributeCombinationQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation + * @method ChildAttributeCombinationQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * * @method ChildAttributeCombination findOne(ConnectionInterface $con = null) Return the first ChildAttributeCombination matching the query * @method ChildAttributeCombination findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttributeCombination matching the query, or a new ChildAttributeCombination object populated from the query conditions when no match is found * * @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 findOneByStockId(int $stock_id) Return the first ChildAttributeCombination filtered by the stock_id column + * @method ChildAttributeCombination findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildAttributeCombination filtered by the product_sale_elements_id 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 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 findByStockId(int $stock_id) Return ChildAttributeCombination objects filtered by the stock_id column + * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildAttributeCombination objects filtered by the product_sale_elements_id 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 * @@ -113,7 +113,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria * $obj = $c->findPk(array(12, 34, 56), $con); * * - * @param array[$attribute_id, $attribute_av_id, $stock_id] $key Primary key to use for the query + * @param array[$attribute_id, $attribute_av_id, $product_sale_elements_id] $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeCombination|array|mixed the result, formatted by the current formatter @@ -151,7 +151,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ATTRIBUTE_ID, ATTRIBUTE_AV_ID, STOCK_ID, CREATED_AT, UPDATED_AT FROM attribute_combination WHERE ATTRIBUTE_ID = :p0 AND ATTRIBUTE_AV_ID = :p1 AND STOCK_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 { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -227,7 +227,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria { $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[0], Criteria::EQUAL); $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $key[2], Criteria::EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[2], Criteria::EQUAL); return $this; } @@ -248,7 +248,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria $cton0 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[0], Criteria::EQUAL); $cton1 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AttributeCombinationTableMap::STOCK_ID, $key[2], Criteria::EQUAL); + $cton2 = $this->getNewCriterion(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $key[2], Criteria::EQUAL); $cton0->addAnd($cton2); $this->addOr($cton0); } @@ -343,18 +343,18 @@ abstract class AttributeCombinationQuery extends ModelCriteria } /** - * Filter the query on the stock_id column + * Filter the query on the product_sale_elements_id column * * Example usage: * - * $query->filterByStockId(1234); // WHERE stock_id = 1234 - * $query->filterByStockId(array(12, 34)); // WHERE stock_id IN (12, 34) - * $query->filterByStockId(array('min' => 12)); // WHERE stock_id > 12 + * $query->filterByProductSaleElementsId(1234); // WHERE product_sale_elements_id = 1234 + * $query->filterByProductSaleElementsId(array(12, 34)); // WHERE product_sale_elements_id IN (12, 34) + * $query->filterByProductSaleElementsId(array('min' => 12)); // WHERE product_sale_elements_id > 12 * * - * @see filterByStock() + * @see filterByProductSaleElements() * - * @param mixed $stockId The value to use as filter. + * @param mixed $productSaleElementsId 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. @@ -362,16 +362,16 @@ abstract class AttributeCombinationQuery extends ModelCriteria * * @return ChildAttributeCombinationQuery The current query, for fluid interface */ - public function filterByStockId($stockId = null, $comparison = null) + public function filterByProductSaleElementsId($productSaleElementsId = null, $comparison = null) { - if (is_array($stockId)) { + if (is_array($productSaleElementsId)) { $useMinMax = false; - if (isset($stockId['min'])) { - $this->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $stockId['min'], Criteria::GREATER_EQUAL); + if (isset($productSaleElementsId['min'])) { + $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($stockId['max'])) { - $this->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $stockId['max'], Criteria::LESS_EQUAL); + if (isset($productSaleElementsId['max'])) { + $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -382,7 +382,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $stockId, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison); } /** @@ -622,42 +622,42 @@ abstract class AttributeCombinationQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Stock object + * Filter the query by a related \Thelia\Model\ProductSaleElements object * - * @param \Thelia\Model\Stock|ObjectCollection $stock The related object(s) to use as filter + * @param \Thelia\Model\ProductSaleElements|ObjectCollection $productSaleElements The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAttributeCombinationQuery The current query, for fluid interface */ - public function filterByStock($stock, $comparison = null) + public function filterByProductSaleElements($productSaleElements, $comparison = null) { - if ($stock instanceof \Thelia\Model\Stock) { + if ($productSaleElements instanceof \Thelia\Model\ProductSaleElements) { return $this - ->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $stock->getId(), $comparison); - } elseif ($stock instanceof ObjectCollection) { + ->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->getId(), $comparison); + } elseif ($productSaleElements instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCombinationTableMap::STOCK_ID, $stock->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); + throw new PropelException('filterByProductSaleElements() only accepts arguments of type \Thelia\Model\ProductSaleElements or Collection'); } } /** - * Adds a JOIN clause to the query using the Stock relation + * Adds a JOIN clause to the query using the ProductSaleElements relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAttributeCombinationQuery The current query, for fluid interface */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProductSaleElements($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); + $relationMap = $tableMap->getRelation('ProductSaleElements'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -672,14 +672,14 @@ abstract class AttributeCombinationQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Stock'); + $this->addJoinObject($join, 'ProductSaleElements'); } return $this; } /** - * Use the Stock relation Stock object + * Use the ProductSaleElements relation ProductSaleElements object * * @see useQuery() * @@ -687,13 +687,13 @@ abstract class AttributeCombinationQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductSaleElementsQuery A secondary query class using the current class as primary query */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProductSaleElementsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); + ->joinProductSaleElements($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } /** @@ -708,7 +708,7 @@ abstract class AttributeCombinationQuery extends ModelCriteria if ($attributeCombination) { $this->addCond('pruneCond0', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_ID), $attributeCombination->getAttributeId(), Criteria::NOT_EQUAL); $this->addCond('pruneCond1', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_AV_ID), $attributeCombination->getAttributeAvId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationTableMap::STOCK_ID), $attributeCombination->getStockId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID), $attributeCombination->getProductSaleElementsId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); } diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Cart.php b/core/lib/Thelia/Model/Base/Cart.php index 9d42de7cd..910bdf0e0 100644 --- a/core/lib/Thelia/Model/Base/Cart.php +++ b/core/lib/Thelia/Model/Base/Cart.php @@ -1963,10 +1963,10 @@ abstract class Cart implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildCartItem[] List of ChildCartItem objects */ - public function getCartItemsJoinStock($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getCartItemsJoinProductSaleElements($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildCartItemQuery::create(null, $criteria); - $query->joinWith('Stock', $joinBehavior); + $query->joinWith('ProductSaleElements', $joinBehavior); return $this->getCartItems($query, $con); } diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 82c87ac1a..fa187435a 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -22,8 +22,8 @@ use Thelia\Model\CartItemQuery as ChildCartItemQuery; use Thelia\Model\CartQuery as ChildCartQuery; use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductQuery as ChildProductQuery; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\Map\CartItemTableMap; abstract class CartItem implements ActiveRecordInterface @@ -86,10 +86,10 @@ abstract class CartItem implements ActiveRecordInterface protected $quantity; /** - * The value for the stock_id field. + * The value for the product_sale_elements_id field. * @var int */ - protected $stock_id; + protected $product_sale_elements_id; /** * The value for the created_at field. @@ -114,9 +114,9 @@ abstract class CartItem implements ActiveRecordInterface protected $aProduct; /** - * @var Stock + * @var ProductSaleElements */ - protected $aStock; + protected $aProductSaleElements; /** * Flag to prevent endless save loop, if this object is referenced @@ -438,14 +438,14 @@ abstract class CartItem implements ActiveRecordInterface } /** - * Get the [stock_id] column value. + * Get the [product_sale_elements_id] column value. * * @return int */ - public function getStockId() + public function getProductSaleElementsId() { - return $this->stock_id; + return $this->product_sale_elements_id; } /** @@ -581,29 +581,29 @@ abstract class CartItem implements ActiveRecordInterface } // setQuantity() /** - * Set the value of [stock_id] column. + * Set the value of [product_sale_elements_id] column. * * @param int $v new value * @return \Thelia\Model\CartItem The current object (for fluent API support) */ - public function setStockId($v) + public function setProductSaleElementsId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->stock_id !== $v) { - $this->stock_id = $v; - $this->modifiedColumns[] = CartItemTableMap::STOCK_ID; + if ($this->product_sale_elements_id !== $v) { + $this->product_sale_elements_id = $v; + $this->modifiedColumns[] = CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID; } - if ($this->aStock !== null && $this->aStock->getId() !== $v) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->aProductSaleElements->getId() !== $v) { + $this->aProductSaleElements = null; } return $this; - } // setStockId() + } // setProductSaleElementsId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -700,8 +700,8 @@ abstract class CartItem implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CartItemTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; $this->quantity = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CartItemTableMap::translateFieldName('StockId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->stock_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CartItemTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_sale_elements_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -750,8 +750,8 @@ abstract class CartItem implements ActiveRecordInterface if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } - if ($this->aStock !== null && $this->stock_id !== $this->aStock->getId()) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->product_sale_elements_id !== $this->aProductSaleElements->getId()) { + $this->aProductSaleElements = null; } } // ensureConsistency @@ -794,7 +794,7 @@ abstract class CartItem implements ActiveRecordInterface $this->aCart = null; $this->aProduct = null; - $this->aStock = null; + $this->aProductSaleElements = null; } // if (deep) } @@ -936,11 +936,11 @@ abstract class CartItem implements ActiveRecordInterface $this->setProduct($this->aProduct); } - if ($this->aStock !== null) { - if ($this->aStock->isModified() || $this->aStock->isNew()) { - $affectedRows += $this->aStock->save($con); + if ($this->aProductSaleElements !== null) { + if ($this->aProductSaleElements->isModified() || $this->aProductSaleElements->isNew()) { + $affectedRows += $this->aProductSaleElements->save($con); } - $this->setStock($this->aStock); + $this->setProductSaleElements($this->aProductSaleElements); } if ($this->isNew() || $this->isModified()) { @@ -992,8 +992,8 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::QUANTITY)) { $modifiedColumns[':p' . $index++] = 'QUANTITY'; } - if ($this->isColumnModified(CartItemTableMap::STOCK_ID)) { - $modifiedColumns[':p' . $index++] = 'STOCK_ID'; + if ($this->isColumnModified(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; } if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1024,8 +1024,8 @@ abstract class CartItem implements ActiveRecordInterface case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); break; - case 'STOCK_ID': - $stmt->bindValue($identifier, $this->stock_id, PDO::PARAM_INT); + case 'PRODUCT_SALE_ELEMENTS_ID': + $stmt->bindValue($identifier, $this->product_sale_elements_id, 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); @@ -1108,7 +1108,7 @@ abstract class CartItem implements ActiveRecordInterface return $this->getQuantity(); break; case 4: - return $this->getStockId(); + return $this->getProductSaleElementsId(); break; case 5: return $this->getCreatedAt(); @@ -1149,7 +1149,7 @@ abstract class CartItem implements ActiveRecordInterface $keys[1] => $this->getCartId(), $keys[2] => $this->getProductId(), $keys[3] => $this->getQuantity(), - $keys[4] => $this->getStockId(), + $keys[4] => $this->getProductSaleElementsId(), $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); @@ -1166,8 +1166,8 @@ abstract class CartItem implements ActiveRecordInterface if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->aStock) { - $result['Stock'] = $this->aStock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aProductSaleElements) { + $result['ProductSaleElements'] = $this->aProductSaleElements->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1216,7 +1216,7 @@ abstract class CartItem implements ActiveRecordInterface $this->setQuantity($value); break; case 4: - $this->setStockId($value); + $this->setProductSaleElementsId($value); break; case 5: $this->setCreatedAt($value); @@ -1252,7 +1252,7 @@ abstract class CartItem implements ActiveRecordInterface if (array_key_exists($keys[1], $arr)) $this->setCartId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setQuantity($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setStockId($arr[$keys[4]]); + if (array_key_exists($keys[4], $arr)) $this->setProductSaleElementsId($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } @@ -1270,7 +1270,7 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::CART_ID)) $criteria->add(CartItemTableMap::CART_ID, $this->cart_id); if ($this->isColumnModified(CartItemTableMap::PRODUCT_ID)) $criteria->add(CartItemTableMap::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(CartItemTableMap::QUANTITY)) $criteria->add(CartItemTableMap::QUANTITY, $this->quantity); - if ($this->isColumnModified(CartItemTableMap::STOCK_ID)) $criteria->add(CartItemTableMap::STOCK_ID, $this->stock_id); + if ($this->isColumnModified(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at); @@ -1339,7 +1339,7 @@ abstract class CartItem implements ActiveRecordInterface $copyObj->setCartId($this->getCartId()); $copyObj->setProductId($this->getProductId()); $copyObj->setQuantity($this->getQuantity()); - $copyObj->setStockId($this->getStockId()); + $copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1473,24 +1473,24 @@ abstract class CartItem implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildStock object. + * Declares an association between this object and a ChildProductSaleElements object. * - * @param ChildStock $v + * @param ChildProductSaleElements $v * @return \Thelia\Model\CartItem The current object (for fluent API support) * @throws PropelException */ - public function setStock(ChildStock $v = null) + public function setProductSaleElements(ChildProductSaleElements $v = null) { if ($v === null) { - $this->setStockId(NULL); + $this->setProductSaleElementsId(NULL); } else { - $this->setStockId($v->getId()); + $this->setProductSaleElementsId($v->getId()); } - $this->aStock = $v; + $this->aProductSaleElements = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildStock object, it will not be re-added. + // If this object has already been added to the ChildProductSaleElements object, it will not be re-added. if ($v !== null) { $v->addCartItem($this); } @@ -1501,26 +1501,26 @@ abstract class CartItem implements ActiveRecordInterface /** - * Get the associated ChildStock object + * Get the associated ChildProductSaleElements object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildStock The associated ChildStock object. + * @return ChildProductSaleElements The associated ChildProductSaleElements object. * @throws PropelException */ - public function getStock(ConnectionInterface $con = null) + public function getProductSaleElements(ConnectionInterface $con = null) { - if ($this->aStock === null && ($this->stock_id !== null)) { - $this->aStock = ChildStockQuery::create()->findPk($this->stock_id, $con); + if ($this->aProductSaleElements === null && ($this->product_sale_elements_id !== null)) { + $this->aProductSaleElements = ChildProductSaleElementsQuery::create()->findPk($this->product_sale_elements_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aStock->addCartItems($this); + $this->aProductSaleElements->addCartItems($this); */ } - return $this->aStock; + return $this->aProductSaleElements; } /** @@ -1532,7 +1532,7 @@ abstract class CartItem implements ActiveRecordInterface $this->cart_id = null; $this->product_id = null; $this->quantity = null; - $this->stock_id = null; + $this->product_sale_elements_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1559,7 +1559,7 @@ abstract class CartItem implements ActiveRecordInterface $this->aCart = null; $this->aProduct = null; - $this->aStock = null; + $this->aProductSaleElements = null; } /** diff --git a/core/lib/Thelia/Model/Base/CartItemQuery.php b/core/lib/Thelia/Model/Base/CartItemQuery.php index 1e82cbf30..a7258d60d 100644 --- a/core/lib/Thelia/Model/Base/CartItemQuery.php +++ b/core/lib/Thelia/Model/Base/CartItemQuery.php @@ -25,7 +25,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery orderByCartId($order = Criteria::ASC) Order by the cart_id column * @method ChildCartItemQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ChildCartItemQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column - * @method ChildCartItemQuery orderByStockId($order = Criteria::ASC) Order by the stock_id column + * @method ChildCartItemQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column * @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -33,7 +33,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery groupByCartId() Group by the cart_id column * @method ChildCartItemQuery groupByProductId() Group by the product_id column * @method ChildCartItemQuery groupByQuantity() Group by the quantity column - * @method ChildCartItemQuery groupByStockId() Group by the stock_id column + * @method ChildCartItemQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column * @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column * @@ -49,9 +49,9 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation * @method ChildCartItemQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation * - * @method ChildCartItemQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation - * @method ChildCartItemQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation - * @method ChildCartItemQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation + * @method ChildCartItemQuery leftJoinProductSaleElements($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductSaleElements relation + * @method ChildCartItemQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation + * @method ChildCartItemQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * * @method ChildCartItem findOne(ConnectionInterface $con = null) Return the first ChildCartItem matching the query * @method ChildCartItem findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCartItem matching the query, or a new ChildCartItem object populated from the query conditions when no match is found @@ -60,7 +60,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItem findOneByCartId(int $cart_id) Return the first ChildCartItem filtered by the cart_id column * @method ChildCartItem findOneByProductId(int $product_id) Return the first ChildCartItem filtered by the product_id column * @method ChildCartItem findOneByQuantity(double $quantity) Return the first ChildCartItem filtered by the quantity column - * @method ChildCartItem findOneByStockId(int $stock_id) Return the first ChildCartItem filtered by the stock_id column + * @method ChildCartItem findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildCartItem filtered by the product_sale_elements_id column * @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column * @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column * @@ -68,7 +68,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method array findByCartId(int $cart_id) Return ChildCartItem objects filtered by the cart_id column * @method array findByProductId(int $product_id) Return ChildCartItem objects filtered by the product_id column * @method array findByQuantity(double $quantity) Return ChildCartItem objects filtered by the quantity column - * @method array findByStockId(int $stock_id) Return ChildCartItem objects filtered by the stock_id column + * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildCartItem objects filtered by the product_sale_elements_id column * @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column * @@ -159,7 +159,7 @@ abstract class CartItemQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, STOCK_ID, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; + $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -417,18 +417,18 @@ abstract class CartItemQuery extends ModelCriteria } /** - * Filter the query on the stock_id column + * Filter the query on the product_sale_elements_id column * * Example usage: * - * $query->filterByStockId(1234); // WHERE stock_id = 1234 - * $query->filterByStockId(array(12, 34)); // WHERE stock_id IN (12, 34) - * $query->filterByStockId(array('min' => 12)); // WHERE stock_id > 12 + * $query->filterByProductSaleElementsId(1234); // WHERE product_sale_elements_id = 1234 + * $query->filterByProductSaleElementsId(array(12, 34)); // WHERE product_sale_elements_id IN (12, 34) + * $query->filterByProductSaleElementsId(array('min' => 12)); // WHERE product_sale_elements_id > 12 * * - * @see filterByStock() + * @see filterByProductSaleElements() * - * @param mixed $stockId The value to use as filter. + * @param mixed $productSaleElementsId 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. @@ -436,16 +436,16 @@ abstract class CartItemQuery extends ModelCriteria * * @return ChildCartItemQuery The current query, for fluid interface */ - public function filterByStockId($stockId = null, $comparison = null) + public function filterByProductSaleElementsId($productSaleElementsId = null, $comparison = null) { - if (is_array($stockId)) { + if (is_array($productSaleElementsId)) { $useMinMax = false; - if (isset($stockId['min'])) { - $this->addUsingAlias(CartItemTableMap::STOCK_ID, $stockId['min'], Criteria::GREATER_EQUAL); + if (isset($productSaleElementsId['min'])) { + $this->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($stockId['max'])) { - $this->addUsingAlias(CartItemTableMap::STOCK_ID, $stockId['max'], Criteria::LESS_EQUAL); + if (isset($productSaleElementsId['max'])) { + $this->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -456,7 +456,7 @@ abstract class CartItemQuery extends ModelCriteria } } - return $this->addUsingAlias(CartItemTableMap::STOCK_ID, $stockId, $comparison); + return $this->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison); } /** @@ -696,42 +696,42 @@ abstract class CartItemQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Stock object + * Filter the query by a related \Thelia\Model\ProductSaleElements object * - * @param \Thelia\Model\Stock|ObjectCollection $stock The related object(s) to use as filter + * @param \Thelia\Model\ProductSaleElements|ObjectCollection $productSaleElements The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildCartItemQuery The current query, for fluid interface */ - public function filterByStock($stock, $comparison = null) + public function filterByProductSaleElements($productSaleElements, $comparison = null) { - if ($stock instanceof \Thelia\Model\Stock) { + if ($productSaleElements instanceof \Thelia\Model\ProductSaleElements) { return $this - ->addUsingAlias(CartItemTableMap::STOCK_ID, $stock->getId(), $comparison); - } elseif ($stock instanceof ObjectCollection) { + ->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->getId(), $comparison); + } elseif ($productSaleElements instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CartItemTableMap::STOCK_ID, $stock->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); + throw new PropelException('filterByProductSaleElements() only accepts arguments of type \Thelia\Model\ProductSaleElements or Collection'); } } /** - * Adds a JOIN clause to the query using the Stock relation + * Adds a JOIN clause to the query using the ProductSaleElements relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildCartItemQuery The current query, for fluid interface */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProductSaleElements($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); + $relationMap = $tableMap->getRelation('ProductSaleElements'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -746,14 +746,14 @@ abstract class CartItemQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Stock'); + $this->addJoinObject($join, 'ProductSaleElements'); } return $this; } /** - * Use the Stock relation Stock object + * Use the ProductSaleElements relation ProductSaleElements object * * @see useQuery() * @@ -761,13 +761,13 @@ abstract class CartItemQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductSaleElementsQuery A secondary query class using the current class as primary query */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProductSaleElementsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); + ->joinProductSaleElements($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CategoryI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CategoryVersionQuery.php b/core/lib/Thelia/Model/Base/CategoryVersionQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Combination.php b/core/lib/Thelia/Model/Base/Combination.php deleted file mode 100755 index e5c42425a..000000000 --- a/core/lib/Thelia/Model/Base/Combination.php +++ /dev/null @@ -1,2246 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another Combination instance. If - * obj is an instance of Combination, delegates to - * equals(Combination). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return isset($this->virtualColumns[$name]); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return Combination The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return Combination The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [ref] column value. - * - * @return string - */ - public function getRef() - { - - return $this->ref; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CombinationTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = CombinationTableMap::REF; - } - - - return $this; - } // setRef() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = CombinationTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CombinationTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; - $this->ref = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CombinationTableMap::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 ? 3 + $startcol : CombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = CombinationTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Combination object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAttributeCombinations = null; - - $this->collStocks = null; - - $this->collCartItems = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see Combination::setDeleted() - * @see Combination::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildCombinationQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CombinationTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CombinationTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CombinationTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CombinationTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->attributeCombinationsScheduledForDeletion !== null) { - if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - \Thelia\Model\AttributeCombinationQuery::create() - ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCombinationsScheduledForDeletion = null; - } - } - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->stocksScheduledForDeletion !== null) { - if (!$this->stocksScheduledForDeletion->isEmpty()) { - foreach ($this->stocksScheduledForDeletion as $stock) { - // need to save related object because we set the relation to null - $stock->save($con); - } - $this->stocksScheduledForDeletion = null; - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->cartItemsScheduledForDeletion !== null) { - if (!$this->cartItemsScheduledForDeletion->isEmpty()) { - foreach ($this->cartItemsScheduledForDeletion as $cartItem) { - // need to save related object because we set the relation to null - $cartItem->save($con); - } - $this->cartItemsScheduledForDeletion = null; - } - } - - if ($this->collCartItems !== null) { - foreach ($this->collCartItems as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CombinationTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CombinationTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(CombinationTableMap::REF)) { - $modifiedColumns[':p' . $index++] = 'REF'; - } - if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO combination (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'REF': - $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); - 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; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getRef(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Combination'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Combination'][$this->getPrimaryKey()] = true; - $keys = CombinationTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getRef(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->collAttributeCombinations) { - $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collStocks) { - $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collCartItems) { - $result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setRef($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = CombinationTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CombinationTableMap::DATABASE_NAME); - - if ($this->isColumnModified(CombinationTableMap::ID)) $criteria->add(CombinationTableMap::ID, $this->id); - if ($this->isColumnModified(CombinationTableMap::REF)) $criteria->add(CombinationTableMap::REF, $this->ref); - if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) $criteria->add(CombinationTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) $criteria->add(CombinationTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CombinationTableMap::DATABASE_NAME); - $criteria->add(CombinationTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\Combination (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setRef($this->getRef()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - - foreach ($this->getAttributeCombinations() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCombination($relObj->copy($deepCopy)); - } - } - - foreach ($this->getStocks() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addStock($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCartItems() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCartItem($relObj->copy($deepCopy)); - } - } - - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Combination Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AttributeCombination' == $relationName) { - return $this->initAttributeCombinations(); - } - if ('Stock' == $relationName) { - return $this->initStocks(); - } - if ('CartItem' == $relationName) { - return $this->initCartItems(); - } - } - - /** - * Clears out the collAttributeCombinations collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addAttributeCombinations() - */ - public function clearAttributeCombinations() - { - $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collAttributeCombinations collection loaded partially. - */ - public function resetPartialAttributeCombinations($v = true) - { - $this->collAttributeCombinationsPartial = $v; - } - - /** - * Initializes the collAttributeCombinations collection. - * - * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCombinations($overrideExisting = true) - { - if (null !== $this->collAttributeCombinations && !$overrideExisting) { - return; - } - $this->collAttributeCombinations = new ObjectCollection(); - $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination'); - } - - /** - * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCombination is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects - * @throws PropelException - */ - public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - // return empty collection - $this->initAttributeCombinations(); - } else { - $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria) - ->filterByCombination($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); - - foreach ($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); - } - } - - $this->collAttributeCombinationsPartial = true; - } - - $collAttributeCombinations->getInternalIterator()->rewind(); - - return $collAttributeCombinations; - } - - if ($partial && $this->collAttributeCombinations) { - foreach ($this->collAttributeCombinations as $obj) { - if ($obj->isNew()) { - $collAttributeCombinations[] = $obj; - } - } - } - - $this->collAttributeCombinations = $collAttributeCombinations; - $this->collAttributeCombinationsPartial = false; - } - } - - return $this->collAttributeCombinations; - } - - /** - * Sets a collection of AttributeCombination objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $attributeCombinations A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCombination The current object (for fluent API support) - */ - public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null) - { - $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - - - //since at least one column in the foreign key is at the same time a PK - //we can not just set a PK to NULL in the lines below. We have to store - //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete; - - foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { - $attributeCombinationRemoved->setCombination(null); - } - - $this->collAttributeCombinations = null; - foreach ($attributeCombinations as $attributeCombination) { - $this->addAttributeCombination($attributeCombination); - } - - $this->collAttributeCombinations = $attributeCombinations; - $this->collAttributeCombinationsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCombination objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related AttributeCombination objects. - * @throws PropelException - */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - - $query = ChildAttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); - } - - return count($this->collAttributeCombinations); - } - - /** - * Method called to associate a ChildAttributeCombination object to this object - * through the ChildAttributeCombination foreign key attribute. - * - * @param ChildAttributeCombination $l ChildAttributeCombination - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function addAttributeCombination(ChildAttributeCombination $l) - { - if ($this->collAttributeCombinations === null) { - $this->initAttributeCombinations(); - $this->collAttributeCombinationsPartial = true; - } - - if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCombination($l); - } - - return $this; - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. - */ - protected function doAddAttributeCombination($attributeCombination) - { - $this->collAttributeCombinations[]= $attributeCombination; - $attributeCombination->setCombination($this); - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return ChildCombination The current object (for fluent API support) - */ - public function removeAttributeCombination($attributeCombination) - { - if ($this->getAttributeCombinations()->contains($attributeCombination)) { - $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination)); - if (null === $this->attributeCombinationsScheduledForDeletion) { - $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; - $this->attributeCombinationsScheduledForDeletion->clear(); - } - $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; - $attributeCombination->setCombination(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects - */ - public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildAttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Attribute', $joinBehavior); - - return $this->getAttributeCombinations($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects - */ - public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildAttributeCombinationQuery::create(null, $criteria); - $query->joinWith('AttributeAv', $joinBehavior); - - return $this->getAttributeCombinations($query, $con); - } - - /** - * Clears out the collStocks collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addStocks() - */ - public function clearStocks() - { - $this->collStocks = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collStocks collection loaded partially. - */ - public function resetPartialStocks($v = true) - { - $this->collStocksPartial = $v; - } - - /** - * Initializes the collStocks collection. - * - * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initStocks($overrideExisting = true) - { - if (null !== $this->collStocks && !$overrideExisting) { - return; - } - $this->collStocks = new ObjectCollection(); - $this->collStocks->setModel('\Thelia\Model\Stock'); - } - - /** - * Gets an array of ChildStock objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCombination is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildStock[] List of ChildStock objects - * @throws PropelException - */ - public function getStocks($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - // return empty collection - $this->initStocks(); - } else { - $collStocks = ChildStockQuery::create(null, $criteria) - ->filterByCombination($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); - - foreach ($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); - } - } - - $this->collStocksPartial = true; - } - - $collStocks->getInternalIterator()->rewind(); - - return $collStocks; - } - - if ($partial && $this->collStocks) { - foreach ($this->collStocks as $obj) { - if ($obj->isNew()) { - $collStocks[] = $obj; - } - } - } - - $this->collStocks = $collStocks; - $this->collStocksPartial = false; - } - } - - return $this->collStocks; - } - - /** - * Sets a collection of Stock objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $stocks A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCombination The current object (for fluent API support) - */ - public function setStocks(Collection $stocks, ConnectionInterface $con = null) - { - $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - - - $this->stocksScheduledForDeletion = $stocksToDelete; - - foreach ($stocksToDelete as $stockRemoved) { - $stockRemoved->setCombination(null); - } - - $this->collStocks = null; - foreach ($stocks as $stock) { - $this->addStock($stock); - } - - $this->collStocks = $stocks; - $this->collStocksPartial = false; - - return $this; - } - - /** - * Returns the number of related Stock objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related Stock objects. - * @throws PropelException - */ - public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getStocks()); - } - - $query = ChildStockQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); - } - - return count($this->collStocks); - } - - /** - * Method called to associate a ChildStock object to this object - * through the ChildStock foreign key attribute. - * - * @param ChildStock $l ChildStock - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function addStock(ChildStock $l) - { - if ($this->collStocks === null) { - $this->initStocks(); - $this->collStocksPartial = true; - } - - if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddStock($l); - } - - return $this; - } - - /** - * @param Stock $stock The stock object to add. - */ - protected function doAddStock($stock) - { - $this->collStocks[]= $stock; - $stock->setCombination($this); - } - - /** - * @param Stock $stock The stock object to remove. - * @return ChildCombination The current object (for fluent API support) - */ - public function removeStock($stock) - { - if ($this->getStocks()->contains($stock)) { - $this->collStocks->remove($this->collStocks->search($stock)); - if (null === $this->stocksScheduledForDeletion) { - $this->stocksScheduledForDeletion = clone $this->collStocks; - $this->stocksScheduledForDeletion->clear(); - } - $this->stocksScheduledForDeletion[]= $stock; - $stock->setCombination(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related Stocks from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildStock[] List of ChildStock objects - */ - public function getStocksJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildStockQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getStocks($query, $con); - } - - /** - * Clears out the collCartItems collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addCartItems() - */ - public function clearCartItems() - { - $this->collCartItems = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collCartItems collection loaded partially. - */ - public function resetPartialCartItems($v = true) - { - $this->collCartItemsPartial = $v; - } - - /** - * Initializes the collCartItems collection. - * - * By default this just sets the collCartItems collection to an empty array (like clearcollCartItems()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCartItems($overrideExisting = true) - { - if (null !== $this->collCartItems && !$overrideExisting) { - return; - } - $this->collCartItems = new ObjectCollection(); - $this->collCartItems->setModel('\Thelia\Model\CartItem'); - } - - /** - * Gets an array of ChildCartItem objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildCombination is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildCartItem[] List of ChildCartItem objects - * @throws PropelException - */ - public function getCartItems($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collCartItemsPartial && !$this->isNew(); - if (null === $this->collCartItems || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCartItems) { - // return empty collection - $this->initCartItems(); - } else { - $collCartItems = ChildCartItemQuery::create(null, $criteria) - ->filterByCombination($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collCartItemsPartial && count($collCartItems)) { - $this->initCartItems(false); - - foreach ($collCartItems as $obj) { - if (false == $this->collCartItems->contains($obj)) { - $this->collCartItems->append($obj); - } - } - - $this->collCartItemsPartial = true; - } - - $collCartItems->getInternalIterator()->rewind(); - - return $collCartItems; - } - - if ($partial && $this->collCartItems) { - foreach ($this->collCartItems as $obj) { - if ($obj->isNew()) { - $collCartItems[] = $obj; - } - } - } - - $this->collCartItems = $collCartItems; - $this->collCartItemsPartial = false; - } - } - - return $this->collCartItems; - } - - /** - * Sets a collection of CartItem objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $cartItems A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildCombination The current object (for fluent API support) - */ - public function setCartItems(Collection $cartItems, ConnectionInterface $con = null) - { - $cartItemsToDelete = $this->getCartItems(new Criteria(), $con)->diff($cartItems); - - - $this->cartItemsScheduledForDeletion = $cartItemsToDelete; - - foreach ($cartItemsToDelete as $cartItemRemoved) { - $cartItemRemoved->setCombination(null); - } - - $this->collCartItems = null; - foreach ($cartItems as $cartItem) { - $this->addCartItem($cartItem); - } - - $this->collCartItems = $cartItems; - $this->collCartItemsPartial = false; - - return $this; - } - - /** - * Returns the number of related CartItem objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related CartItem objects. - * @throws PropelException - */ - public function countCartItems(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collCartItemsPartial && !$this->isNew(); - if (null === $this->collCartItems || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCartItems) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getCartItems()); - } - - $query = ChildCartItemQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); - } - - return count($this->collCartItems); - } - - /** - * Method called to associate a ChildCartItem object to this object - * through the ChildCartItem foreign key attribute. - * - * @param ChildCartItem $l ChildCartItem - * @return \Thelia\Model\Combination The current object (for fluent API support) - */ - public function addCartItem(ChildCartItem $l) - { - if ($this->collCartItems === null) { - $this->initCartItems(); - $this->collCartItemsPartial = true; - } - - if (!in_array($l, $this->collCartItems->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCartItem($l); - } - - return $this; - } - - /** - * @param CartItem $cartItem The cartItem object to add. - */ - protected function doAddCartItem($cartItem) - { - $this->collCartItems[]= $cartItem; - $cartItem->setCombination($this); - } - - /** - * @param CartItem $cartItem The cartItem object to remove. - * @return ChildCombination The current object (for fluent API support) - */ - public function removeCartItem($cartItem) - { - if ($this->getCartItems()->contains($cartItem)) { - $this->collCartItems->remove($this->collCartItems->search($cartItem)); - if (null === $this->cartItemsScheduledForDeletion) { - $this->cartItemsScheduledForDeletion = clone $this->collCartItems; - $this->cartItemsScheduledForDeletion->clear(); - } - $this->cartItemsScheduledForDeletion[]= $cartItem; - $cartItem->setCombination(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related CartItems from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildCartItem[] List of ChildCartItem objects - */ - public function getCartItemsJoinCart($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildCartItemQuery::create(null, $criteria); - $query->joinWith('Cart', $joinBehavior); - - return $this->getCartItems($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related CartItems from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildCartItem[] List of ChildCartItem objects - */ - public function getCartItemsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildCartItemQuery::create(null, $criteria); - $query->joinWith('Product', $joinBehavior); - - return $this->getCartItems($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->ref = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - if ($this->collAttributeCombinations) { - foreach ($this->collAttributeCombinations as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collStocks) { - foreach ($this->collStocks as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCartItems) { - foreach ($this->collCartItems as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - if ($this->collAttributeCombinations instanceof Collection) { - $this->collAttributeCombinations->clearIterator(); - } - $this->collAttributeCombinations = null; - if ($this->collStocks instanceof Collection) { - $this->collStocks->clearIterator(); - } - $this->collStocks = null; - if ($this->collCartItems instanceof Collection) { - $this->collCartItems->clearIterator(); - } - $this->collCartItems = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CombinationTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildCombination The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/CombinationQuery.php b/core/lib/Thelia/Model/Base/CombinationQuery.php deleted file mode 100755 index d14358739..000000000 --- a/core/lib/Thelia/Model/Base/CombinationQuery.php +++ /dev/null @@ -1,771 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildCombination|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildCombination A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, REF, CREATED_AT, UPDATED_AT FROM combination WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildCombination(); - $obj->hydrate($row); - CombinationTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildCombination|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CombinationTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CombinationTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id 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 ChildCombinationQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the ref column - * - * Example usage: - * - * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue' - * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%' - * - * - * @param string $ref 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 ChildCombinationQuery The current query, for fluid interface - */ - public function filterByRef($ref = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($ref)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $ref)) { - $ref = str_replace('*', '%', $ref); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CombinationTableMap::REF, $ref, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * 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 ChildCombinationQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * 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 ChildCombinationQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\AttributeCombination object - * - * @param \Thelia\Model\AttributeCombination|ObjectCollection $attributeCombination the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeCombination($attributeCombination, $comparison = null) - { - if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) { - return $this - ->addUsingAlias(CombinationTableMap::ID, $attributeCombination->getCombinationId(), $comparison); - } elseif ($attributeCombination instanceof ObjectCollection) { - return $this - ->useAttributeCombinationQuery() - ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCombination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCombination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCombination'); - } - - return $this; - } - - /** - * Use the AttributeCombination relation AttributeCombination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query - */ - public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Stock object - * - * @param \Thelia\Model\Stock|ObjectCollection $stock the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function filterByStock($stock, $comparison = null) - { - if ($stock instanceof \Thelia\Model\Stock) { - return $this - ->addUsingAlias(CombinationTableMap::ID, $stock->getCombinationId(), $comparison); - } elseif ($stock instanceof ObjectCollection) { - return $this - ->useStockQuery() - ->filterByPrimaryKeys($stock->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Stock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Stock'); - } - - return $this; - } - - /** - * Use the Stock relation Stock object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query - */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\CartItem object - * - * @param \Thelia\Model\CartItem|ObjectCollection $cartItem the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function filterByCartItem($cartItem, $comparison = null) - { - if ($cartItem instanceof \Thelia\Model\CartItem) { - return $this - ->addUsingAlias(CombinationTableMap::ID, $cartItem->getCombinationId(), $comparison); - } elseif ($cartItem instanceof ObjectCollection) { - return $this - ->useCartItemQuery() - ->filterByPrimaryKeys($cartItem->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCartItem() only accepts arguments of type \Thelia\Model\CartItem or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the CartItem relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function joinCartItem($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CartItem'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CartItem'); - } - - return $this; - } - - /** - * Use the CartItem relation CartItem object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CartItemQuery A secondary query class using the current class as primary query - */ - public function useCartItemQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCartItem($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CartItem', '\Thelia\Model\CartItemQuery'); - } - - /** - * Exclude object from result - * - * @param ChildCombination $combination Object to remove from the list of results - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function prune($combination = null) - { - if ($combination) { - $this->addUsingAlias(CombinationTableMap::ID, $combination->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the combination table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CombinationTableMap::clearInstancePool(); - CombinationTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildCombination or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildCombination object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(CombinationTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - CombinationTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - CombinationTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CombinationTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CombinationTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CombinationTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildCombinationQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CombinationTableMap::CREATED_AT); - } - -} // CombinationQuery diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ConfigI18nQuery.php b/core/lib/Thelia/Model/Base/ConfigI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentAssoc.php b/core/lib/Thelia/Model/Base/ContentAssoc.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentAssocQuery.php b/core/lib/Thelia/Model/Base/ContentAssocQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentFolderQuery.php b/core/lib/Thelia/Model/Base/ContentFolderQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentI18nQuery.php b/core/lib/Thelia/Model/Base/ContentI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ContentVersionQuery.php b/core/lib/Thelia/Model/Base/ContentVersionQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CountryI18nQuery.php b/core/lib/Thelia/Model/Base/CountryI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CouponRule.php b/core/lib/Thelia/Model/Base/CouponRule.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CouponRuleQuery.php b/core/lib/Thelia/Model/Base/CouponRuleQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php old mode 100755 new mode 100644 index 5e0de24b5..5ab40a742 --- a/core/lib/Thelia/Model/Base/Currency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -20,6 +20,8 @@ use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Cart as ChildCart; use Thelia\Model\CartQuery as ChildCartQuery; use Thelia\Model\Currency as ChildCurrency; +use Thelia\Model\CurrencyI18n as ChildCurrencyI18n; +use Thelia\Model\CurrencyI18nQuery as ChildCurrencyI18nQuery; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; @@ -67,12 +69,6 @@ abstract class Currency implements ActiveRecordInterface */ protected $id; - /** - * The value for the name field. - * @var string - */ - protected $name; - /** * The value for the code field. * @var string @@ -127,6 +123,12 @@ abstract class Currency implements ActiveRecordInterface protected $collProductPrices; protected $collProductPricesPartial; + /** + * @var ObjectCollection|ChildCurrencyI18n[] Collection to store aggregation of ChildCurrencyI18n objects. + */ + protected $collCurrencyI18ns; + protected $collCurrencyI18nsPartial; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -135,6 +137,20 @@ abstract class Currency implements ActiveRecordInterface */ protected $alreadyInSave = false; + // i18n behavior + + /** + * Current locale + * @var string + */ + protected $currentLocale = 'en_US'; + + /** + * Current translation objects + * @var array[ChildCurrencyI18n] + */ + protected $currentTranslations; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -153,6 +169,12 @@ abstract class Currency implements ActiveRecordInterface */ protected $productPricesScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $currencyI18nsScheduledForDeletion = null; + /** * Initializes internal state of Thelia\Model\Base\Currency object. */ @@ -418,17 +440,6 @@ abstract class Currency implements ActiveRecordInterface return $this->id; } - /** - * Get the [name] column value. - * - * @return string - */ - public function getName() - { - - return $this->name; - } - /** * Get the [code] column value. * @@ -534,27 +545,6 @@ abstract class Currency implements ActiveRecordInterface return $this; } // setId() - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return \Thelia\Model\Currency The current object (for fluent API support) - */ - public function setName($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CurrencyTableMap::NAME; - } - - - return $this; - } // setName() - /** * Set the value of [code] column. * @@ -721,28 +711,25 @@ abstract class Currency implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CurrencyTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CurrencyTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; - $this->name = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CurrencyTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; $this->code = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Symbol', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyTableMap::translateFieldName('Symbol', TableMap::TYPE_PHPNAME, $indexType)]; $this->symbol = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)]; $this->rate = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; $this->by_default = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::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 ? 7 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -755,7 +742,7 @@ abstract class Currency implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 8; // 8 = CurrencyTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 7; // 7 = CurrencyTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Currency object", 0, $e); @@ -822,6 +809,8 @@ abstract class Currency implements ActiveRecordInterface $this->collProductPrices = null; + $this->collCurrencyI18ns = null; + } // if (deep) } @@ -1008,6 +997,23 @@ abstract class Currency implements ActiveRecordInterface } } + if ($this->currencyI18nsScheduledForDeletion !== null) { + if (!$this->currencyI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\CurrencyI18nQuery::create() + ->filterByPrimaryKeys($this->currencyI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->currencyI18nsScheduledForDeletion = null; + } + } + + if ($this->collCurrencyI18ns !== null) { + foreach ($this->collCurrencyI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + $this->alreadyInSave = false; } @@ -1037,9 +1043,6 @@ abstract class Currency implements ActiveRecordInterface if ($this->isColumnModified(CurrencyTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CurrencyTableMap::NAME)) { - $modifiedColumns[':p' . $index++] = 'NAME'; - } if ($this->isColumnModified(CurrencyTableMap::CODE)) { $modifiedColumns[':p' . $index++] = 'CODE'; } @@ -1072,9 +1075,6 @@ abstract class Currency implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'NAME': - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); - break; case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; @@ -1159,24 +1159,21 @@ abstract class Currency implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getName(); - break; - case 2: return $this->getCode(); break; - case 3: + case 2: return $this->getSymbol(); break; - case 4: + case 3: return $this->getRate(); break; - case 5: + case 4: return $this->getByDefault(); break; - case 6: + case 5: return $this->getCreatedAt(); break; - case 7: + case 6: return $this->getUpdatedAt(); break; default: @@ -1209,13 +1206,12 @@ abstract class Currency implements ActiveRecordInterface $keys = CurrencyTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getName(), - $keys[2] => $this->getCode(), - $keys[3] => $this->getSymbol(), - $keys[4] => $this->getRate(), - $keys[5] => $this->getByDefault(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), + $keys[1] => $this->getCode(), + $keys[2] => $this->getSymbol(), + $keys[3] => $this->getRate(), + $keys[4] => $this->getByDefault(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1233,6 +1229,9 @@ abstract class Currency implements ActiveRecordInterface if (null !== $this->collProductPrices) { $result['ProductPrices'] = $this->collProductPrices->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collCurrencyI18ns) { + $result['CurrencyI18ns'] = $this->collCurrencyI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } } return $result; @@ -1271,24 +1270,21 @@ abstract class Currency implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setName($value); - break; - case 2: $this->setCode($value); break; - case 3: + case 2: $this->setSymbol($value); break; - case 4: + case 3: $this->setRate($value); break; - case 5: + case 4: $this->setByDefault($value); break; - case 6: + case 5: $this->setCreatedAt($value); break; - case 7: + case 6: $this->setUpdatedAt($value); break; } // switch() @@ -1316,13 +1312,12 @@ abstract class Currency implements ActiveRecordInterface $keys = CurrencyTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setSymbol($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setByDefault($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]]); + if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setSymbol($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setRate($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } /** @@ -1335,7 +1330,6 @@ abstract class Currency implements ActiveRecordInterface $criteria = new Criteria(CurrencyTableMap::DATABASE_NAME); if ($this->isColumnModified(CurrencyTableMap::ID)) $criteria->add(CurrencyTableMap::ID, $this->id); - if ($this->isColumnModified(CurrencyTableMap::NAME)) $criteria->add(CurrencyTableMap::NAME, $this->name); if ($this->isColumnModified(CurrencyTableMap::CODE)) $criteria->add(CurrencyTableMap::CODE, $this->code); if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) $criteria->add(CurrencyTableMap::SYMBOL, $this->symbol); if ($this->isColumnModified(CurrencyTableMap::RATE)) $criteria->add(CurrencyTableMap::RATE, $this->rate); @@ -1405,7 +1399,6 @@ abstract class Currency implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setName($this->getName()); $copyObj->setCode($this->getCode()); $copyObj->setSymbol($this->getSymbol()); $copyObj->setRate($this->getRate()); @@ -1436,6 +1429,12 @@ abstract class Currency implements ActiveRecordInterface } } + foreach ($this->getCurrencyI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addCurrencyI18n($relObj->copy($deepCopy)); + } + } + } // if ($deepCopy) if ($makeNew) { @@ -1486,6 +1485,9 @@ abstract class Currency implements ActiveRecordInterface if ('ProductPrice' == $relationName) { return $this->initProductPrices(); } + if ('CurrencyI18n' == $relationName) { + return $this->initCurrencyI18ns(); + } } /** @@ -2334,21 +2336,245 @@ abstract class Currency implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildProductPrice[] List of ChildProductPrice objects */ - public function getProductPricesJoinStock($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getProductPricesJoinProductSaleElements($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildProductPriceQuery::create(null, $criteria); - $query->joinWith('Stock', $joinBehavior); + $query->joinWith('ProductSaleElements', $joinBehavior); return $this->getProductPrices($query, $con); } + /** + * Clears out the collCurrencyI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCurrencyI18ns() + */ + public function clearCurrencyI18ns() + { + $this->collCurrencyI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCurrencyI18ns collection loaded partially. + */ + public function resetPartialCurrencyI18ns($v = true) + { + $this->collCurrencyI18nsPartial = $v; + } + + /** + * Initializes the collCurrencyI18ns collection. + * + * By default this just sets the collCurrencyI18ns collection to an empty array (like clearcollCurrencyI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCurrencyI18ns($overrideExisting = true) + { + if (null !== $this->collCurrencyI18ns && !$overrideExisting) { + return; + } + $this->collCurrencyI18ns = new ObjectCollection(); + $this->collCurrencyI18ns->setModel('\Thelia\Model\CurrencyI18n'); + } + + /** + * Gets an array of ChildCurrencyI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildCurrency is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCurrencyI18n[] List of ChildCurrencyI18n objects + * @throws PropelException + */ + public function getCurrencyI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCurrencyI18nsPartial && !$this->isNew(); + if (null === $this->collCurrencyI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCurrencyI18ns) { + // return empty collection + $this->initCurrencyI18ns(); + } else { + $collCurrencyI18ns = ChildCurrencyI18nQuery::create(null, $criteria) + ->filterByCurrency($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCurrencyI18nsPartial && count($collCurrencyI18ns)) { + $this->initCurrencyI18ns(false); + + foreach ($collCurrencyI18ns as $obj) { + if (false == $this->collCurrencyI18ns->contains($obj)) { + $this->collCurrencyI18ns->append($obj); + } + } + + $this->collCurrencyI18nsPartial = true; + } + + $collCurrencyI18ns->getInternalIterator()->rewind(); + + return $collCurrencyI18ns; + } + + if ($partial && $this->collCurrencyI18ns) { + foreach ($this->collCurrencyI18ns as $obj) { + if ($obj->isNew()) { + $collCurrencyI18ns[] = $obj; + } + } + } + + $this->collCurrencyI18ns = $collCurrencyI18ns; + $this->collCurrencyI18nsPartial = false; + } + } + + return $this->collCurrencyI18ns; + } + + /** + * Sets a collection of CurrencyI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $currencyI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCurrency The current object (for fluent API support) + */ + public function setCurrencyI18ns(Collection $currencyI18ns, ConnectionInterface $con = null) + { + $currencyI18nsToDelete = $this->getCurrencyI18ns(new Criteria(), $con)->diff($currencyI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->currencyI18nsScheduledForDeletion = clone $currencyI18nsToDelete; + + foreach ($currencyI18nsToDelete as $currencyI18nRemoved) { + $currencyI18nRemoved->setCurrency(null); + } + + $this->collCurrencyI18ns = null; + foreach ($currencyI18ns as $currencyI18n) { + $this->addCurrencyI18n($currencyI18n); + } + + $this->collCurrencyI18ns = $currencyI18ns; + $this->collCurrencyI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related CurrencyI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related CurrencyI18n objects. + * @throws PropelException + */ + public function countCurrencyI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCurrencyI18nsPartial && !$this->isNew(); + if (null === $this->collCurrencyI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCurrencyI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCurrencyI18ns()); + } + + $query = ChildCurrencyI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByCurrency($this) + ->count($con); + } + + return count($this->collCurrencyI18ns); + } + + /** + * Method called to associate a ChildCurrencyI18n object to this object + * through the ChildCurrencyI18n foreign key attribute. + * + * @param ChildCurrencyI18n $l ChildCurrencyI18n + * @return \Thelia\Model\Currency The current object (for fluent API support) + */ + public function addCurrencyI18n(ChildCurrencyI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collCurrencyI18ns === null) { + $this->initCurrencyI18ns(); + $this->collCurrencyI18nsPartial = true; + } + + if (!in_array($l, $this->collCurrencyI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCurrencyI18n($l); + } + + return $this; + } + + /** + * @param CurrencyI18n $currencyI18n The currencyI18n object to add. + */ + protected function doAddCurrencyI18n($currencyI18n) + { + $this->collCurrencyI18ns[]= $currencyI18n; + $currencyI18n->setCurrency($this); + } + + /** + * @param CurrencyI18n $currencyI18n The currencyI18n object to remove. + * @return ChildCurrency The current object (for fluent API support) + */ + public function removeCurrencyI18n($currencyI18n) + { + if ($this->getCurrencyI18ns()->contains($currencyI18n)) { + $this->collCurrencyI18ns->remove($this->collCurrencyI18ns->search($currencyI18n)); + if (null === $this->currencyI18nsScheduledForDeletion) { + $this->currencyI18nsScheduledForDeletion = clone $this->collCurrencyI18ns; + $this->currencyI18nsScheduledForDeletion->clear(); + } + $this->currencyI18nsScheduledForDeletion[]= clone $currencyI18n; + $currencyI18n->setCurrency(null); + } + + return $this; + } + /** * Clears the current object and sets all attributes to their default values */ public function clear() { $this->id = null; - $this->name = null; $this->code = null; $this->symbol = null; $this->rate = null; @@ -2389,8 +2615,17 @@ abstract class Currency implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collCurrencyI18ns) { + foreach ($this->collCurrencyI18ns as $o) { + $o->clearAllReferences($deep); + } + } } // if ($deep) + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + if ($this->collOrders instanceof Collection) { $this->collOrders->clearIterator(); } @@ -2403,6 +2638,10 @@ abstract class Currency implements ActiveRecordInterface $this->collProductPrices->clearIterator(); } $this->collProductPrices = null; + if ($this->collCurrencyI18ns instanceof Collection) { + $this->collCurrencyI18ns->clearIterator(); + } + $this->collCurrencyI18ns = null; } /** @@ -2429,6 +2668,129 @@ abstract class Currency implements ActiveRecordInterface return $this; } + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildCurrency The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCurrencyI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collCurrencyI18ns) { + foreach ($this->collCurrencyI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildCurrencyI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildCurrencyI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addCurrencyI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCurrency The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildCurrencyI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collCurrencyI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collCurrencyI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCurrencyI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + return $this->getCurrentTranslation()->getName(); + } + + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return \Thelia\Model\CurrencyI18n The current object (for fluent API support) + */ + public function setName($v) + { $this->getCurrentTranslation()->setName($v); + + return $this; + } + /** * Code to be run before persisting the object * @param ConnectionInterface $con diff --git a/core/lib/Thelia/Model/Base/CurrencyI18n.php b/core/lib/Thelia/Model/Base/CurrencyI18n.php new file mode 100644 index 000000000..eb86a87c4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CurrencyI18n.php @@ -0,0 +1,1265 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CurrencyI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CurrencyI18n instance. If + * obj is an instance of CurrencyI18n, delegates to + * equals(CurrencyI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CurrencyI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CurrencyI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [name] column value. + * + * @return string + */ + public function getName() + { + + return $this->name; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CurrencyI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CurrencyI18nTableMap::ID; + } + + if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) { + $this->aCurrency = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\CurrencyI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CurrencyI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return \Thelia\Model\CurrencyI18n The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = CurrencyI18nTableMap::NAME; + } + + + return $this; + } // setName() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CurrencyI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CurrencyI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyI18nTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 3; // 3 = CurrencyI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CurrencyI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aCurrency !== null && $this->id !== $this->aCurrency->getId()) { + $this->aCurrency = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCurrencyI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCurrency = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CurrencyI18n::setDeleted() + * @see CurrencyI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCurrencyI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CurrencyI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aCurrency !== null) { + if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) { + $affectedRows += $this->aCurrency->save($con); + } + $this->setCurrency($this->aCurrency); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CurrencyI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CurrencyI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CurrencyI18nTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; + } + + $sql = sprintf( + 'INSERT INTO currency_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'NAME': + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CurrencyI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getName(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CurrencyI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CurrencyI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CurrencyI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getName(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aCurrency) { + $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CurrencyI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setName($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = CurrencyI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(CurrencyI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CurrencyI18nTableMap::ID)) $criteria->add(CurrencyI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CurrencyI18nTableMap::LOCALE)) $criteria->add(CurrencyI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CurrencyI18nTableMap::NAME)) $criteria->add(CurrencyI18nTableMap::NAME, $this->name); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(CurrencyI18nTableMap::DATABASE_NAME); + $criteria->add(CurrencyI18nTableMap::ID, $this->id); + $criteria->add(CurrencyI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\CurrencyI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setName($this->getName()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CurrencyI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildCurrency object. + * + * @param ChildCurrency $v + * @return \Thelia\Model\CurrencyI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCurrency(ChildCurrency $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aCurrency = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildCurrency object, it will not be re-added. + if ($v !== null) { + $v->addCurrencyI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCurrency object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCurrency The associated ChildCurrency object. + * @throws PropelException + */ + public function getCurrency(ConnectionInterface $con = null) + { + if ($this->aCurrency === null && ($this->id !== null)) { + $this->aCurrency = ChildCurrencyQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aCurrency->addCurrencyI18ns($this); + */ + } + + return $this->aCurrency; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->name = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCurrency = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CurrencyI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CurrencyI18nQuery.php b/core/lib/Thelia/Model/Base/CurrencyI18nQuery.php new file mode 100644 index 000000000..33af4ff87 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CurrencyI18nQuery.php @@ -0,0 +1,508 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCurrencyI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CurrencyI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCurrencyI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, NAME FROM currency_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCurrencyI18n(); + $obj->hydrate($row); + CurrencyI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCurrencyI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CurrencyI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CurrencyI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(CurrencyI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CurrencyI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByCurrency() + * + * @param mixed $id 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 ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(CurrencyI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CurrencyI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CurrencyI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale 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 ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CurrencyI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the name column + * + * Example usage: + * + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' + * + * + * @param string $name 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 ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterByName($name = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($name)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $name)) { + $name = str_replace('*', '%', $name); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(CurrencyI18nTableMap::NAME, $name, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Currency object + * + * @param \Thelia\Model\Currency|ObjectCollection $currency The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function filterByCurrency($currency, $comparison = null) + { + if ($currency instanceof \Thelia\Model\Currency) { + return $this + ->addUsingAlias(CurrencyI18nTableMap::ID, $currency->getId(), $comparison); + } elseif ($currency instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CurrencyI18nTableMap::ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCurrency() only accepts arguments of type \Thelia\Model\Currency or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Currency relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function joinCurrency($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Currency'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Currency'); + } + + return $this; + } + + /** + * Use the Currency relation Currency object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query + */ + public function useCurrencyQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCurrency($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Currency', '\Thelia\Model\CurrencyQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCurrencyI18n $currencyI18n Object to remove from the list of results + * + * @return ChildCurrencyI18nQuery The current query, for fluid interface + */ + public function prune($currencyI18n = null) + { + if ($currencyI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CurrencyI18nTableMap::ID), $currencyI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CurrencyI18nTableMap::LOCALE), $currencyI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the currency_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CurrencyI18nTableMap::clearInstancePool(); + CurrencyI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCurrencyI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCurrencyI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CurrencyI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CurrencyI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CurrencyI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CurrencyI18nQuery diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php old mode 100755 new mode 100644 index 0718e56c7..140b70463 --- a/core/lib/Thelia/Model/Base/CurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -13,6 +13,7 @@ use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; use Thelia\Model\Currency as ChildCurrency; +use Thelia\Model\CurrencyI18nQuery as ChildCurrencyI18nQuery; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\Map\CurrencyTableMap; @@ -22,7 +23,6 @@ use Thelia\Model\Map\CurrencyTableMap; * * * @method ChildCurrencyQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildCurrencyQuery orderByName($order = Criteria::ASC) Order by the name column * @method ChildCurrencyQuery orderByCode($order = Criteria::ASC) Order by the code column * @method ChildCurrencyQuery orderBySymbol($order = Criteria::ASC) Order by the symbol column * @method ChildCurrencyQuery orderByRate($order = Criteria::ASC) Order by the rate column @@ -31,7 +31,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrencyQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildCurrencyQuery groupById() Group by the id column - * @method ChildCurrencyQuery groupByName() Group by the name column * @method ChildCurrencyQuery groupByCode() Group by the code column * @method ChildCurrencyQuery groupBySymbol() Group by the symbol column * @method ChildCurrencyQuery groupByRate() Group by the rate column @@ -55,11 +54,14 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrencyQuery rightJoinProductPrice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductPrice relation * @method ChildCurrencyQuery innerJoinProductPrice($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductPrice relation * + * @method ChildCurrencyQuery leftJoinCurrencyI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CurrencyI18n relation + * @method ChildCurrencyQuery rightJoinCurrencyI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CurrencyI18n relation + * @method ChildCurrencyQuery innerJoinCurrencyI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CurrencyI18n relation + * * @method ChildCurrency findOne(ConnectionInterface $con = null) Return the first ChildCurrency matching the query * @method ChildCurrency findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCurrency matching the query, or a new ChildCurrency object populated from the query conditions when no match is found * * @method ChildCurrency findOneById(int $id) Return the first ChildCurrency filtered by the id column - * @method ChildCurrency findOneByName(string $name) Return the first ChildCurrency filtered by the name column * @method ChildCurrency findOneByCode(string $code) Return the first ChildCurrency filtered by the code column * @method ChildCurrency findOneBySymbol(string $symbol) Return the first ChildCurrency filtered by the symbol column * @method ChildCurrency findOneByRate(double $rate) Return the first ChildCurrency filtered by the rate column @@ -68,7 +70,6 @@ use Thelia\Model\Map\CurrencyTableMap; * @method ChildCurrency findOneByUpdatedAt(string $updated_at) Return the first ChildCurrency filtered by the updated_at column * * @method array findById(int $id) Return ChildCurrency objects filtered by the id column - * @method array findByName(string $name) Return ChildCurrency objects filtered by the name column * @method array findByCode(string $code) Return ChildCurrency objects filtered by the code column * @method array findBySymbol(string $symbol) Return ChildCurrency objects filtered by the symbol column * @method array findByRate(double $rate) Return ChildCurrency objects filtered by the rate column @@ -163,7 +164,7 @@ abstract class CurrencyQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, NAME, CODE, SYMBOL, RATE, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0'; + $sql = 'SELECT ID, CODE, SYMBOL, RATE, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -293,35 +294,6 @@ abstract class CurrencyQuery extends ModelCriteria return $this->addUsingAlias(CurrencyTableMap::ID, $id, $comparison); } - /** - * Filter the query on the name column - * - * Example usage: - * - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' - * - * - * @param string $name 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 ChildCurrencyQuery The current query, for fluid interface - */ - public function filterByName($name = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($name)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $name)) { - $name = str_replace('*', '%', $name); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CurrencyTableMap::NAME, $name, $comparison); - } - /** * Filter the query on the code column * @@ -767,6 +739,79 @@ abstract class CurrencyQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'ProductPrice', '\Thelia\Model\ProductPriceQuery'); } + /** + * Filter the query by a related \Thelia\Model\CurrencyI18n object + * + * @param \Thelia\Model\CurrencyI18n|ObjectCollection $currencyI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function filterByCurrencyI18n($currencyI18n, $comparison = null) + { + if ($currencyI18n instanceof \Thelia\Model\CurrencyI18n) { + return $this + ->addUsingAlias(CurrencyTableMap::ID, $currencyI18n->getId(), $comparison); + } elseif ($currencyI18n instanceof ObjectCollection) { + return $this + ->useCurrencyI18nQuery() + ->filterByPrimaryKeys($currencyI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByCurrencyI18n() only accepts arguments of type \Thelia\Model\CurrencyI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the CurrencyI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function joinCurrencyI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('CurrencyI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'CurrencyI18n'); + } + + return $this; + } + + /** + * Use the CurrencyI18n relation CurrencyI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\CurrencyI18nQuery A secondary query class using the current class as primary query + */ + public function useCurrencyI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinCurrencyI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CurrencyI18n', '\Thelia\Model\CurrencyI18nQuery'); + } + /** * Exclude object from result * @@ -924,4 +969,61 @@ abstract class CurrencyQuery extends ModelCriteria return $this->addAscendingOrderByColumn(CurrencyTableMap::CREATED_AT); } + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'CurrencyI18n'; + + return $this + ->joinCurrencyI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('CurrencyI18n'); + $this->with['CurrencyI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildCurrencyI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CurrencyI18n', '\Thelia\Model\CurrencyI18nQuery'); + } + } // CurrencyQuery diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/Delivzone.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/DelivzoneQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Document.php b/core/lib/Thelia/Model/Base/Document.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/DocumentI18n.php b/core/lib/Thelia/Model/Base/DocumentI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/DocumentI18nQuery.php b/core/lib/Thelia/Model/Base/DocumentI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/DocumentQuery.php b/core/lib/Thelia/Model/Base/DocumentQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php b/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FolderI18nQuery.php b/core/lib/Thelia/Model/Base/FolderI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/FolderVersionQuery.php b/core/lib/Thelia/Model/Base/FolderVersionQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupI18nQuery.php b/core/lib/Thelia/Model/Base/GroupI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupModuleQuery.php b/core/lib/Thelia/Model/Base/GroupModuleQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/GroupResourceQuery.php b/core/lib/Thelia/Model/Base/GroupResourceQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Image.php b/core/lib/Thelia/Model/Base/Image.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ImageI18n.php b/core/lib/Thelia/Model/Base/ImageI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ImageI18nQuery.php b/core/lib/Thelia/Model/Base/ImageI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ImageQuery.php b/core/lib/Thelia/Model/Base/ImageQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/LangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/MessageI18nQuery.php b/core/lib/Thelia/Model/Base/MessageI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/MessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/MessageVersionQuery.php b/core/lib/Thelia/Model/Base/MessageVersionQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ModuleI18nQuery.php b/core/lib/Thelia/Model/Base/ModuleI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderAddressQuery.php b/core/lib/Thelia/Model/Base/OrderAddressQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderFeature.php b/core/lib/Thelia/Model/Base/OrderFeature.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderFeatureQuery.php b/core/lib/Thelia/Model/Base/OrderFeatureQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php b/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php old mode 100755 new mode 100644 index c4a1fda12..d8ca1d36b --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -37,12 +37,12 @@ use Thelia\Model\ProductCategoryQuery as ChildProductCategoryQuery; use Thelia\Model\ProductI18n as ChildProductI18n; use Thelia\Model\ProductI18nQuery as ChildProductI18nQuery; use Thelia\Model\ProductQuery as ChildProductQuery; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\ProductVersion as ChildProductVersion; use Thelia\Model\ProductVersionQuery as ChildProductVersionQuery; use Thelia\Model\Rewriting as ChildRewriting; use Thelia\Model\RewritingQuery as ChildRewritingQuery; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; use Thelia\Model\TaxRule as ChildTaxRule; use Thelia\Model\TaxRuleQuery as ChildTaxRuleQuery; use Thelia\Model\Map\ProductTableMap; @@ -162,10 +162,10 @@ abstract class Product implements ActiveRecordInterface protected $collFeatureProductsPartial; /** - * @var ObjectCollection|ChildStock[] Collection to store aggregation of ChildStock objects. + * @var ObjectCollection|ChildProductSaleElements[] Collection to store aggregation of ChildProductSaleElements objects. */ - protected $collStocks; - protected $collStocksPartial; + protected $collProductSaleElementss; + protected $collProductSaleElementssPartial; /** * @var ObjectCollection|ChildContentAssoc[] Collection to store aggregation of ChildContentAssoc objects. @@ -300,7 +300,7 @@ abstract class Product implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $stocksScheduledForDeletion = null; + protected $productSaleElementssScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -1135,7 +1135,7 @@ abstract class Product implements ActiveRecordInterface $this->collFeatureProducts = null; - $this->collStocks = null; + $this->collProductSaleElementss = null; $this->collContentAssocs = null; @@ -1430,17 +1430,17 @@ abstract class Product implements ActiveRecordInterface } } - if ($this->stocksScheduledForDeletion !== null) { - if (!$this->stocksScheduledForDeletion->isEmpty()) { - \Thelia\Model\StockQuery::create() - ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false)) + if ($this->productSaleElementssScheduledForDeletion !== null) { + if (!$this->productSaleElementssScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductSaleElementsQuery::create() + ->filterByPrimaryKeys($this->productSaleElementssScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->stocksScheduledForDeletion = null; + $this->productSaleElementssScheduledForDeletion = null; } } - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { + if ($this->collProductSaleElementss !== null) { + foreach ($this->collProductSaleElementss as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1845,8 +1845,8 @@ abstract class Product implements ActiveRecordInterface if (null !== $this->collFeatureProducts) { $result['FeatureProducts'] = $this->collFeatureProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collStocks) { - $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProductSaleElementss) { + $result['ProductSaleElementss'] = $this->collProductSaleElementss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -2084,9 +2084,9 @@ abstract class Product implements ActiveRecordInterface } } - foreach ($this->getStocks() as $relObj) { + foreach ($this->getProductSaleElementss() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addStock($relObj->copy($deepCopy)); + $copyObj->addProductSaleElements($relObj->copy($deepCopy)); } } @@ -2242,8 +2242,8 @@ abstract class Product implements ActiveRecordInterface if ('FeatureProduct' == $relationName) { return $this->initFeatureProducts(); } - if ('Stock' == $relationName) { - return $this->initStocks(); + if ('ProductSaleElements' == $relationName) { + return $this->initProductSaleElementss(); } if ('ContentAssoc' == $relationName) { return $this->initContentAssocs(); @@ -2789,31 +2789,31 @@ abstract class Product implements ActiveRecordInterface } /** - * Clears out the collStocks collection + * Clears out the collProductSaleElementss collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addStocks() + * @see addProductSaleElementss() */ - public function clearStocks() + public function clearProductSaleElementss() { - $this->collStocks = null; // important to set this to NULL since that means it is uninitialized + $this->collProductSaleElementss = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collStocks collection loaded partially. + * Reset is the collProductSaleElementss collection loaded partially. */ - public function resetPartialStocks($v = true) + public function resetPartialProductSaleElementss($v = true) { - $this->collStocksPartial = $v; + $this->collProductSaleElementssPartial = $v; } /** - * Initializes the collStocks collection. + * Initializes the collProductSaleElementss collection. * - * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); + * By default this just sets the collProductSaleElementss collection to an empty array (like clearcollProductSaleElementss()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -2822,17 +2822,17 @@ abstract class Product implements ActiveRecordInterface * * @return void */ - public function initStocks($overrideExisting = true) + public function initProductSaleElementss($overrideExisting = true) { - if (null !== $this->collStocks && !$overrideExisting) { + if (null !== $this->collProductSaleElementss && !$overrideExisting) { return; } - $this->collStocks = new ObjectCollection(); - $this->collStocks->setModel('\Thelia\Model\Stock'); + $this->collProductSaleElementss = new ObjectCollection(); + $this->collProductSaleElementss->setModel('\Thelia\Model\ProductSaleElements'); } /** - * Gets an array of ChildStock objects which contain a foreign key that references this object. + * Gets an array of ChildProductSaleElements objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -2842,109 +2842,109 @@ abstract class Product implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildStock[] List of ChildStock objects + * @return Collection|ChildProductSaleElements[] List of ChildProductSaleElements objects * @throws PropelException */ - public function getStocks($criteria = null, ConnectionInterface $con = null) + public function getProductSaleElementss($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { + $partial = $this->collProductSaleElementssPartial && !$this->isNew(); + if (null === $this->collProductSaleElementss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductSaleElementss) { // return empty collection - $this->initStocks(); + $this->initProductSaleElementss(); } else { - $collStocks = ChildStockQuery::create(null, $criteria) + $collProductSaleElementss = ChildProductSaleElementsQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); + if (false !== $this->collProductSaleElementssPartial && count($collProductSaleElementss)) { + $this->initProductSaleElementss(false); - foreach ($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); + foreach ($collProductSaleElementss as $obj) { + if (false == $this->collProductSaleElementss->contains($obj)) { + $this->collProductSaleElementss->append($obj); } } - $this->collStocksPartial = true; + $this->collProductSaleElementssPartial = true; } - $collStocks->getInternalIterator()->rewind(); + $collProductSaleElementss->getInternalIterator()->rewind(); - return $collStocks; + return $collProductSaleElementss; } - if ($partial && $this->collStocks) { - foreach ($this->collStocks as $obj) { + if ($partial && $this->collProductSaleElementss) { + foreach ($this->collProductSaleElementss as $obj) { if ($obj->isNew()) { - $collStocks[] = $obj; + $collProductSaleElementss[] = $obj; } } } - $this->collStocks = $collStocks; - $this->collStocksPartial = false; + $this->collProductSaleElementss = $collProductSaleElementss; + $this->collProductSaleElementssPartial = false; } } - return $this->collStocks; + return $this->collProductSaleElementss; } /** - * Sets a collection of Stock objects related by a one-to-many relationship + * Sets a collection of ProductSaleElements objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $stocks A Propel collection. + * @param Collection $productSaleElementss A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildProduct The current object (for fluent API support) */ - public function setStocks(Collection $stocks, ConnectionInterface $con = null) + public function setProductSaleElementss(Collection $productSaleElementss, ConnectionInterface $con = null) { - $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); + $productSaleElementssToDelete = $this->getProductSaleElementss(new Criteria(), $con)->diff($productSaleElementss); - $this->stocksScheduledForDeletion = $stocksToDelete; + $this->productSaleElementssScheduledForDeletion = $productSaleElementssToDelete; - foreach ($stocksToDelete as $stockRemoved) { - $stockRemoved->setProduct(null); + foreach ($productSaleElementssToDelete as $productSaleElementsRemoved) { + $productSaleElementsRemoved->setProduct(null); } - $this->collStocks = null; - foreach ($stocks as $stock) { - $this->addStock($stock); + $this->collProductSaleElementss = null; + foreach ($productSaleElementss as $productSaleElements) { + $this->addProductSaleElements($productSaleElements); } - $this->collStocks = $stocks; - $this->collStocksPartial = false; + $this->collProductSaleElementss = $productSaleElementss; + $this->collProductSaleElementssPartial = false; return $this; } /** - * Returns the number of related Stock objects. + * Returns the number of related ProductSaleElements objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Stock objects. + * @return int Count of related ProductSaleElements objects. * @throws PropelException */ - public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProductSaleElementss(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { + $partial = $this->collProductSaleElementssPartial && !$this->isNew(); + if (null === $this->collProductSaleElementss || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductSaleElementss) { return 0; } if ($partial && !$criteria) { - return count($this->getStocks()); + return count($this->getProductSaleElementss()); } - $query = ChildStockQuery::create(null, $criteria); + $query = ChildProductSaleElementsQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2954,53 +2954,53 @@ abstract class Product implements ActiveRecordInterface ->count($con); } - return count($this->collStocks); + return count($this->collProductSaleElementss); } /** - * Method called to associate a ChildStock object to this object - * through the ChildStock foreign key attribute. + * Method called to associate a ChildProductSaleElements object to this object + * through the ChildProductSaleElements foreign key attribute. * - * @param ChildStock $l ChildStock + * @param ChildProductSaleElements $l ChildProductSaleElements * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addStock(ChildStock $l) + public function addProductSaleElements(ChildProductSaleElements $l) { - if ($this->collStocks === null) { - $this->initStocks(); - $this->collStocksPartial = true; + if ($this->collProductSaleElementss === null) { + $this->initProductSaleElementss(); + $this->collProductSaleElementssPartial = true; } - if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddStock($l); + if (!in_array($l, $this->collProductSaleElementss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProductSaleElements($l); } return $this; } /** - * @param Stock $stock The stock object to add. + * @param ProductSaleElements $productSaleElements The productSaleElements object to add. */ - protected function doAddStock($stock) + protected function doAddProductSaleElements($productSaleElements) { - $this->collStocks[]= $stock; - $stock->setProduct($this); + $this->collProductSaleElementss[]= $productSaleElements; + $productSaleElements->setProduct($this); } /** - * @param Stock $stock The stock object to remove. + * @param ProductSaleElements $productSaleElements The productSaleElements object to remove. * @return ChildProduct The current object (for fluent API support) */ - public function removeStock($stock) + public function removeProductSaleElements($productSaleElements) { - if ($this->getStocks()->contains($stock)) { - $this->collStocks->remove($this->collStocks->search($stock)); - if (null === $this->stocksScheduledForDeletion) { - $this->stocksScheduledForDeletion = clone $this->collStocks; - $this->stocksScheduledForDeletion->clear(); + if ($this->getProductSaleElementss()->contains($productSaleElements)) { + $this->collProductSaleElementss->remove($this->collProductSaleElementss->search($productSaleElements)); + if (null === $this->productSaleElementssScheduledForDeletion) { + $this->productSaleElementssScheduledForDeletion = clone $this->collProductSaleElementss; + $this->productSaleElementssScheduledForDeletion->clear(); } - $this->stocksScheduledForDeletion[]= clone $stock; - $stock->setProduct(null); + $this->productSaleElementssScheduledForDeletion[]= clone $productSaleElements; + $productSaleElements->setProduct(null); } return $this; @@ -4849,10 +4849,10 @@ abstract class Product implements ActiveRecordInterface * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return Collection|ChildCartItem[] List of ChildCartItem objects */ - public function getCartItemsJoinStock($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getCartItemsJoinProductSaleElements($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildCartItemQuery::create(null, $criteria); - $query->joinWith('Stock', $joinBehavior); + $query->joinWith('ProductSaleElements', $joinBehavior); return $this->getCartItems($query, $con); } @@ -5897,8 +5897,8 @@ abstract class Product implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collStocks) { - foreach ($this->collStocks as $o) { + if ($this->collProductSaleElementss) { + foreach ($this->collProductSaleElementss as $o) { $o->clearAllReferences($deep); } } @@ -5976,10 +5976,10 @@ abstract class Product implements ActiveRecordInterface $this->collFeatureProducts->clearIterator(); } $this->collFeatureProducts = null; - if ($this->collStocks instanceof Collection) { - $this->collStocks->clearIterator(); + if ($this->collProductSaleElementss instanceof Collection) { + $this->collProductSaleElementss->clearIterator(); } - $this->collStocks = null; + $this->collProductSaleElementss = null; if ($this->collContentAssocs instanceof Collection) { $this->collContentAssocs->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ProductI18nQuery.php b/core/lib/Thelia/Model/Base/ProductI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ProductPrice.php b/core/lib/Thelia/Model/Base/ProductPrice.php index ebf350a3b..dab6e47a4 100644 --- a/core/lib/Thelia/Model/Base/ProductPrice.php +++ b/core/lib/Thelia/Model/Base/ProductPrice.php @@ -20,8 +20,8 @@ use Thelia\Model\Currency as ChildCurrency; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\ProductPrice as ChildProductPrice; use Thelia\Model\ProductPriceQuery as ChildProductPriceQuery; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; use Thelia\Model\Map\ProductPriceTableMap; abstract class ProductPrice implements ActiveRecordInterface @@ -65,10 +65,10 @@ abstract class ProductPrice implements ActiveRecordInterface protected $id; /** - * The value for the stock_id field. + * The value for the product_sale_elements_id field. * @var int */ - protected $stock_id; + protected $product_sale_elements_id; /** * The value for the currency_id field. @@ -101,9 +101,9 @@ abstract class ProductPrice implements ActiveRecordInterface protected $updated_at; /** - * @var Stock + * @var ProductSaleElements */ - protected $aStock; + protected $aProductSaleElements; /** * @var Currency @@ -384,14 +384,14 @@ abstract class ProductPrice implements ActiveRecordInterface } /** - * Get the [stock_id] column value. + * Get the [product_sale_elements_id] column value. * * @return int */ - public function getStockId() + public function getProductSaleElementsId() { - return $this->stock_id; + return $this->product_sale_elements_id; } /** @@ -489,29 +489,29 @@ abstract class ProductPrice implements ActiveRecordInterface } // setId() /** - * Set the value of [stock_id] column. + * Set the value of [product_sale_elements_id] column. * * @param int $v new value * @return \Thelia\Model\ProductPrice The current object (for fluent API support) */ - public function setStockId($v) + public function setProductSaleElementsId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->stock_id !== $v) { - $this->stock_id = $v; - $this->modifiedColumns[] = ProductPriceTableMap::STOCK_ID; + if ($this->product_sale_elements_id !== $v) { + $this->product_sale_elements_id = $v; + $this->modifiedColumns[] = ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID; } - if ($this->aStock !== null && $this->aStock->getId() !== $v) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->aProductSaleElements->getId() !== $v) { + $this->aProductSaleElements = null; } return $this; - } // setStockId() + } // setProductSaleElementsId() /** * Set the value of [currency_id] column. @@ -662,8 +662,8 @@ abstract class ProductPrice implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductPriceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('StockId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->stock_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductPriceTableMap::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_sale_elements_id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductPriceTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)]; $this->currency_id = (null !== $col) ? (int) $col : null; @@ -715,8 +715,8 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aStock !== null && $this->stock_id !== $this->aStock->getId()) { - $this->aStock = null; + if ($this->aProductSaleElements !== null && $this->product_sale_elements_id !== $this->aProductSaleElements->getId()) { + $this->aProductSaleElements = null; } if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; @@ -760,7 +760,7 @@ abstract class ProductPrice implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aStock = null; + $this->aProductSaleElements = null; $this->aCurrency = null; } // if (deep) } @@ -889,11 +889,11 @@ abstract class ProductPrice implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aStock !== null) { - if ($this->aStock->isModified() || $this->aStock->isNew()) { - $affectedRows += $this->aStock->save($con); + if ($this->aProductSaleElements !== null) { + if ($this->aProductSaleElements->isModified() || $this->aProductSaleElements->isNew()) { + $affectedRows += $this->aProductSaleElements->save($con); } - $this->setStock($this->aStock); + $this->setProductSaleElements($this->aProductSaleElements); } if ($this->aCurrency !== null) { @@ -943,8 +943,8 @@ abstract class ProductPrice implements ActiveRecordInterface if ($this->isColumnModified(ProductPriceTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ProductPriceTableMap::STOCK_ID)) { - $modifiedColumns[':p' . $index++] = 'STOCK_ID'; + if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; } if ($this->isColumnModified(ProductPriceTableMap::CURRENCY_ID)) { $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; @@ -975,8 +975,8 @@ abstract class ProductPrice implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'STOCK_ID': - $stmt->bindValue($identifier, $this->stock_id, PDO::PARAM_INT); + case 'PRODUCT_SALE_ELEMENTS_ID': + $stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT); break; case 'CURRENCY_ID': $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); @@ -1059,7 +1059,7 @@ abstract class ProductPrice implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getStockId(); + return $this->getProductSaleElementsId(); break; case 2: return $this->getCurrencyId(); @@ -1106,7 +1106,7 @@ abstract class ProductPrice implements ActiveRecordInterface $keys = ProductPriceTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getStockId(), + $keys[1] => $this->getProductSaleElementsId(), $keys[2] => $this->getCurrencyId(), $keys[3] => $this->getPrice(), $keys[4] => $this->getPromoPrice(), @@ -1120,8 +1120,8 @@ abstract class ProductPrice implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aStock) { - $result['Stock'] = $this->aStock->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + if (null !== $this->aProductSaleElements) { + $result['ProductSaleElements'] = $this->aProductSaleElements->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aCurrency) { $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1164,7 +1164,7 @@ abstract class ProductPrice implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setStockId($value); + $this->setProductSaleElementsId($value); break; case 2: $this->setCurrencyId($value); @@ -1206,7 +1206,7 @@ abstract class ProductPrice implements ActiveRecordInterface $keys = ProductPriceTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setStockId($arr[$keys[1]]); + if (array_key_exists($keys[1], $arr)) $this->setProductSaleElementsId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setCurrencyId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setPromoPrice($arr[$keys[4]]); @@ -1224,7 +1224,7 @@ abstract class ProductPrice implements ActiveRecordInterface $criteria = new Criteria(ProductPriceTableMap::DATABASE_NAME); if ($this->isColumnModified(ProductPriceTableMap::ID)) $criteria->add(ProductPriceTableMap::ID, $this->id); - if ($this->isColumnModified(ProductPriceTableMap::STOCK_ID)) $criteria->add(ProductPriceTableMap::STOCK_ID, $this->stock_id); + if ($this->isColumnModified(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); if ($this->isColumnModified(ProductPriceTableMap::CURRENCY_ID)) $criteria->add(ProductPriceTableMap::CURRENCY_ID, $this->currency_id); if ($this->isColumnModified(ProductPriceTableMap::PRICE)) $criteria->add(ProductPriceTableMap::PRICE, $this->price); if ($this->isColumnModified(ProductPriceTableMap::PROMO_PRICE)) $criteria->add(ProductPriceTableMap::PROMO_PRICE, $this->promo_price); @@ -1293,7 +1293,7 @@ abstract class ProductPrice implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setStockId($this->getStockId()); + $copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); $copyObj->setCurrencyId($this->getCurrencyId()); $copyObj->setPrice($this->getPrice()); $copyObj->setPromoPrice($this->getPromoPrice()); @@ -1328,24 +1328,24 @@ abstract class ProductPrice implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildStock object. + * Declares an association between this object and a ChildProductSaleElements object. * - * @param ChildStock $v + * @param ChildProductSaleElements $v * @return \Thelia\Model\ProductPrice The current object (for fluent API support) * @throws PropelException */ - public function setStock(ChildStock $v = null) + public function setProductSaleElements(ChildProductSaleElements $v = null) { if ($v === null) { - $this->setStockId(NULL); + $this->setProductSaleElementsId(NULL); } else { - $this->setStockId($v->getId()); + $this->setProductSaleElementsId($v->getId()); } - $this->aStock = $v; + $this->aProductSaleElements = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildStock object, it will not be re-added. + // If this object has already been added to the ChildProductSaleElements object, it will not be re-added. if ($v !== null) { $v->addProductPrice($this); } @@ -1356,26 +1356,26 @@ abstract class ProductPrice implements ActiveRecordInterface /** - * Get the associated ChildStock object + * Get the associated ChildProductSaleElements object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildStock The associated ChildStock object. + * @return ChildProductSaleElements The associated ChildProductSaleElements object. * @throws PropelException */ - public function getStock(ConnectionInterface $con = null) + public function getProductSaleElements(ConnectionInterface $con = null) { - if ($this->aStock === null && ($this->stock_id !== null)) { - $this->aStock = ChildStockQuery::create()->findPk($this->stock_id, $con); + if ($this->aProductSaleElements === null && ($this->product_sale_elements_id !== null)) { + $this->aProductSaleElements = ChildProductSaleElementsQuery::create()->findPk($this->product_sale_elements_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aStock->addProductPrices($this); + $this->aProductSaleElements->addProductPrices($this); */ } - return $this->aStock; + return $this->aProductSaleElements; } /** @@ -1435,7 +1435,7 @@ abstract class ProductPrice implements ActiveRecordInterface public function clear() { $this->id = null; - $this->stock_id = null; + $this->product_sale_elements_id = null; $this->currency_id = null; $this->price = null; $this->promo_price = null; @@ -1462,7 +1462,7 @@ abstract class ProductPrice implements ActiveRecordInterface if ($deep) { } // if ($deep) - $this->aStock = null; + $this->aProductSaleElements = null; $this->aCurrency = null; } diff --git a/core/lib/Thelia/Model/Base/ProductPriceQuery.php b/core/lib/Thelia/Model/Base/ProductPriceQuery.php index 950c39125..275aebbb2 100644 --- a/core/lib/Thelia/Model/Base/ProductPriceQuery.php +++ b/core/lib/Thelia/Model/Base/ProductPriceQuery.php @@ -22,7 +22,7 @@ use Thelia\Model\Map\ProductPriceTableMap; * * * @method ChildProductPriceQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildProductPriceQuery orderByStockId($order = Criteria::ASC) Order by the stock_id column + * @method ChildProductPriceQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column * @method ChildProductPriceQuery orderByCurrencyId($order = Criteria::ASC) Order by the currency_id column * @method ChildProductPriceQuery orderByPrice($order = Criteria::ASC) Order by the price column * @method ChildProductPriceQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column @@ -30,7 +30,7 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPriceQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildProductPriceQuery groupById() Group by the id column - * @method ChildProductPriceQuery groupByStockId() Group by the stock_id column + * @method ChildProductPriceQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildProductPriceQuery groupByCurrencyId() Group by the currency_id column * @method ChildProductPriceQuery groupByPrice() Group by the price column * @method ChildProductPriceQuery groupByPromoPrice() Group by the promo_price column @@ -41,9 +41,9 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPriceQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildProductPriceQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildProductPriceQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation - * @method ChildProductPriceQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation - * @method ChildProductPriceQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation + * @method ChildProductPriceQuery leftJoinProductSaleElements($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductSaleElements relation + * @method ChildProductPriceQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation + * @method ChildProductPriceQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * * @method ChildProductPriceQuery leftJoinCurrency($relationAlias = null) Adds a LEFT JOIN clause to the query using the Currency relation * @method ChildProductPriceQuery rightJoinCurrency($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Currency relation @@ -53,7 +53,7 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPrice findOneOrCreate(ConnectionInterface $con = null) Return the first ChildProductPrice matching the query, or a new ChildProductPrice object populated from the query conditions when no match is found * * @method ChildProductPrice findOneById(int $id) Return the first ChildProductPrice filtered by the id column - * @method ChildProductPrice findOneByStockId(int $stock_id) Return the first ChildProductPrice filtered by the stock_id column + * @method ChildProductPrice findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildProductPrice filtered by the product_sale_elements_id column * @method ChildProductPrice findOneByCurrencyId(int $currency_id) Return the first ChildProductPrice filtered by the currency_id column * @method ChildProductPrice findOneByPrice(double $price) Return the first ChildProductPrice filtered by the price column * @method ChildProductPrice findOneByPromoPrice(double $promo_price) Return the first ChildProductPrice filtered by the promo_price column @@ -61,7 +61,7 @@ use Thelia\Model\Map\ProductPriceTableMap; * @method ChildProductPrice findOneByUpdatedAt(string $updated_at) Return the first ChildProductPrice filtered by the updated_at column * * @method array findById(int $id) Return ChildProductPrice objects filtered by the id column - * @method array findByStockId(int $stock_id) Return ChildProductPrice objects filtered by the stock_id column + * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildProductPrice objects filtered by the product_sale_elements_id column * @method array findByCurrencyId(int $currency_id) Return ChildProductPrice objects filtered by the currency_id column * @method array findByPrice(double $price) Return ChildProductPrice objects filtered by the price column * @method array findByPromoPrice(double $promo_price) Return ChildProductPrice objects filtered by the promo_price column @@ -155,7 +155,7 @@ abstract class ProductPriceQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, STOCK_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_SALE_ELEMENTS_ID, CURRENCY_ID, PRICE, PROMO_PRICE, CREATED_AT, UPDATED_AT FROM product_price WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -286,18 +286,18 @@ abstract class ProductPriceQuery extends ModelCriteria } /** - * Filter the query on the stock_id column + * Filter the query on the product_sale_elements_id column * * Example usage: * - * $query->filterByStockId(1234); // WHERE stock_id = 1234 - * $query->filterByStockId(array(12, 34)); // WHERE stock_id IN (12, 34) - * $query->filterByStockId(array('min' => 12)); // WHERE stock_id > 12 + * $query->filterByProductSaleElementsId(1234); // WHERE product_sale_elements_id = 1234 + * $query->filterByProductSaleElementsId(array(12, 34)); // WHERE product_sale_elements_id IN (12, 34) + * $query->filterByProductSaleElementsId(array('min' => 12)); // WHERE product_sale_elements_id > 12 * * - * @see filterByStock() + * @see filterByProductSaleElements() * - * @param mixed $stockId The value to use as filter. + * @param mixed $productSaleElementsId 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. @@ -305,16 +305,16 @@ abstract class ProductPriceQuery extends ModelCriteria * * @return ChildProductPriceQuery The current query, for fluid interface */ - public function filterByStockId($stockId = null, $comparison = null) + public function filterByProductSaleElementsId($productSaleElementsId = null, $comparison = null) { - if (is_array($stockId)) { + if (is_array($productSaleElementsId)) { $useMinMax = false; - if (isset($stockId['min'])) { - $this->addUsingAlias(ProductPriceTableMap::STOCK_ID, $stockId['min'], Criteria::GREATER_EQUAL); + if (isset($productSaleElementsId['min'])) { + $this->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($stockId['max'])) { - $this->addUsingAlias(ProductPriceTableMap::STOCK_ID, $stockId['max'], Criteria::LESS_EQUAL); + if (isset($productSaleElementsId['max'])) { + $this->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -325,7 +325,7 @@ abstract class ProductPriceQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPriceTableMap::STOCK_ID, $stockId, $comparison); + return $this->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison); } /** @@ -540,42 +540,42 @@ abstract class ProductPriceQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Stock object + * Filter the query by a related \Thelia\Model\ProductSaleElements object * - * @param \Thelia\Model\Stock|ObjectCollection $stock The related object(s) to use as filter + * @param \Thelia\Model\ProductSaleElements|ObjectCollection $productSaleElements The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductPriceQuery The current query, for fluid interface */ - public function filterByStock($stock, $comparison = null) + public function filterByProductSaleElements($productSaleElements, $comparison = null) { - if ($stock instanceof \Thelia\Model\Stock) { + if ($productSaleElements instanceof \Thelia\Model\ProductSaleElements) { return $this - ->addUsingAlias(ProductPriceTableMap::STOCK_ID, $stock->getId(), $comparison); - } elseif ($stock instanceof ObjectCollection) { + ->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->getId(), $comparison); + } elseif ($productSaleElements instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductPriceTableMap::STOCK_ID, $stock->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElements->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); + throw new PropelException('filterByProductSaleElements() only accepts arguments of type \Thelia\Model\ProductSaleElements or Collection'); } } /** - * Adds a JOIN clause to the query using the Stock relation + * Adds a JOIN clause to the query using the ProductSaleElements relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildProductPriceQuery The current query, for fluid interface */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProductSaleElements($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); + $relationMap = $tableMap->getRelation('ProductSaleElements'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -590,14 +590,14 @@ abstract class ProductPriceQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Stock'); + $this->addJoinObject($join, 'ProductSaleElements'); } return $this; } /** - * Use the Stock relation Stock object + * Use the ProductSaleElements relation ProductSaleElements object * * @see useQuery() * @@ -605,13 +605,13 @@ abstract class ProductPriceQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductSaleElementsQuery A secondary query class using the current class as primary query */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProductSaleElementsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); + ->joinProductSaleElements($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php old mode 100755 new mode 100644 index c337b6357..37371c4b0 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -60,9 +60,9 @@ use Thelia\Model\Map\ProductTableMap; * @method ChildProductQuery rightJoinFeatureProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureProduct relation * @method ChildProductQuery innerJoinFeatureProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureProduct relation * - * @method ChildProductQuery leftJoinStock($relationAlias = null) Adds a LEFT JOIN clause to the query using the Stock relation - * @method ChildProductQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation - * @method ChildProductQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation + * @method ChildProductQuery leftJoinProductSaleElements($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductSaleElements relation + * @method ChildProductQuery rightJoinProductSaleElements($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductSaleElements relation + * @method ChildProductQuery innerJoinProductSaleElements($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductSaleElements relation * * @method ChildProductQuery leftJoinContentAssoc($relationAlias = null) Adds a LEFT JOIN clause to the query using the ContentAssoc relation * @method ChildProductQuery rightJoinContentAssoc($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ContentAssoc relation @@ -924,40 +924,40 @@ abstract class ProductQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Stock object + * Filter the query by a related \Thelia\Model\ProductSaleElements object * - * @param \Thelia\Model\Stock|ObjectCollection $stock the related object to use as filter + * @param \Thelia\Model\ProductSaleElements|ObjectCollection $productSaleElements the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProductQuery The current query, for fluid interface */ - public function filterByStock($stock, $comparison = null) + public function filterByProductSaleElements($productSaleElements, $comparison = null) { - if ($stock instanceof \Thelia\Model\Stock) { + if ($productSaleElements instanceof \Thelia\Model\ProductSaleElements) { return $this - ->addUsingAlias(ProductTableMap::ID, $stock->getProductId(), $comparison); - } elseif ($stock instanceof ObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $productSaleElements->getProductId(), $comparison); + } elseif ($productSaleElements instanceof ObjectCollection) { return $this - ->useStockQuery() - ->filterByPrimaryKeys($stock->getPrimaryKeys()) + ->useProductSaleElementsQuery() + ->filterByPrimaryKeys($productSaleElements->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); + throw new PropelException('filterByProductSaleElements() only accepts arguments of type \Thelia\Model\ProductSaleElements or Collection'); } } /** - * Adds a JOIN clause to the query using the Stock relation + * Adds a JOIN clause to the query using the ProductSaleElements relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildProductQuery The current query, for fluid interface */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProductSaleElements($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); + $relationMap = $tableMap->getRelation('ProductSaleElements'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -972,14 +972,14 @@ abstract class ProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Stock'); + $this->addJoinObject($join, 'ProductSaleElements'); } return $this; } /** - * Use the Stock relation Stock object + * Use the ProductSaleElements relation ProductSaleElements object * * @see useQuery() * @@ -987,13 +987,13 @@ abstract class ProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProductSaleElementsQuery A secondary query class using the current class as primary query */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProductSaleElementsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); + ->joinProductSaleElements($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProductSaleElements', '\Thelia\Model\ProductSaleElementsQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/Stock.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php old mode 100755 new mode 100644 similarity index 88% rename from core/lib/Thelia/Model/Base/Stock.php rename to core/lib/Thelia/Model/Base/ProductSaleElements.php index 001d41a7c..22a8c9752 --- a/core/lib/Thelia/Model/Base/Stock.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -25,16 +25,16 @@ use Thelia\Model\Product as ChildProduct; use Thelia\Model\ProductPrice as ChildProductPrice; use Thelia\Model\ProductPriceQuery as ChildProductPriceQuery; use Thelia\Model\ProductQuery as ChildProductQuery; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; -use Thelia\Model\Map\StockTableMap; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; +use Thelia\Model\Map\ProductSaleElementsTableMap; -abstract class Stock implements ActiveRecordInterface +abstract class ProductSaleElements implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\StockTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\ProductSaleElementsTableMap'; /** @@ -75,12 +75,6 @@ abstract class Stock implements ActiveRecordInterface */ protected $product_id; - /** - * The value for the increase field. - * @var double - */ - protected $increase; - /** * The value for the quantity field. * @var double @@ -181,7 +175,7 @@ abstract class Stock implements ActiveRecordInterface } /** - * Initializes internal state of Thelia\Model\Base\Stock object. + * Initializes internal state of Thelia\Model\Base\ProductSaleElements object. * @see applyDefaults() */ public function __construct() @@ -278,9 +272,9 @@ abstract class Stock implements ActiveRecordInterface } /** - * Compares this with another Stock instance. If - * obj is an instance of Stock, delegates to - * equals(Stock). Otherwise, returns false. + * Compares this with another ProductSaleElements instance. If + * obj is an instance of ProductSaleElements, delegates to + * equals(ProductSaleElements). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -361,7 +355,7 @@ abstract class Stock implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Stock The current object, for fluid interface + * @return ProductSaleElements The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -393,7 +387,7 @@ abstract class Stock implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Stock The current object, for fluid interface + * @return ProductSaleElements The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -458,17 +452,6 @@ abstract class Stock implements ActiveRecordInterface return $this->product_id; } - /** - * Get the [increase] column value. - * - * @return double - */ - public function getIncrease() - { - - return $this->increase; - } - /** * Get the [quantity] column value. * @@ -557,7 +540,7 @@ abstract class Stock implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setId($v) { @@ -567,7 +550,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = StockTableMap::ID; + $this->modifiedColumns[] = ProductSaleElementsTableMap::ID; } @@ -578,7 +561,7 @@ abstract class Stock implements ActiveRecordInterface * Set the value of [product_id] column. * * @param int $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setProductId($v) { @@ -588,7 +571,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = StockTableMap::PRODUCT_ID; + $this->modifiedColumns[] = ProductSaleElementsTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -599,32 +582,11 @@ abstract class Stock implements ActiveRecordInterface return $this; } // setProductId() - /** - * Set the value of [increase] column. - * - * @param double $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) - */ - public function setIncrease($v) - { - if ($v !== null) { - $v = (double) $v; - } - - if ($this->increase !== $v) { - $this->increase = $v; - $this->modifiedColumns[] = StockTableMap::INCREASE; - } - - - return $this; - } // setIncrease() - /** * Set the value of [quantity] column. * * @param double $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setQuantity($v) { @@ -634,7 +596,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->quantity !== $v) { $this->quantity = $v; - $this->modifiedColumns[] = StockTableMap::QUANTITY; + $this->modifiedColumns[] = ProductSaleElementsTableMap::QUANTITY; } @@ -645,7 +607,7 @@ abstract class Stock implements ActiveRecordInterface * Set the value of [promo] column. * * @param int $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setPromo($v) { @@ -655,7 +617,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->promo !== $v) { $this->promo = $v; - $this->modifiedColumns[] = StockTableMap::PROMO; + $this->modifiedColumns[] = ProductSaleElementsTableMap::PROMO; } @@ -666,7 +628,7 @@ abstract class Stock implements ActiveRecordInterface * Set the value of [newness] column. * * @param int $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setNewness($v) { @@ -676,7 +638,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->newness !== $v) { $this->newness = $v; - $this->modifiedColumns[] = StockTableMap::NEWNESS; + $this->modifiedColumns[] = ProductSaleElementsTableMap::NEWNESS; } @@ -687,7 +649,7 @@ abstract class Stock implements ActiveRecordInterface * Set the value of [weight] column. * * @param double $v new value - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setWeight($v) { @@ -697,7 +659,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->weight !== $v) { $this->weight = $v; - $this->modifiedColumns[] = StockTableMap::WEIGHT; + $this->modifiedColumns[] = ProductSaleElementsTableMap::WEIGHT; } @@ -709,7 +671,7 @@ abstract class Stock implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -717,7 +679,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = StockTableMap::CREATED_AT; + $this->modifiedColumns[] = ProductSaleElementsTableMap::CREATED_AT; } } // if either are not null @@ -730,7 +692,7 @@ abstract class Stock implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -738,7 +700,7 @@ abstract class Stock implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = StockTableMap::UPDATED_AT; + $this->modifiedColumns[] = ProductSaleElementsTableMap::UPDATED_AT; } } // if either are not null @@ -791,34 +753,31 @@ abstract class Stock implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : StockTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductSaleElementsTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : StockTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductSaleElementsTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; $this->product_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : StockTableMap::translateFieldName('Increase', TableMap::TYPE_PHPNAME, $indexType)]; - $this->increase = (null !== $col) ? (double) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : StockTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductSaleElementsTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; $this->quantity = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : StockTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductSaleElementsTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; $this->promo = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : StockTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductSaleElementsTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)]; $this->newness = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : StockTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; $this->weight = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : StockTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $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 : StockTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -831,10 +790,10 @@ abstract class Stock implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = StockTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Stock object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e); } } @@ -879,13 +838,13 @@ abstract class Stock implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ProductSaleElementsTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildStockQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildProductSaleElementsQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -911,8 +870,8 @@ abstract class Stock implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Stock::setDeleted() - * @see Stock::isDeleted() + * @see ProductSaleElements::setDeleted() + * @see ProductSaleElements::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -921,12 +880,12 @@ abstract class Stock implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildStockQuery::create() + $deleteQuery = ChildProductSaleElementsQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -963,7 +922,7 @@ abstract class Stock implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -973,16 +932,16 @@ abstract class Stock implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(StockTableMap::CREATED_AT)) { + if (!$this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(StockTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(StockTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -994,7 +953,7 @@ abstract class Stock implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - StockTableMap::addInstanceToPool($this); + ProductSaleElementsTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1118,42 +1077,39 @@ abstract class Stock implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = StockTableMap::ID; + $this->modifiedColumns[] = ProductSaleElementsTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . StockTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductSaleElementsTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(StockTableMap::ID)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(StockTableMap::INCREASE)) { - $modifiedColumns[':p' . $index++] = 'INCREASE'; - } - if ($this->isColumnModified(StockTableMap::QUANTITY)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) { $modifiedColumns[':p' . $index++] = 'QUANTITY'; } - if ($this->isColumnModified(StockTableMap::PROMO)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) { $modifiedColumns[':p' . $index++] = 'PROMO'; } - if ($this->isColumnModified(StockTableMap::NEWNESS)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) { $modifiedColumns[':p' . $index++] = 'NEWNESS'; } - if ($this->isColumnModified(StockTableMap::WEIGHT)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) { $modifiedColumns[':p' . $index++] = 'WEIGHT'; } - if ($this->isColumnModified(StockTableMap::CREATED_AT)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(StockTableMap::UPDATED_AT)) { + if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO stock (%s) VALUES (%s)', + 'INSERT INTO product_sale_elements (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1168,9 +1124,6 @@ abstract class Stock implements ActiveRecordInterface case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case 'INCREASE': - $stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR); - break; case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); break; @@ -1235,7 +1188,7 @@ abstract class Stock implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = StockTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProductSaleElementsTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1258,24 +1211,21 @@ abstract class Stock implements ActiveRecordInterface return $this->getProductId(); break; case 2: - return $this->getIncrease(); - break; - case 3: return $this->getQuantity(); break; - case 4: + case 3: return $this->getPromo(); break; - case 5: + case 4: return $this->getNewness(); break; - case 6: + case 5: return $this->getWeight(); break; - case 7: + case 6: return $this->getCreatedAt(); break; - case 8: + case 7: return $this->getUpdatedAt(); break; default: @@ -1301,21 +1251,20 @@ abstract class Stock implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Stock'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['ProductSaleElements'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Stock'][$this->getPrimaryKey()] = true; - $keys = StockTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['ProductSaleElements'][$this->getPrimaryKey()] = true; + $keys = ProductSaleElementsTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getProductId(), - $keys[2] => $this->getIncrease(), - $keys[3] => $this->getQuantity(), - $keys[4] => $this->getPromo(), - $keys[5] => $this->getNewness(), - $keys[6] => $this->getWeight(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[2] => $this->getQuantity(), + $keys[3] => $this->getPromo(), + $keys[4] => $this->getNewness(), + $keys[5] => $this->getWeight(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1354,7 +1303,7 @@ abstract class Stock implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = StockTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = ProductSaleElementsTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1377,24 +1326,21 @@ abstract class Stock implements ActiveRecordInterface $this->setProductId($value); break; case 2: - $this->setIncrease($value); - break; - case 3: $this->setQuantity($value); break; - case 4: + case 3: $this->setPromo($value); break; - case 5: + case 4: $this->setNewness($value); break; - case 6: + case 5: $this->setWeight($value); break; - case 7: + case 6: $this->setCreatedAt($value); break; - case 8: + case 7: $this->setUpdatedAt($value); break; } // switch() @@ -1419,17 +1365,16 @@ abstract class Stock implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = StockTableMap::getFieldNames($keyType); + $keys = ProductSaleElementsTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setIncrease($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setQuantity($arr[$keys[3]]); - 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[2], $arr)) $this->setQuantity($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPromo($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setNewness($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setWeight($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]]); } /** @@ -1439,17 +1384,16 @@ abstract class Stock implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(StockTableMap::DATABASE_NAME); + $criteria = new Criteria(ProductSaleElementsTableMap::DATABASE_NAME); - if ($this->isColumnModified(StockTableMap::ID)) $criteria->add(StockTableMap::ID, $this->id); - if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) $criteria->add(StockTableMap::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(StockTableMap::INCREASE)) $criteria->add(StockTableMap::INCREASE, $this->increase); - if ($this->isColumnModified(StockTableMap::QUANTITY)) $criteria->add(StockTableMap::QUANTITY, $this->quantity); - if ($this->isColumnModified(StockTableMap::PROMO)) $criteria->add(StockTableMap::PROMO, $this->promo); - if ($this->isColumnModified(StockTableMap::NEWNESS)) $criteria->add(StockTableMap::NEWNESS, $this->newness); - if ($this->isColumnModified(StockTableMap::WEIGHT)) $criteria->add(StockTableMap::WEIGHT, $this->weight); - if ($this->isColumnModified(StockTableMap::CREATED_AT)) $criteria->add(StockTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(StockTableMap::UPDATED_AT)) $criteria->add(StockTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ProductSaleElementsTableMap::ID)) $criteria->add(ProductSaleElementsTableMap::ID, $this->id); + if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) $criteria->add(ProductSaleElementsTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) $criteria->add(ProductSaleElementsTableMap::QUANTITY, $this->quantity); + 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::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1464,8 +1408,8 @@ abstract class Stock implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(StockTableMap::DATABASE_NAME); - $criteria->add(StockTableMap::ID, $this->id); + $criteria = new Criteria(ProductSaleElementsTableMap::DATABASE_NAME); + $criteria->add(ProductSaleElementsTableMap::ID, $this->id); return $criteria; } @@ -1506,7 +1450,7 @@ abstract class Stock implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Stock (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\ProductSaleElements (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1514,7 +1458,6 @@ abstract class Stock implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setProductId($this->getProductId()); - $copyObj->setIncrease($this->getIncrease()); $copyObj->setQuantity($this->getQuantity()); $copyObj->setPromo($this->getPromo()); $copyObj->setNewness($this->getNewness()); @@ -1562,7 +1505,7 @@ abstract class Stock implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Stock Clone of current object. + * @return \Thelia\Model\ProductSaleElements Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1579,7 +1522,7 @@ abstract class Stock implements ActiveRecordInterface * Declares an association between this object and a ChildProduct object. * * @param ChildProduct $v - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) * @throws PropelException */ public function setProduct(ChildProduct $v = null) @@ -1595,7 +1538,7 @@ abstract class Stock implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { - $v->addStock($this); + $v->addProductSaleElements($this); } @@ -1619,7 +1562,7 @@ abstract class Stock implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aProduct->addStocks($this); + $this->aProduct->addProductSaleElementss($this); */ } @@ -1697,7 +1640,7 @@ abstract class Stock implements ActiveRecordInterface * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildStock is new, it will return + * If this ChildProductSaleElements is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria optional Criteria object to narrow the query @@ -1714,7 +1657,7 @@ abstract class Stock implements ActiveRecordInterface $this->initAttributeCombinations(); } else { $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria) - ->filterByStock($this) + ->filterByProductSaleElements($this) ->find($con); if (null !== $criteria) { @@ -1759,7 +1702,7 @@ abstract class Stock implements ActiveRecordInterface * * @param Collection $attributeCombinations A Propel collection. * @param ConnectionInterface $con Optional connection object - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null) { @@ -1772,7 +1715,7 @@ abstract class Stock implements ActiveRecordInterface $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete; foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { - $attributeCombinationRemoved->setStock(null); + $attributeCombinationRemoved->setProductSaleElements(null); } $this->collAttributeCombinations = null; @@ -1813,7 +1756,7 @@ abstract class Stock implements ActiveRecordInterface } return $query - ->filterByStock($this) + ->filterByProductSaleElements($this) ->count($con); } @@ -1825,7 +1768,7 @@ abstract class Stock implements ActiveRecordInterface * through the ChildAttributeCombination foreign key attribute. * * @param ChildAttributeCombination $l ChildAttributeCombination - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function addAttributeCombination(ChildAttributeCombination $l) { @@ -1847,12 +1790,12 @@ abstract class Stock implements ActiveRecordInterface protected function doAddAttributeCombination($attributeCombination) { $this->collAttributeCombinations[]= $attributeCombination; - $attributeCombination->setStock($this); + $attributeCombination->setProductSaleElements($this); } /** * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1863,7 +1806,7 @@ abstract class Stock implements ActiveRecordInterface $this->attributeCombinationsScheduledForDeletion->clear(); } $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; - $attributeCombination->setStock(null); + $attributeCombination->setProductSaleElements(null); } return $this; @@ -1873,13 +1816,13 @@ abstract class Stock implements ActiveRecordInterface /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this Stock is new, it will return - * an empty collection; or if this Stock has previously + * Otherwise if this ProductSaleElements is new, it will return + * an empty collection; or if this ProductSaleElements has previously * been saved, it will retrieve related AttributeCombinations from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in Stock. + * actually need in ProductSaleElements. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object @@ -1898,13 +1841,13 @@ abstract class Stock implements ActiveRecordInterface /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this Stock is new, it will return - * an empty collection; or if this Stock has previously + * Otherwise if this ProductSaleElements is new, it will return + * an empty collection; or if this ProductSaleElements has previously * been saved, it will retrieve related AttributeCombinations from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in Stock. + * actually need in ProductSaleElements. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object @@ -1968,7 +1911,7 @@ abstract class Stock implements ActiveRecordInterface * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildStock is new, it will return + * If this ChildProductSaleElements is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria optional Criteria object to narrow the query @@ -1985,7 +1928,7 @@ abstract class Stock implements ActiveRecordInterface $this->initCartItems(); } else { $collCartItems = ChildCartItemQuery::create(null, $criteria) - ->filterByStock($this) + ->filterByProductSaleElements($this) ->find($con); if (null !== $criteria) { @@ -2030,7 +1973,7 @@ abstract class Stock implements ActiveRecordInterface * * @param Collection $cartItems A Propel collection. * @param ConnectionInterface $con Optional connection object - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function setCartItems(Collection $cartItems, ConnectionInterface $con = null) { @@ -2040,7 +1983,7 @@ abstract class Stock implements ActiveRecordInterface $this->cartItemsScheduledForDeletion = $cartItemsToDelete; foreach ($cartItemsToDelete as $cartItemRemoved) { - $cartItemRemoved->setStock(null); + $cartItemRemoved->setProductSaleElements(null); } $this->collCartItems = null; @@ -2081,7 +2024,7 @@ abstract class Stock implements ActiveRecordInterface } return $query - ->filterByStock($this) + ->filterByProductSaleElements($this) ->count($con); } @@ -2093,7 +2036,7 @@ abstract class Stock implements ActiveRecordInterface * through the ChildCartItem foreign key attribute. * * @param ChildCartItem $l ChildCartItem - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function addCartItem(ChildCartItem $l) { @@ -2115,12 +2058,12 @@ abstract class Stock implements ActiveRecordInterface protected function doAddCartItem($cartItem) { $this->collCartItems[]= $cartItem; - $cartItem->setStock($this); + $cartItem->setProductSaleElements($this); } /** * @param CartItem $cartItem The cartItem object to remove. - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function removeCartItem($cartItem) { @@ -2131,7 +2074,7 @@ abstract class Stock implements ActiveRecordInterface $this->cartItemsScheduledForDeletion->clear(); } $this->cartItemsScheduledForDeletion[]= clone $cartItem; - $cartItem->setStock(null); + $cartItem->setProductSaleElements(null); } return $this; @@ -2141,13 +2084,13 @@ abstract class Stock implements ActiveRecordInterface /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this Stock is new, it will return - * an empty collection; or if this Stock has previously + * Otherwise if this ProductSaleElements is new, it will return + * an empty collection; or if this ProductSaleElements has previously * been saved, it will retrieve related CartItems from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in Stock. + * actually need in ProductSaleElements. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object @@ -2166,13 +2109,13 @@ abstract class Stock implements ActiveRecordInterface /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this Stock is new, it will return - * an empty collection; or if this Stock has previously + * Otherwise if this ProductSaleElements is new, it will return + * an empty collection; or if this ProductSaleElements has previously * been saved, it will retrieve related CartItems from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in Stock. + * actually need in ProductSaleElements. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object @@ -2236,7 +2179,7 @@ abstract class Stock implements ActiveRecordInterface * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildStock is new, it will return + * If this ChildProductSaleElements is new, it will return * an empty collection or the current collection; the criteria is ignored on a new object. * * @param Criteria $criteria optional Criteria object to narrow the query @@ -2253,7 +2196,7 @@ abstract class Stock implements ActiveRecordInterface $this->initProductPrices(); } else { $collProductPrices = ChildProductPriceQuery::create(null, $criteria) - ->filterByStock($this) + ->filterByProductSaleElements($this) ->find($con); if (null !== $criteria) { @@ -2298,7 +2241,7 @@ abstract class Stock implements ActiveRecordInterface * * @param Collection $productPrices A Propel collection. * @param ConnectionInterface $con Optional connection object - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function setProductPrices(Collection $productPrices, ConnectionInterface $con = null) { @@ -2308,7 +2251,7 @@ abstract class Stock implements ActiveRecordInterface $this->productPricesScheduledForDeletion = $productPricesToDelete; foreach ($productPricesToDelete as $productPriceRemoved) { - $productPriceRemoved->setStock(null); + $productPriceRemoved->setProductSaleElements(null); } $this->collProductPrices = null; @@ -2349,7 +2292,7 @@ abstract class Stock implements ActiveRecordInterface } return $query - ->filterByStock($this) + ->filterByProductSaleElements($this) ->count($con); } @@ -2361,7 +2304,7 @@ abstract class Stock implements ActiveRecordInterface * through the ChildProductPrice foreign key attribute. * * @param ChildProductPrice $l ChildProductPrice - * @return \Thelia\Model\Stock The current object (for fluent API support) + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) */ public function addProductPrice(ChildProductPrice $l) { @@ -2383,12 +2326,12 @@ abstract class Stock implements ActiveRecordInterface protected function doAddProductPrice($productPrice) { $this->collProductPrices[]= $productPrice; - $productPrice->setStock($this); + $productPrice->setProductSaleElements($this); } /** * @param ProductPrice $productPrice The productPrice object to remove. - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function removeProductPrice($productPrice) { @@ -2399,7 +2342,7 @@ abstract class Stock implements ActiveRecordInterface $this->productPricesScheduledForDeletion->clear(); } $this->productPricesScheduledForDeletion[]= clone $productPrice; - $productPrice->setStock(null); + $productPrice->setProductSaleElements(null); } return $this; @@ -2409,13 +2352,13 @@ abstract class Stock implements ActiveRecordInterface /** * If this collection has already been initialized with * an identical criteria, it returns the collection. - * Otherwise if this Stock is new, it will return - * an empty collection; or if this Stock has previously + * Otherwise if this ProductSaleElements is new, it will return + * an empty collection; or if this ProductSaleElements has previously * been saved, it will retrieve related ProductPrices from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you - * actually need in Stock. + * actually need in ProductSaleElements. * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object @@ -2437,7 +2380,6 @@ abstract class Stock implements ActiveRecordInterface { $this->id = null; $this->product_id = null; - $this->increase = null; $this->quantity = null; $this->promo = null; $this->newness = null; @@ -2503,7 +2445,7 @@ abstract class Stock implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(StockTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(ProductSaleElementsTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2511,11 +2453,11 @@ abstract class Stock implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildStock The current object (for fluent API support) + * @return ChildProductSaleElements The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = StockTableMap::UPDATED_AT; + $this->modifiedColumns[] = ProductSaleElementsTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/StockQuery.php b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php old mode 100755 new mode 100644 similarity index 67% rename from core/lib/Thelia/Model/Base/StockQuery.php rename to core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php index 94e98e83b..9892bff51 --- a/core/lib/Thelia/Model/Base/StockQuery.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php @@ -12,108 +12,104 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\Stock as ChildStock; -use Thelia\Model\StockQuery as ChildStockQuery; -use Thelia\Model\Map\StockTableMap; +use Thelia\Model\ProductSaleElements as ChildProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery as ChildProductSaleElementsQuery; +use Thelia\Model\Map\ProductSaleElementsTableMap; /** - * Base class that represents a query for the 'stock' table. + * Base class that represents a query for the 'product_sale_elements' table. * * * - * @method ChildStockQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildStockQuery orderByProductId($order = Criteria::ASC) Order by the product_id column - * @method ChildStockQuery orderByIncrease($order = Criteria::ASC) Order by the increase column - * @method ChildStockQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column - * @method ChildStockQuery orderByPromo($order = Criteria::ASC) Order by the promo column - * @method ChildStockQuery orderByNewness($order = Criteria::ASC) Order by the newness column - * @method ChildStockQuery orderByWeight($order = Criteria::ASC) Order by the weight column - * @method ChildStockQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildStockQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildProductSaleElementsQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildProductSaleElementsQuery orderByProductId($order = Criteria::ASC) Order by the product_id column + * @method ChildProductSaleElementsQuery orderByQuantity($order = Criteria::ASC) Order by the quantity 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 orderByWeight($order = Criteria::ASC) Order by the weight 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 ChildStockQuery groupById() Group by the id column - * @method ChildStockQuery groupByProductId() Group by the product_id column - * @method ChildStockQuery groupByIncrease() Group by the increase column - * @method ChildStockQuery groupByQuantity() Group by the quantity column - * @method ChildStockQuery groupByPromo() Group by the promo column - * @method ChildStockQuery groupByNewness() Group by the newness column - * @method ChildStockQuery groupByWeight() Group by the weight column - * @method ChildStockQuery groupByCreatedAt() Group by the created_at column - * @method ChildStockQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildProductSaleElementsQuery groupById() Group by the id column + * @method ChildProductSaleElementsQuery groupByProductId() Group by the product_id column + * @method ChildProductSaleElementsQuery groupByQuantity() Group by the quantity column + * @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 groupByCreatedAt() Group by the created_at column + * @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildStockQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildStockQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildStockQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildProductSaleElementsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildProductSaleElementsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildProductSaleElementsQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildStockQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation - * @method ChildStockQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation - * @method ChildStockQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation + * @method ChildProductSaleElementsQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation + * @method ChildProductSaleElementsQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation + * @method ChildProductSaleElementsQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation * - * @method ChildStockQuery leftJoinAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCombination relation - * @method ChildStockQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation - * @method ChildStockQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation + * @method ChildProductSaleElementsQuery leftJoinAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the AttributeCombination relation + * @method ChildProductSaleElementsQuery rightJoinAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AttributeCombination relation + * @method ChildProductSaleElementsQuery innerJoinAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the AttributeCombination relation * - * @method ChildStockQuery leftJoinCartItem($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartItem relation - * @method ChildStockQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation - * @method ChildStockQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation + * @method ChildProductSaleElementsQuery leftJoinCartItem($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartItem relation + * @method ChildProductSaleElementsQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation + * @method ChildProductSaleElementsQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation * - * @method ChildStockQuery leftJoinProductPrice($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductPrice relation - * @method ChildStockQuery rightJoinProductPrice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductPrice relation - * @method ChildStockQuery innerJoinProductPrice($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductPrice relation + * @method ChildProductSaleElementsQuery leftJoinProductPrice($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductPrice relation + * @method ChildProductSaleElementsQuery rightJoinProductPrice($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductPrice relation + * @method ChildProductSaleElementsQuery innerJoinProductPrice($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductPrice relation * - * @method ChildStock findOne(ConnectionInterface $con = null) Return the first ChildStock matching the query - * @method ChildStock findOneOrCreate(ConnectionInterface $con = null) Return the first ChildStock matching the query, or a new ChildStock object populated from the query conditions when no match is found + * @method ChildProductSaleElements findOne(ConnectionInterface $con = null) Return the first ChildProductSaleElements matching the query + * @method ChildProductSaleElements findOneOrCreate(ConnectionInterface $con = null) Return the first ChildProductSaleElements matching the query, or a new ChildProductSaleElements object populated from the query conditions when no match is found * - * @method ChildStock findOneById(int $id) Return the first ChildStock filtered by the id column - * @method ChildStock findOneByProductId(int $product_id) Return the first ChildStock filtered by the product_id column - * @method ChildStock findOneByIncrease(double $increase) Return the first ChildStock filtered by the increase column - * @method ChildStock findOneByQuantity(double $quantity) Return the first ChildStock filtered by the quantity column - * @method ChildStock findOneByPromo(int $promo) Return the first ChildStock filtered by the promo column - * @method ChildStock findOneByNewness(int $newness) Return the first ChildStock filtered by the newness column - * @method ChildStock findOneByWeight(double $weight) Return the first ChildStock filtered by the weight column - * @method ChildStock findOneByCreatedAt(string $created_at) Return the first ChildStock filtered by the created_at column - * @method ChildStock findOneByUpdatedAt(string $updated_at) Return the first ChildStock filtered by the updated_at column + * @method ChildProductSaleElements findOneById(int $id) Return the first ChildProductSaleElements filtered by the id column + * @method ChildProductSaleElements findOneByProductId(int $product_id) Return the first ChildProductSaleElements filtered by the product_id column + * @method ChildProductSaleElements findOneByQuantity(double $quantity) Return the first ChildProductSaleElements filtered by the quantity 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 findOneByWeight(double $weight) Return the first ChildProductSaleElements filtered by the weight 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 array findById(int $id) Return ChildStock objects filtered by the id column - * @method array findByProductId(int $product_id) Return ChildStock objects filtered by the product_id column - * @method array findByIncrease(double $increase) Return ChildStock objects filtered by the increase column - * @method array findByQuantity(double $quantity) Return ChildStock objects filtered by the quantity column - * @method array findByPromo(int $promo) Return ChildStock objects filtered by the promo column - * @method array findByNewness(int $newness) Return ChildStock objects filtered by the newness column - * @method array findByWeight(double $weight) Return ChildStock objects filtered by the weight column - * @method array findByCreatedAt(string $created_at) Return ChildStock objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildStock objects filtered by the updated_at column + * @method array findById(int $id) Return ChildProductSaleElements objects filtered by the id column + * @method array findByProductId(int $product_id) Return ChildProductSaleElements objects filtered by the product_id column + * @method array findByQuantity(double $quantity) Return ChildProductSaleElements objects filtered by the quantity 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 findByWeight(double $weight) Return ChildProductSaleElements objects filtered by the weight 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 * */ -abstract class StockQuery extends ModelCriteria +abstract class ProductSaleElementsQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\StockQuery object. + * Initializes internal state of \Thelia\Model\Base\ProductSaleElementsQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\Stock', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\ProductSaleElements', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildStockQuery object. + * Returns a new ChildProductSaleElementsQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildStockQuery + * @return ChildProductSaleElementsQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\StockQuery) { + if ($criteria instanceof \Thelia\Model\ProductSaleElementsQuery) { return $criteria; } - $query = new \Thelia\Model\StockQuery(); + $query = new \Thelia\Model\ProductSaleElementsQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -136,19 +132,19 @@ abstract class StockQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildStock|array|mixed the result, formatted by the current formatter + * @return ChildProductSaleElements|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = StockTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = ProductSaleElementsTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(ProductSaleElementsTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -167,11 +163,11 @@ abstract class StockQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildStock A model object, or null if the key is not found + * @return ChildProductSaleElements A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, INCREASE, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM stock WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -182,9 +178,9 @@ abstract class StockQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildStock(); + $obj = new ChildProductSaleElements(); $obj->hydrate($row); - StockTableMap::addInstanceToPool($obj, (string) $key); + ProductSaleElementsTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -197,7 +193,7 @@ abstract class StockQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildStock|array|mixed the result, formatted by the current formatter + * @return ChildProductSaleElements|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -239,12 +235,12 @@ abstract class StockQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(StockTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ProductSaleElementsTableMap::ID, $key, Criteria::EQUAL); } /** @@ -252,12 +248,12 @@ abstract class StockQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(StockTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ProductSaleElementsTableMap::ID, $keys, Criteria::IN); } /** @@ -276,18 +272,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(StockTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(StockTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -298,7 +294,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::ID, $id, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::ID, $id, $comparison); } /** @@ -319,18 +315,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByProductId($productId = null, $comparison = null) { if (is_array($productId)) { $useMinMax = false; if (isset($productId['min'])) { - $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -341,48 +337,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the increase column - * - * Example usage: - * - * $query->filterByIncrease(1234); // WHERE increase = 1234 - * $query->filterByIncrease(array(12, 34)); // WHERE increase IN (12, 34) - * $query->filterByIncrease(array('min' => 12)); // WHERE increase > 12 - * - * - * @param mixed $increase 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 ChildStockQuery The current query, for fluid interface - */ - public function filterByIncrease($increase = null, $comparison = null) - { - if (is_array($increase)) { - $useMinMax = false; - if (isset($increase['min'])) { - $this->addUsingAlias(StockTableMap::INCREASE, $increase['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($increase['max'])) { - $this->addUsingAlias(StockTableMap::INCREASE, $increase['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockTableMap::INCREASE, $increase, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -401,18 +356,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByQuantity($quantity = null, $comparison = null) { if (is_array($quantity)) { $useMinMax = false; if (isset($quantity['min'])) { - $this->addUsingAlias(StockTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($quantity['max'])) { - $this->addUsingAlias(StockTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -423,7 +378,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::QUANTITY, $quantity, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::QUANTITY, $quantity, $comparison); } /** @@ -442,18 +397,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByPromo($promo = null, $comparison = null) { if (is_array($promo)) { $useMinMax = false; if (isset($promo['min'])) { - $this->addUsingAlias(StockTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($promo['max'])) { - $this->addUsingAlias(StockTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -464,7 +419,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::PROMO, $promo, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::PROMO, $promo, $comparison); } /** @@ -483,18 +438,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByNewness($newness = null, $comparison = null) { if (is_array($newness)) { $useMinMax = false; if (isset($newness['min'])) { - $this->addUsingAlias(StockTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($newness['max'])) { - $this->addUsingAlias(StockTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -505,7 +460,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::NEWNESS, $newness, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::NEWNESS, $newness, $comparison); } /** @@ -524,18 +479,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByWeight($weight = null, $comparison = null) { if (is_array($weight)) { $useMinMax = false; if (isset($weight['min'])) { - $this->addUsingAlias(StockTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($weight['max'])) { - $this->addUsingAlias(StockTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -546,7 +501,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::WEIGHT, $weight, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison); } /** @@ -567,18 +522,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByCreatedAt($createdAt = null, $comparison = null) { if (is_array($createdAt)) { $useMinMax = false; if (isset($createdAt['min'])) { - $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -589,7 +544,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -610,18 +565,18 @@ abstract class StockQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { if (is_array($updatedAt)) { $useMinMax = false; if (isset($updatedAt['min'])) { - $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductSaleElementsTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -632,7 +587,7 @@ abstract class StockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ProductSaleElementsTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -641,20 +596,20 @@ abstract class StockQuery extends ModelCriteria * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->getId(), $comparison); + ->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $product->getId(), $comparison); } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } @@ -666,7 +621,7 @@ abstract class StockQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -716,13 +671,13 @@ abstract class StockQuery extends ModelCriteria * @param \Thelia\Model\AttributeCombination|ObjectCollection $attributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) { return $this - ->addUsingAlias(StockTableMap::ID, $attributeCombination->getStockId(), $comparison); + ->addUsingAlias(ProductSaleElementsTableMap::ID, $attributeCombination->getProductSaleElementsId(), $comparison); } elseif ($attributeCombination instanceof ObjectCollection) { return $this ->useAttributeCombinationQuery() @@ -739,7 +694,7 @@ abstract class StockQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -789,13 +744,13 @@ abstract class StockQuery extends ModelCriteria * @param \Thelia\Model\CartItem|ObjectCollection $cartItem the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByCartItem($cartItem, $comparison = null) { if ($cartItem instanceof \Thelia\Model\CartItem) { return $this - ->addUsingAlias(StockTableMap::ID, $cartItem->getStockId(), $comparison); + ->addUsingAlias(ProductSaleElementsTableMap::ID, $cartItem->getProductSaleElementsId(), $comparison); } elseif ($cartItem instanceof ObjectCollection) { return $this ->useCartItemQuery() @@ -812,7 +767,7 @@ abstract class StockQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function joinCartItem($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -862,13 +817,13 @@ abstract class StockQuery extends ModelCriteria * @param \Thelia\Model\ProductPrice|ObjectCollection $productPrice the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function filterByProductPrice($productPrice, $comparison = null) { if ($productPrice instanceof \Thelia\Model\ProductPrice) { return $this - ->addUsingAlias(StockTableMap::ID, $productPrice->getStockId(), $comparison); + ->addUsingAlias(ProductSaleElementsTableMap::ID, $productPrice->getProductSaleElementsId(), $comparison); } elseif ($productPrice instanceof ObjectCollection) { return $this ->useProductPriceQuery() @@ -885,7 +840,7 @@ abstract class StockQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function joinProductPrice($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -932,21 +887,21 @@ abstract class StockQuery extends ModelCriteria /** * Exclude object from result * - * @param ChildStock $stock Object to remove from the list of results + * @param ChildProductSaleElements $productSaleElements Object to remove from the list of results * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ - public function prune($stock = null) + public function prune($productSaleElements = null) { - if ($stock) { - $this->addUsingAlias(StockTableMap::ID, $stock->getId(), Criteria::NOT_EQUAL); + if ($productSaleElements) { + $this->addUsingAlias(ProductSaleElementsTableMap::ID, $productSaleElements->getId(), Criteria::NOT_EQUAL); } return $this; } /** - * Deletes all rows from the stock table. + * Deletes all rows from the product_sale_elements table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -954,7 +909,7 @@ abstract class StockQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -965,8 +920,8 @@ abstract class StockQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - StockTableMap::clearInstancePool(); - StockTableMap::clearRelatedInstancePool(); + ProductSaleElementsTableMap::clearInstancePool(); + ProductSaleElementsTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -978,9 +933,9 @@ abstract class StockQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildStock or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildProductSaleElements or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildStock object or primary key or array of primary keys + * @param mixed $values Criteria or ChildProductSaleElements object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -991,13 +946,13 @@ abstract class StockQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(StockTableMap::DATABASE_NAME); + $criteria->setDbName(ProductSaleElementsTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -1007,10 +962,10 @@ abstract class StockQuery extends ModelCriteria $con->beginTransaction(); - StockTableMap::removeInstanceFromPool($criteria); + ProductSaleElementsTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - StockTableMap::clearRelatedInstancePool(); + ProductSaleElementsTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -1027,11 +982,11 @@ abstract class StockQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(StockTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(ProductSaleElementsTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1039,51 +994,51 @@ abstract class StockQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(StockTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(ProductSaleElementsTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(StockTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(ProductSaleElementsTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(StockTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(ProductSaleElementsTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(StockTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(ProductSaleElementsTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildStockQuery The current query, for fluid interface + * @return ChildProductSaleElementsQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(StockTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(ProductSaleElementsTableMap::CREATED_AT); } -} // StockQuery +} // ProductSaleElementsQuery diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ProductVersionQuery.php b/core/lib/Thelia/Model/Base/ProductVersionQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ResourceI18nQuery.php b/core/lib/Thelia/Model/Base/ResourceI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Rewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/RewritingQuery.php b/core/lib/Thelia/Model/Base/RewritingQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxI18nQuery.php b/core/lib/Thelia/Model/Base/TaxI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php b/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index cf9b083c5..8d74c6f20 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -2,11 +2,20 @@ namespace Thelia\Model; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Model\Base\Cart as BaseCart; +use Thelia\Model\Base\ProductSaleElementsQuery; class Cart extends BaseCart { + protected $dispatcher; + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + public function duplicate($token, Customer $customer = null) { $cartItems = $this->getCartItems(); @@ -15,22 +24,35 @@ class Cart extends BaseCart $cart->setAddressDeliveryId($this->getAddressDeliveryId()); $cart->setAddressInvoiceId($this->getAddressInvoiceId()); $cart->setToken($token); + // TODO : set current Currency + $cart->setCurrencyId($this->getCurrencyId()); if ($customer){ $cart->setCustomer($customer); } - // TODO : set current Currency - //$cart->setCurrency() + $cart->save(); foreach ($cartItems as $cartItem){ - $item = new CartItem(); - $item->setCart($cart); - $item->setProductId($cartItem->getProductId()); - $item->setQuantity($cartItem->getQuantity()); - $item->save(); + + $product = $cartItem->getProduct(); + $productSaleElements = $cartItem->getProductSaleElements(); + if ($product && $productSaleElements && $product->getVisible() == 1 && $productSaleElements->getQuantity() > $cartItem->getQuantity()) { + + $item = new CartItem(); + $item->setCart($cart); + $item->setProductId($cartItem->getProductId()); + $item->setQuantity($cartItem->getQuantity()); + $item->save(); + } + } return $cart; } + + protected function dispatchEvent($name) + { + + } } diff --git a/core/lib/Thelia/Model/Combination.php b/core/lib/Thelia/Model/Combination.php deleted file mode 100755 index 8dc338e44..000000000 --- a/core/lib/Thelia/Model/Combination.php +++ /dev/null @@ -1,9 +0,0 @@ - array('AttributeId', 'AttributeAvId', 'StockId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('attributeId', 'attributeAvId', 'stockId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID, AttributeCombinationTableMap::ATTRIBUTE_AV_ID, AttributeCombinationTableMap::STOCK_ID, AttributeCombinationTableMap::CREATED_AT, AttributeCombinationTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID', 'ATTRIBUTE_AV_ID', 'STOCK_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('attribute_id', 'attribute_av_id', 'stock_id', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('AttributeId', 'AttributeAvId', 'ProductSaleElementsId', '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::CREATED_AT, AttributeCombinationTableMap::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', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class AttributeCombinationTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('AttributeId' => 0, 'AttributeAvId' => 1, 'StockId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('attributeId' => 0, 'attributeAvId' => 1, 'stockId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AttributeCombinationTableMap::ATTRIBUTE_ID => 0, AttributeCombinationTableMap::ATTRIBUTE_AV_ID => 1, AttributeCombinationTableMap::STOCK_ID => 2, AttributeCombinationTableMap::CREATED_AT => 3, AttributeCombinationTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ATTRIBUTE_ID' => 0, 'ATTRIBUTE_AV_ID' => 1, 'STOCK_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('attribute_id' => 0, 'attribute_av_id' => 1, 'stock_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('AttributeId' => 0, 'AttributeAvId' => 1, 'ProductSaleElementsId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + 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::CREATED_AT => 3, AttributeCombinationTableMap::UPDATED_AT => 4, ), + 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, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -147,7 +147,7 @@ class AttributeCombinationTableMap extends TableMap // columns $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('STOCK_ID', 'StockId', 'INTEGER' , 'stock', 'ID', true, null, null); + $this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -159,7 +159,7 @@ class AttributeCombinationTableMap extends TableMap { $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::MANY_TO_ONE, array('stock_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); } // buildRelations() /** @@ -190,7 +190,7 @@ class AttributeCombinationTableMap extends TableMap { if (Propel::isInstancePoolingEnabled()) { if (null === $key) { - $key = serialize(array((string) $obj->getAttributeId(), (string) $obj->getAttributeAvId(), (string) $obj->getStockId())); + $key = serialize(array((string) $obj->getAttributeId(), (string) $obj->getAttributeAvId(), (string) $obj->getProductSaleElementsId())); } // if key === null self::$instances[$key] = $obj; } @@ -210,7 +210,7 @@ class AttributeCombinationTableMap extends TableMap { if (Propel::isInstancePoolingEnabled() && null !== $value) { if (is_object($value) && $value instanceof \Thelia\Model\AttributeCombination) { - $key = serialize(array((string) $value->getAttributeId(), (string) $value->getAttributeAvId(), (string) $value->getStockId())); + $key = serialize(array((string) $value->getAttributeId(), (string) $value->getAttributeAvId(), (string) $value->getProductSaleElementsId())); } elseif (is_array($value) && count($value) === 3) { // assume we've been passed a primary key"; @@ -242,11 +242,11 @@ class AttributeCombinationTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('StockId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('StockId', TableMap::TYPE_PHPNAME, $indexType)])); + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ProductSaleElementsId', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -364,13 +364,13 @@ class AttributeCombinationTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_ID); $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_AV_ID); - $criteria->addSelectColumn(AttributeCombinationTableMap::STOCK_ID); + $criteria->addSelectColumn(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(AttributeCombinationTableMap::CREATED_AT); $criteria->addSelectColumn(AttributeCombinationTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID'); - $criteria->addSelectColumn($alias . '.STOCK_ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -433,7 +433,7 @@ class AttributeCombinationTableMap extends TableMap foreach ($values as $value) { $criterion = $criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::STOCK_ID, $value[2])); + $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, $value[2])); $criteria->addOr($criterion); } } diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CartItemTableMap.php b/core/lib/Thelia/Model/Map/CartItemTableMap.php index ae1bd590b..49335f9ec 100644 --- a/core/lib/Thelia/Model/Map/CartItemTableMap.php +++ b/core/lib/Thelia/Model/Map/CartItemTableMap.php @@ -90,9 +90,9 @@ class CartItemTableMap extends TableMap const QUANTITY = 'cart_item.QUANTITY'; /** - * the column name for the STOCK_ID field + * the column name for the PRODUCT_SALE_ELEMENTS_ID field */ - const STOCK_ID = 'cart_item.STOCK_ID'; + const PRODUCT_SALE_ELEMENTS_ID = 'cart_item.PRODUCT_SALE_ELEMENTS_ID'; /** * the column name for the CREATED_AT field @@ -116,11 +116,11 @@ class CartItemTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'StockId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'stockId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::STOCK_ID, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'STOCK_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'stock_id', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); @@ -131,11 +131,11 @@ class CartItemTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'StockId' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'stockId' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::STOCK_ID => 4, CartItemTableMap::CREATED_AT => 5, CartItemTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'STOCK_ID' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'stock_id' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::CREATED_AT => 5, CartItemTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'created_at' => 5, 'updated_at' => 6, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); @@ -159,7 +159,7 @@ class CartItemTableMap extends TableMap $this->addForeignKey('CART_ID', 'CartId', 'INTEGER', 'cart', 'ID', true, null, null); $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', false, null, 1); - $this->addForeignKey('STOCK_ID', 'StockId', 'INTEGER', 'stock', 'ID', true, null, null); + $this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -171,7 +171,7 @@ class CartItemTableMap extends TableMap { $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::MANY_TO_ONE, array('cart_id' => 'id', ), null, null); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), null, null); - $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::MANY_TO_ONE, array('stock_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); } // buildRelations() /** @@ -329,7 +329,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn(CartItemTableMap::CART_ID); $criteria->addSelectColumn(CartItemTableMap::PRODUCT_ID); $criteria->addSelectColumn(CartItemTableMap::QUANTITY); - $criteria->addSelectColumn(CartItemTableMap::STOCK_ID); + $criteria->addSelectColumn(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(CartItemTableMap::CREATED_AT); $criteria->addSelectColumn(CartItemTableMap::UPDATED_AT); } else { @@ -337,7 +337,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn($alias . '.CART_ID'); $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.QUANTITY'); - $criteria->addSelectColumn($alias . '.STOCK_ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ContentAssocTableMap.php b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ContentVersionTableMap.php b/core/lib/Thelia/Model/Map/ContentVersionTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CouponRuleTableMap.php b/core/lib/Thelia/Model/Map/CouponRuleTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CombinationTableMap.php b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/Map/CombinationTableMap.php rename to core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php index 7134c5eaf..c7e4725c1 --- a/core/lib/Thelia/Model/Map/CombinationTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyI18nTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Combination; -use Thelia\Model\CombinationQuery; +use Thelia\Model\CurrencyI18n; +use Thelia\Model\CurrencyI18nQuery; /** - * This class defines the structure of the 'combination' table. + * This class defines the structure of the 'currency_i18n' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\CombinationQuery; * (i.e. if it's a text column type). * */ -class CombinationTableMap extends TableMap +class CurrencyI18nTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.CombinationTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.CurrencyI18nTableMap'; /** * The default database name for this class @@ -42,22 +42,22 @@ class CombinationTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'combination'; + const TABLE_NAME = 'currency_i18n'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Combination'; + const OM_CLASS = '\\Thelia\\Model\\CurrencyI18n'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Combination'; + const CLASS_DEFAULT = 'Thelia.Model.CurrencyI18n'; /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 3; /** * The number of lazy-loaded columns @@ -67,27 +67,22 @@ class CombinationTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 3; /** * the column name for the ID field */ - const ID = 'combination.ID'; + const ID = 'currency_i18n.ID'; /** - * the column name for the REF field + * the column name for the LOCALE field */ - const REF = 'combination.REF'; + const LOCALE = 'currency_i18n.LOCALE'; /** - * the column name for the CREATED_AT field + * the column name for the NAME field */ - const CREATED_AT = 'combination.CREATED_AT'; - - /** - * the column name for the UPDATED_AT field - */ - const UPDATED_AT = 'combination.UPDATED_AT'; + const NAME = 'currency_i18n.NAME'; /** * The default string format for model objects of the related table @@ -101,12 +96,12 @@ class CombinationTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CombinationTableMap::ID, CombinationTableMap::REF, CombinationTableMap::CREATED_AT, CombinationTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('Id', 'Locale', 'Name', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'name', ), + self::TYPE_COLNAME => array(CurrencyI18nTableMap::ID, CurrencyI18nTableMap::LOCALE, CurrencyI18nTableMap::NAME, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'NAME', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'name', ), + self::TYPE_NUM => array(0, 1, 2, ) ); /** @@ -116,12 +111,12 @@ class CombinationTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(CombinationTableMap::ID => 0, CombinationTableMap::REF => 1, CombinationTableMap::CREATED_AT => 2, CombinationTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Name' => 2, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'name' => 2, ), + self::TYPE_COLNAME => array(CurrencyI18nTableMap::ID => 0, CurrencyI18nTableMap::LOCALE => 1, CurrencyI18nTableMap::NAME => 2, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'NAME' => 2, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'name' => 2, ), + self::TYPE_NUM => array(0, 1, 2, ) ); /** @@ -134,16 +129,15 @@ class CombinationTableMap extends TableMap public function initialize() { // attributes - $this->setName('combination'); - $this->setPhpName('Combination'); - $this->setClassName('\\Thelia\\Model\\Combination'); + $this->setName('currency_i18n'); + $this->setPhpName('CurrencyI18n'); + $this->setClassName('\\Thelia\\Model\\CurrencyI18n'); $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); + $this->setUseIdGenerator(false); // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'currency', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null); } // initialize() /** @@ -151,34 +145,62 @@ class CombinationTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); - $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT', 'Stocks'); - $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), null, null, 'CartItems'); + $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); } // buildRelations() /** + * Adds an object to the instance pool. * - * Gets the list of behaviors registered for this table + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. * - * @return array Associative array (name => parameters) of behaviors + * @param \Thelia\Model\CurrencyI18n $obj A \Thelia\Model\CurrencyI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ - public function getBehaviors() + public static function addInstanceToPool($obj, $key = null) { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + /** - * Method to invalidate the instance pool of all tables related to combination * by a foreign key with ON DELETE CASCADE + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\CurrencyI18n object or a primary key value. */ - public static function clearRelatedInstancePool() + public static function removeInstanceFromPool($value) { - // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCombinationTableMap::clearInstancePool(); - StockTableMap::clearInstancePool(); + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\CurrencyI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CurrencyI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; } + unset(self::$instances[$key]); + } + } + /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. * @@ -193,11 +215,11 @@ class CombinationTableMap extends TableMap public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -215,11 +237,7 @@ class CombinationTableMap extends TableMap public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; + return $pks; } /** @@ -235,7 +253,7 @@ class CombinationTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? CombinationTableMap::CLASS_DEFAULT : CombinationTableMap::OM_CLASS; + return $withPrefix ? CurrencyI18nTableMap::CLASS_DEFAULT : CurrencyI18nTableMap::OM_CLASS; } /** @@ -249,21 +267,21 @@ class CombinationTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Combination object, last column rank) + * @return array (CurrencyI18n object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = CombinationTableMap::getInstanceFromPool($key))) { + $key = CurrencyI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CurrencyI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + CombinationTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + CurrencyI18nTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = CombinationTableMap::OM_CLASS; + $cls = CurrencyI18nTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - CombinationTableMap::addInstanceToPool($obj, $key); + CurrencyI18nTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -286,8 +304,8 @@ class CombinationTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = CombinationTableMap::getInstanceFromPool($key))) { + $key = CurrencyI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CurrencyI18nTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -296,7 +314,7 @@ class CombinationTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - CombinationTableMap::addInstanceToPool($obj, $key); + CurrencyI18nTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -317,15 +335,13 @@ class CombinationTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(CombinationTableMap::ID); - $criteria->addSelectColumn(CombinationTableMap::REF); - $criteria->addSelectColumn(CombinationTableMap::CREATED_AT); - $criteria->addSelectColumn(CombinationTableMap::UPDATED_AT); + $criteria->addSelectColumn(CurrencyI18nTableMap::ID); + $criteria->addSelectColumn(CurrencyI18nTableMap::LOCALE); + $criteria->addSelectColumn(CurrencyI18nTableMap::NAME); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.REF'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.NAME'); } } @@ -338,7 +354,7 @@ class CombinationTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME)->getTable(CombinationTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(CurrencyI18nTableMap::DATABASE_NAME)->getTable(CurrencyI18nTableMap::TABLE_NAME); } /** @@ -346,16 +362,16 @@ class CombinationTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(CombinationTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new CombinationTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CurrencyI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CurrencyI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CurrencyI18nTableMap()); } } /** - * Performs a DELETE on the database, given a Combination or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a CurrencyI18n or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Combination object or primary key or array of primary keys + * @param mixed $values Criteria or CurrencyI18n object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -366,25 +382,35 @@ class CombinationTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Combination) { // it's a model object + } elseif ($values instanceof \Thelia\Model\CurrencyI18n) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CombinationTableMap::DATABASE_NAME); - $criteria->add(CombinationTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(CurrencyI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(CurrencyI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CurrencyI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } } - $query = CombinationQuery::create()->mergeWith($criteria); + $query = CurrencyI18nQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { CombinationTableMap::clearInstancePool(); + if ($values instanceof Criteria) { CurrencyI18nTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { CombinationTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { CurrencyI18nTableMap::removeInstanceFromPool($singleval); } } @@ -392,20 +418,20 @@ class CombinationTableMap extends TableMap } /** - * Deletes all rows from the combination table. + * Deletes all rows from the currency_i18n table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return CombinationQuery::create()->doDeleteAll($con); + return CurrencyI18nQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Combination or Criteria object. + * Performs an INSERT on the database, given a CurrencyI18n or Criteria object. * - * @param mixed $criteria Criteria or Combination object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or CurrencyI18n object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -414,22 +440,18 @@ class CombinationTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyI18nTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Combination object - } - - if ($criteria->containsKey(CombinationTableMap::ID) && $criteria->keyContainsValue(CombinationTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CombinationTableMap::ID.')'); + $criteria = $criteria->buildCriteria(); // build Criteria from CurrencyI18n object } // Set the correct dbName - $query = CombinationQuery::create()->mergeWith($criteria); + $query = CurrencyI18nQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -445,7 +467,7 @@ class CombinationTableMap extends TableMap return $pk; } -} // CombinationTableMap +} // CurrencyI18nTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -CombinationTableMap::buildTableMap(); +CurrencyI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php old mode 100755 new mode 100644 index f3b6e5a27..c9a707d9a --- a/core/lib/Thelia/Model/Map/CurrencyTableMap.php +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -57,7 +57,7 @@ class CurrencyTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 8; + const NUM_COLUMNS = 7; /** * The number of lazy-loaded columns @@ -67,18 +67,13 @@ class CurrencyTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 8; + const NUM_HYDRATE_COLUMNS = 7; /** * the column name for the ID field */ const ID = 'currency.ID'; - /** - * the column name for the NAME field - */ - const NAME = 'currency.NAME'; - /** * the column name for the CODE field */ @@ -114,6 +109,15 @@ class CurrencyTableMap extends TableMap */ const DEFAULT_STRING_FORMAT = 'YAML'; + // i18n behavior + + /** + * The default locale to use for translations. + * + * @var string + */ + const DEFAULT_LOCALE = 'en_US'; + /** * holds an array of fieldnames * @@ -121,12 +125,12 @@ class CurrencyTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Name', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'name', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::NAME, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'name', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + self::TYPE_PHPNAME => array('Id', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -136,12 +140,12 @@ class CurrencyTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::NAME => 1, CurrencyTableMap::CODE => 2, CurrencyTableMap::SYMBOL => 3, CurrencyTableMap::RATE => 4, CurrencyTableMap::BY_DEFAULT => 5, CurrencyTableMap::CREATED_AT => 6, CurrencyTableMap::UPDATED_AT => 7, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Symbol' => 2, 'Rate' => 3, 'ByDefault' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'byDefault' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::CODE => 1, CurrencyTableMap::SYMBOL => 2, CurrencyTableMap::RATE => 3, CurrencyTableMap::BY_DEFAULT => 4, CurrencyTableMap::CREATED_AT => 5, CurrencyTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'SYMBOL' => 2, 'RATE' => 3, 'BY_DEFAULT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'symbol' => 2, 'rate' => 3, 'by_default' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -161,7 +165,6 @@ class CurrencyTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null); $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null); $this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null); $this->addColumn('RATE', 'Rate', 'FLOAT', false, null, null); @@ -178,6 +181,7 @@ class CurrencyTableMap extends TableMap $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); $this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'Carts'); $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'ProductPrices'); + $this->addRelation('CurrencyI18n', '\\Thelia\\Model\\CurrencyI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CurrencyI18ns'); } // buildRelations() /** @@ -190,6 +194,7 @@ class CurrencyTableMap extends TableMap { return array( 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'name', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), ); } // getBehaviors() /** @@ -200,6 +205,7 @@ class CurrencyTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. OrderTableMap::clearInstancePool(); + CurrencyI18nTableMap::clearInstancePool(); } /** @@ -341,7 +347,6 @@ class CurrencyTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(CurrencyTableMap::ID); - $criteria->addSelectColumn(CurrencyTableMap::NAME); $criteria->addSelectColumn(CurrencyTableMap::CODE); $criteria->addSelectColumn(CurrencyTableMap::SYMBOL); $criteria->addSelectColumn(CurrencyTableMap::RATE); @@ -350,7 +355,6 @@ class CurrencyTableMap extends TableMap $criteria->addSelectColumn(CurrencyTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.NAME'); $criteria->addSelectColumn($alias . '.CODE'); $criteria->addSelectColumn($alias . '.SYMBOL'); $criteria->addSelectColumn($alias . '.RATE'); diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php b/core/lib/Thelia/Model/Map/DelivzoneTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/DocumentTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/FolderVersionTableMap.php b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/GroupModuleTableMap.php b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/GroupResourceTableMap.php b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ImageTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/MessageVersionTableMap.php b/core/lib/Thelia/Model/Map/MessageVersionTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php index d04c44f22..2b231321b 100644 --- a/core/lib/Thelia/Model/Map/ProductPriceTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductPriceTableMap.php @@ -75,9 +75,9 @@ class ProductPriceTableMap extends TableMap const ID = 'product_price.ID'; /** - * the column name for the STOCK_ID field + * the column name for the PRODUCT_SALE_ELEMENTS_ID field */ - const STOCK_ID = 'product_price.STOCK_ID'; + const PRODUCT_SALE_ELEMENTS_ID = 'product_price.PRODUCT_SALE_ELEMENTS_ID'; /** * the column name for the CURRENCY_ID field @@ -116,11 +116,11 @@ class ProductPriceTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'StockId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'stockId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductPriceTableMap::ID, ProductPriceTableMap::STOCK_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'STOCK_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'stock_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'ProductSaleElementsId', 'CurrencyId', 'Price', 'PromoPrice', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productSaleElementsId', 'currencyId', 'price', 'promoPrice', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductPriceTableMap::ID, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductPriceTableMap::CURRENCY_ID, ProductPriceTableMap::PRICE, ProductPriceTableMap::PROMO_PRICE, ProductPriceTableMap::CREATED_AT, ProductPriceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_SALE_ELEMENTS_ID', 'CURRENCY_ID', 'PRICE', 'PROMO_PRICE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_sale_elements_id', 'currency_id', 'price', 'promo_price', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); @@ -131,11 +131,11 @@ class ProductPriceTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'StockId' => 1, 'CurrencyId' => 2, 'Price' => 3, 'PromoPrice' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'stockId' => 1, 'currencyId' => 2, 'price' => 3, 'promoPrice' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(ProductPriceTableMap::ID => 0, ProductPriceTableMap::STOCK_ID => 1, ProductPriceTableMap::CURRENCY_ID => 2, ProductPriceTableMap::PRICE => 3, ProductPriceTableMap::PROMO_PRICE => 4, ProductPriceTableMap::CREATED_AT => 5, ProductPriceTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'STOCK_ID' => 1, 'CURRENCY_ID' => 2, 'PRICE' => 3, 'PROMO_PRICE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'stock_id' => 1, 'currency_id' => 2, 'price' => 3, 'promo_price' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_PHPNAME => array('Id' => 0, 'ProductSaleElementsId' => 1, 'CurrencyId' => 2, 'Price' => 3, 'PromoPrice' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productSaleElementsId' => 1, 'currencyId' => 2, 'price' => 3, 'promoPrice' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(ProductPriceTableMap::ID => 0, ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID => 1, ProductPriceTableMap::CURRENCY_ID => 2, ProductPriceTableMap::PRICE => 3, ProductPriceTableMap::PROMO_PRICE => 4, ProductPriceTableMap::CREATED_AT => 5, ProductPriceTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_SALE_ELEMENTS_ID' => 1, 'CURRENCY_ID' => 2, 'PRICE' => 3, 'PROMO_PRICE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_sale_elements_id' => 1, 'currency_id' => 2, 'price' => 3, 'promo_price' => 4, 'created_at' => 5, 'updated_at' => 6, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); @@ -156,7 +156,7 @@ class ProductPriceTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('STOCK_ID', 'StockId', 'INTEGER', 'stock', 'ID', true, null, null); + $this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null); $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null); $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); @@ -169,7 +169,7 @@ class ProductPriceTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::MANY_TO_ONE, array('stock_id' => 'id', ), null, null); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::MANY_TO_ONE, array('product_sale_elements_id' => 'id', ), null, null); $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), null, null); } // buildRelations() @@ -325,7 +325,7 @@ class ProductPriceTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(ProductPriceTableMap::ID); - $criteria->addSelectColumn(ProductPriceTableMap::STOCK_ID); + $criteria->addSelectColumn(ProductPriceTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(ProductPriceTableMap::CURRENCY_ID); $criteria->addSelectColumn(ProductPriceTableMap::PRICE); $criteria->addSelectColumn(ProductPriceTableMap::PROMO_PRICE); @@ -333,7 +333,7 @@ class ProductPriceTableMap extends TableMap $criteria->addSelectColumn(ProductPriceTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.STOCK_ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.CURRENCY_ID'); $criteria->addSelectColumn($alias . '.PRICE'); $criteria->addSelectColumn($alias . '.PROMO_PRICE'); diff --git a/core/lib/Thelia/Model/Map/StockTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php old mode 100755 new mode 100644 similarity index 68% rename from core/lib/Thelia/Model/Map/StockTableMap.php rename to core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index 6a3206c16..2eb9a0b83 --- a/core/lib/Thelia/Model/Map/StockTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\Stock; -use Thelia\Model\StockQuery; +use Thelia\Model\ProductSaleElements; +use Thelia\Model\ProductSaleElementsQuery; /** - * This class defines the structure of the 'stock' table. + * This class defines the structure of the 'product_sale_elements' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\StockQuery; * (i.e. if it's a text column type). * */ -class StockTableMap extends TableMap +class ProductSaleElementsTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.StockTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.ProductSaleElementsTableMap'; /** * The default database name for this class @@ -42,22 +42,22 @@ class StockTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'stock'; + const TABLE_NAME = 'product_sale_elements'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\Stock'; + const OM_CLASS = '\\Thelia\\Model\\ProductSaleElements'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.Stock'; + const CLASS_DEFAULT = 'Thelia.Model.ProductSaleElements'; /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 8; /** * The number of lazy-loaded columns @@ -67,52 +67,47 @@ class StockTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 8; /** * the column name for the ID field */ - const ID = 'stock.ID'; + const ID = 'product_sale_elements.ID'; /** * the column name for the PRODUCT_ID field */ - const PRODUCT_ID = 'stock.PRODUCT_ID'; - - /** - * the column name for the INCREASE field - */ - const INCREASE = 'stock.INCREASE'; + const PRODUCT_ID = 'product_sale_elements.PRODUCT_ID'; /** * the column name for the QUANTITY field */ - const QUANTITY = 'stock.QUANTITY'; + const QUANTITY = 'product_sale_elements.QUANTITY'; /** * the column name for the PROMO field */ - const PROMO = 'stock.PROMO'; + const PROMO = 'product_sale_elements.PROMO'; /** * the column name for the NEWNESS field */ - const NEWNESS = 'stock.NEWNESS'; + const NEWNESS = 'product_sale_elements.NEWNESS'; /** * the column name for the WEIGHT field */ - const WEIGHT = 'stock.WEIGHT'; + const WEIGHT = 'product_sale_elements.WEIGHT'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'stock.CREATED_AT'; + const CREATED_AT = 'product_sale_elements.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'stock.UPDATED_AT'; + const UPDATED_AT = 'product_sale_elements.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -126,12 +121,12 @@ class StockTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'Increase', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'increase', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(StockTableMap::ID, StockTableMap::PRODUCT_ID, StockTableMap::INCREASE, StockTableMap::QUANTITY, StockTableMap::PROMO, StockTableMap::NEWNESS, StockTableMap::WEIGHT, StockTableMap::CREATED_AT, StockTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'INCREASE', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'increase', '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', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -141,12 +136,12 @@ class StockTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Increase' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'increase' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(StockTableMap::ID => 0, StockTableMap::PRODUCT_ID => 1, StockTableMap::INCREASE => 2, StockTableMap::QUANTITY => 3, StockTableMap::PROMO => 4, StockTableMap::NEWNESS => 5, StockTableMap::WEIGHT => 6, StockTableMap::CREATED_AT => 7, StockTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'INCREASE' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'increase' => 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, 'Quantity' => 2, 'Promo' => 3, 'Newness' => 4, 'Weight' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::QUANTITY => 2, ProductSaleElementsTableMap::PROMO => 3, ProductSaleElementsTableMap::NEWNESS => 4, ProductSaleElementsTableMap::WEIGHT => 5, ProductSaleElementsTableMap::CREATED_AT => 6, ProductSaleElementsTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'QUANTITY' => 2, 'PROMO' => 3, 'NEWNESS' => 4, 'WEIGHT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -159,15 +154,14 @@ class StockTableMap extends TableMap public function initialize() { // attributes - $this->setName('stock'); - $this->setPhpName('Stock'); - $this->setClassName('\\Thelia\\Model\\Stock'); + $this->setName('product_sale_elements'); + $this->setPhpName('ProductSaleElements'); + $this->setClassName('\\Thelia\\Model\\ProductSaleElements'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, 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); @@ -182,9 +176,9 @@ class StockTableMap extends TableMap public function buildRelations() { $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'stock_id', ), null, null, 'AttributeCombinations'); - $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'stock_id', ), null, null, 'CartItems'); - $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'stock_id', ), null, null, 'ProductPrices'); + $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'AttributeCombinations'); + $this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'CartItems'); + $this->addRelation('ProductPrice', '\\Thelia\\Model\\ProductPrice', RelationMap::ONE_TO_MANY, array('id' => 'product_sale_elements_id', ), null, null, 'ProductPrices'); } // buildRelations() /** @@ -256,7 +250,7 @@ class StockTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? StockTableMap::CLASS_DEFAULT : StockTableMap::OM_CLASS; + return $withPrefix ? ProductSaleElementsTableMap::CLASS_DEFAULT : ProductSaleElementsTableMap::OM_CLASS; } /** @@ -270,21 +264,21 @@ class StockTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Stock object, last column rank) + * @return array (ProductSaleElements object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = StockTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = StockTableMap::getInstanceFromPool($key))) { + $key = ProductSaleElementsTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductSaleElementsTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + StockTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = StockTableMap::OM_CLASS; + $cls = ProductSaleElementsTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - StockTableMap::addInstanceToPool($obj, $key); + ProductSaleElementsTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -307,8 +301,8 @@ class StockTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = StockTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = StockTableMap::getInstanceFromPool($key))) { + $key = ProductSaleElementsTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductSaleElementsTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -317,7 +311,7 @@ class StockTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - StockTableMap::addInstanceToPool($obj, $key); + ProductSaleElementsTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -338,19 +332,17 @@ class StockTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(StockTableMap::ID); - $criteria->addSelectColumn(StockTableMap::PRODUCT_ID); - $criteria->addSelectColumn(StockTableMap::INCREASE); - $criteria->addSelectColumn(StockTableMap::QUANTITY); - $criteria->addSelectColumn(StockTableMap::PROMO); - $criteria->addSelectColumn(StockTableMap::NEWNESS); - $criteria->addSelectColumn(StockTableMap::WEIGHT); - $criteria->addSelectColumn(StockTableMap::CREATED_AT); - $criteria->addSelectColumn(StockTableMap::UPDATED_AT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::ID); + $criteria->addSelectColumn(ProductSaleElementsTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProductSaleElementsTableMap::QUANTITY); + $criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO); + $criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS); + $criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.INCREASE'); $criteria->addSelectColumn($alias . '.QUANTITY'); $criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.NEWNESS'); @@ -369,7 +361,7 @@ class StockTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME)->getTable(StockTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(ProductSaleElementsTableMap::DATABASE_NAME)->getTable(ProductSaleElementsTableMap::TABLE_NAME); } /** @@ -377,16 +369,16 @@ class StockTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(StockTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new StockTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductSaleElementsTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductSaleElementsTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductSaleElementsTableMap()); } } /** - * Performs a DELETE on the database, given a Stock or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ProductSaleElements or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Stock object or primary key or array of primary keys + * @param mixed $values Criteria or ProductSaleElements object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -397,25 +389,25 @@ class StockTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Stock) { // it's a model object + } elseif ($values instanceof \Thelia\Model\ProductSaleElements) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(StockTableMap::DATABASE_NAME); - $criteria->add(StockTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(ProductSaleElementsTableMap::DATABASE_NAME); + $criteria->add(ProductSaleElementsTableMap::ID, (array) $values, Criteria::IN); } - $query = StockQuery::create()->mergeWith($criteria); + $query = ProductSaleElementsQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { StockTableMap::clearInstancePool(); + if ($values instanceof Criteria) { ProductSaleElementsTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { StockTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { ProductSaleElementsTableMap::removeInstanceFromPool($singleval); } } @@ -423,20 +415,20 @@ class StockTableMap extends TableMap } /** - * Deletes all rows from the stock table. + * Deletes all rows from the product_sale_elements table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return StockQuery::create()->doDeleteAll($con); + return ProductSaleElementsQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Stock or Criteria object. + * Performs an INSERT on the database, given a ProductSaleElements or Criteria object. * - * @param mixed $criteria Criteria or Stock object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or ProductSaleElements object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -445,22 +437,22 @@ class StockTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Stock object + $criteria = $criteria->buildCriteria(); // build Criteria from ProductSaleElements object } - if ($criteria->containsKey(StockTableMap::ID) && $criteria->keyContainsValue(StockTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.StockTableMap::ID.')'); + if ($criteria->containsKey(ProductSaleElementsTableMap::ID) && $criteria->keyContainsValue(ProductSaleElementsTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductSaleElementsTableMap::ID.')'); } // Set the correct dbName - $query = StockQuery::create()->mergeWith($criteria); + $query = ProductSaleElementsQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -476,7 +468,7 @@ class StockTableMap extends TableMap return $pk; } -} // StockTableMap +} // ProductSaleElementsTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -StockTableMap::buildTableMap(); +ProductSaleElementsTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php old mode 100755 new mode 100644 index 4d720e601..b61dd1815 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -199,7 +199,7 @@ class ProductTableMap extends TableMap $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT'); $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories'); $this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts'); - $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Stocks'); + $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss'); $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Images'); $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Documents'); @@ -237,7 +237,7 @@ class ProductTableMap extends TableMap // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductCategoryTableMap::clearInstancePool(); FeatureProductTableMap::clearInstancePool(); - StockTableMap::clearInstancePool(); + ProductSaleElementsTableMap::clearInstancePool(); ContentAssocTableMap::clearInstancePool(); ImageTableMap::clearInstancePool(); DocumentTableMap::clearInstancePool(); diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/RewritingTableMap.php b/core/lib/Thelia/Model/Map/RewritingTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php old mode 100755 new mode 100644 diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 649f315dc..ca26317e0 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -3,7 +3,7 @@ namespace Thelia\Model; use Thelia\Model\Base\Product as BaseProduct; +use Thelia\Model\ProductSaleElements; class Product extends BaseProduct { - } diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php new file mode 100644 index 000000000..cec9c49a7 --- /dev/null +++ b/core/lib/Thelia/Model/ProductSaleElements.php @@ -0,0 +1,10 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Form; + + +class CartAddTest extends \PHPUnit_Framework_TestCase +{ + + public function testSimpleAddingToCart() + { + + } +} \ No newline at end of file diff --git a/install/faker.php b/install/faker.php index 925e83e5c..52572dc81 100755 --- a/install/faker.php +++ b/install/faker.php @@ -7,6 +7,9 @@ $faker = Faker\Factory::create(); $con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $con->beginTransaction(); + +$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne(); + try { $category = Thelia\Model\CategoryQuery::create() @@ -52,13 +55,25 @@ try { $product->addCategory($sweet); $product->setTitle($faker->bs); $product->setDescription($faker->text(250)); - $product->setQuantity($faker->randomNumber(1,50)); - $product->setPrice($faker->randomFloat(2, 20, 2500)); +/* $product->setQuantity($faker->randomNumber(1,50)); + $product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setVisible(1); $product->setPosition($i); $product->setRef($faker->text(255)); $product->save(); + $stock = new \Thelia\Model\Stock(); + $stock->setProduct($product); + $stock->setQuantity($faker->randomNumber(1,50)); + $stock->setPromo($faker->randomNumber(0,1)); + $stock->save(); + + $productPrice = new \Thelia\Model\ProductPrice(); + $productPrice->setStock($stock); + $productPrice->setCurrency($currency); + $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); + $productPrice->save(); + } for ($i=1; $i <= 5; $i++) { @@ -66,13 +81,25 @@ try { $product->addCategory($jeans); $product->setTitle($faker->bs); $product->setDescription($faker->text(250)); - $product->setQuantity($faker->randomNumber(1,50)); - $product->setPrice($faker->randomFloat(2, 20, 2500)); +/* $product->setQuantity($faker->randomNumber(1,50)); + $product->setPrice($faker->randomFloat(2, 20, 2500));*/ $product->setVisible(1); $product->setPosition($i); $product->setRef($faker->text(255)); $product->save(); + $stock = new \Thelia\Model\Stock(); + $stock->setProduct($product); + $stock->setQuantity($faker->randomNumber(1,50)); + $stock->setPromo($faker->randomNumber(0,1)); + $stock->save(); + + $productPrice = new \Thelia\Model\ProductPrice(); + $productPrice->setStock($stock); + $productPrice->setCurrency($currency); + $productPrice->setPrice($faker->randomFloat(2, 20, 2500)); + $productPrice->save(); + } diff --git a/install/insert.sql b/install/insert.sql index a06a3fe1d..6518462c4 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -5,7 +5,8 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`by_default`,`created_at`, (4, 'Italiano', 'it', 'it_IT', '','0', NOW(), NOW()); INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES -('session_config.default', '1', 1, 1, NOW(), NOW()); +('session_config.default', '1', 1, 1, NOW(), NOW()), +('verifyStock', '1', 1, 0, NOW(), NOW()); INSERT INTO `module` (`code`, `type`, `activate`, `position`, `created_at`, `updated_at`) VALUES ('test', '1', '1', '1', NOW(), NOW()); @@ -22,6 +23,19 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'en_US', 'Miss', 'Miss'), (3, 'fr_FR', 'Mlle', 'Madamemoiselle'); +INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate` ,`by_default` ,`created_at` ,`updated_at`) +VALUES +(1, 'EUR', '€', '1', '1', NOW() , NOW()), +(2, 'USD', '$', '1.26', '0', NOW(), NOW()), +(3, 'GBP', '£', '0.89', '0', NOW(), NOW()); + +INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) +VALUES +(1, 'en_US', 'euro'), +(2, 'en_US', 'dollar'), +(3, 'en_US', 'pound'); + + INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at`) VALUES (1, NULL, '4', 'AF', 'AFG', NOW(), NOW()), (2, NULL, '710', 'ZA', 'ZAF', NOW(), NOW()), @@ -1080,4 +1094,4 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po (267, 'fr_FR', 'Wallis-et-Futuna', '', '', ''), (268, 'en_US', 'USA - Alabama', '', '', ''), (268, 'es_ES', 'USA - Alabama', '', '', ''), -(268, 'fr_FR', 'USA - Alabama', '', '', ''); \ No newline at end of file +(268, 'fr_FR', 'USA - Alabama', '', '', ''); diff --git a/install/sqldb.map b/install/sqldb.map deleted file mode 100644 index 63a93baa8..000000000 --- a/install/sqldb.map +++ /dev/null @@ -1,2 +0,0 @@ -# Sqlfile -> Database map -thelia.sql=thelia diff --git a/install/thelia.sql b/install/thelia.sql index 6cfb0dbdf..3f587f40f 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -64,8 +64,8 @@ CREATE TABLE `product_category` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`product_id`,`category_id`), - INDEX `fk_product_has_category_category1_idx` (`category_id`), - INDEX `fk_product_has_category_product1_idx` (`product_id`), + INDEX `idx_product_has_category_category1` (`category_id`), + INDEX `idx_product_has_category_product1` (`product_id`), CONSTRAINT `fk_product_has_category_product1` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) @@ -320,13 +320,13 @@ CREATE TABLE `attribute_combination` ( `attribute_id` INTEGER NOT NULL, `attribute_av_id` INTEGER NOT NULL, - `stock_id` INTEGER NOT NULL, + `product_sale_elements_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`attribute_id`,`attribute_av_id`,`stock_id`), + PRIMARY KEY (`attribute_id`,`attribute_av_id`,`product_sale_elements_id`), INDEX `idx_attribute_combination_attribute_id` (`attribute_id`), INDEX `idx_attribute_combination_attribute_av_id` (`attribute_av_id`), - INDEX `idx_attribute_combination_stock_id` (`stock_id`), + INDEX `idx_attribute_combination_product_sale_elements_id` (`product_sale_elements_id`), CONSTRAINT `fk_attribute_combination_attribute_id` FOREIGN KEY (`attribute_id`) REFERENCES `attribute` (`id`) @@ -337,22 +337,21 @@ CREATE TABLE `attribute_combination` REFERENCES `attribute_av` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - CONSTRAINT `fk_attribute_combination_stock_id` - FOREIGN KEY (`stock_id`) - REFERENCES `stock` (`id`) + CONSTRAINT `fk_attribute_combination_product_sale_elements_id` + FOREIGN KEY (`product_sale_elements_id`) + REFERENCES `product_sale_elements` (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- stock +-- product_sale_elements -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `stock`; +DROP TABLE IF EXISTS `product_sale_elements`; -CREATE TABLE `stock` +CREATE TABLE `product_sale_elements` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `product_id` INTEGER NOT NULL, - `increase` FLOAT, `quantity` FLOAT NOT NULL, `promo` TINYINT DEFAULT 0, `newness` TINYINT DEFAULT 0, @@ -360,8 +359,8 @@ CREATE TABLE `stock` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_stock_product_id` (`product_id`), - CONSTRAINT `fk_stock_product_id` + INDEX `idx_product_sale_element_product_id` (`product_id`), + CONSTRAINT `fk_product_sale_element_product_id` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) ON UPDATE RESTRICT @@ -760,7 +759,6 @@ DROP TABLE IF EXISTS `currency`; CREATE TABLE `currency` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `name` VARCHAR(45), `code` VARCHAR(45), `symbol` VARCHAR(45), `rate` FLOAT, @@ -1073,8 +1071,8 @@ CREATE TABLE `group_module` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `id_idx` (`group_id`), - INDEX `id_idx1` (`module_id`), + INDEX `idx_group_module_group_id` (`group_id`), + INDEX `idx_group_module_module_id` (`module_id`), CONSTRAINT `fk_group_module_group_id` FOREIGN KEY (`group_id`) REFERENCES `group` (`id`) @@ -1251,8 +1249,8 @@ CREATE TABLE `content_folder` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`content_id`,`folder_id`), - INDEX `fk__idx` (`content_id`), - INDEX `fk_content_folder_folder_id_idx` (`folder_id`), + INDEX `idx_content_folder_content_id` (`content_id`), + INDEX `idx_content_folder_folder_id` (`folder_id`), CONSTRAINT `fk_content_folder_content_id` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`) @@ -1313,22 +1311,22 @@ CREATE TABLE `cart_item` `cart_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `quantity` FLOAT DEFAULT 1, - `stock_id` INTEGER NOT NULL, + `product_sale_elements_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), INDEX `idx_cart_item_cart_id` (`cart_id`), INDEX `idx_cart_item_product_id` (`product_id`), - INDEX `idx_cart_item_stock_id` (`stock_id`), + INDEX `idx_cart_item_product_sale_elements_id` (`product_sale_elements_id`), CONSTRAINT `fk_cart_item_cart_id` FOREIGN KEY (`cart_id`) REFERENCES `cart` (`id`), CONSTRAINT `fk_cart_item_product_id` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`), - CONSTRAINT `fk_cart_item_stock_id` - FOREIGN KEY (`stock_id`) - REFERENCES `stock` (`id`) + CONSTRAINT `fk_cart_item_product_sale_elements_id` + FOREIGN KEY (`product_sale_elements_id`) + REFERENCES `product_sale_elements` (`id`) ) ENGINE=InnoDB; -- --------------------------------------------------------------------- @@ -1340,18 +1338,18 @@ DROP TABLE IF EXISTS `product_price`; CREATE TABLE `product_price` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `stock_id` INTEGER NOT NULL, + `product_sale_elements_id` INTEGER NOT NULL, `currency_id` INTEGER NOT NULL, `price` FLOAT NOT NULL, `promo_price` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_product_price_stock_id` (`stock_id`), + INDEX `idx_product_price_product_sale_elements_id` (`product_sale_elements_id`), INDEX `idx_product_price_currency_id` (`currency_id`), - CONSTRAINT `fk_product_price_stock_id` - FOREIGN KEY (`stock_id`) - REFERENCES `stock` (`id`), + CONSTRAINT `fk_product_price_product_sale_elements_id` + FOREIGN KEY (`product_sale_elements_id`) + REFERENCES `product_sale_elements` (`id`), CONSTRAINT `fk_product_price_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) @@ -1664,6 +1662,24 @@ CREATE TABLE `document_i18n` ON DELETE CASCADE ) ENGINE=InnoDB; +-- --------------------------------------------------------------------- +-- currency_i18n +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `currency_i18n`; + +CREATE TABLE `currency_i18n` +( + `id` INTEGER NOT NULL, + `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, + `name` VARCHAR(45), + PRIMARY KEY (`id`,`locale`), + CONSTRAINT `currency_i18n_FK_1` + FOREIGN KEY (`id`) + REFERENCES `currency` (`id`) + ON DELETE CASCADE +) ENGINE=InnoDB; + -- --------------------------------------------------------------------- -- order_status_i18n -- --------------------------------------------------------------------- diff --git a/local/config/schema.xml b/local/config/schema.xml index f1eaa310f..cea0b7763 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,4 +1,4 @@ - + @@ -55,10 +55,10 @@ - + - + @@ -239,15 +239,15 @@
- + - - + + @@ -255,23 +255,22 @@ - - + +
- +
- - + - + @@ -591,6 +590,9 @@ + + +
@@ -795,10 +797,10 @@ - + - + @@ -912,10 +914,10 @@ - + - + @@ -961,15 +963,15 @@ - + - - + + @@ -977,25 +979,25 @@ - - + +
- + - - + + - - + + diff --git a/web/index_dev.php b/web/index_dev.php index 1251c012f..cb9a3d6f0 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -16,6 +16,7 @@ $request = Request::createFromGlobals(); if ( false === in_array($request->getClientIp(), $trustIp)) { //change request to send to a 404 error page + exit; } $thelia = new Thelia("dev", true);