From 9995daa1589ff4dfa0cbc50ca024cf27d4fde3a3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 2 Aug 2013 16:01:21 +0200 Subject: [PATCH 01/29] dispatch event when cart is duplicated --- core/lib/Thelia/Action/Cart.php | 17 +++++++++++++++-- core/lib/Thelia/Config/Resources/action.xml | 2 ++ core/lib/Thelia/Core/Event/CartEvent.php | 19 +------------------ core/lib/Thelia/Core/Event/TheliaEvents.php | 5 +++++ core/lib/Thelia/Model/Cart.php | 13 ------------- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 8634feabb..e4255aa30 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -24,9 +24,12 @@ namespace Thelia\Action; use Symfony\Component\Config\Definition\Exception\Exception; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; +use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Form\CartAdd; use Thelia\Model\CartQuery; @@ -36,6 +39,13 @@ use Thelia\Model\Customer; class Cart implements EventSubscriberInterface { + protected $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + /** * * add an article to cart @@ -44,6 +54,7 @@ class Cart implements EventSubscriberInterface */ public function addArticle(ActionEvent $event) { + var_dump($this); $request = $event->getRequest(); if ($request->isMethod("post")) { @@ -66,7 +77,6 @@ class Cart implements EventSubscriberInterface if($form->isValid()) { } else { - var_dump($form->createView()); } } @@ -194,7 +204,10 @@ class Cart implements EventSubscriberInterface $newCart = $cart->duplicate($this->generateCookie(), $customer); $session->setCart($newCart->getId()); - return $newCart; + $cartEvent = new CartEvent($newCart); + $this->dispatcher->dispatch(TheliaEvents::CART_DUPLICATE, $newCart); + + return $cartEvent->cart; } protected function generateCookie() diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 0816f9958..aa79127a1 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -14,6 +14,8 @@ + + diff --git a/core/lib/Thelia/Core/Event/CartEvent.php b/core/lib/Thelia/Core/Event/CartEvent.php index 92092f154..f4d79c78c 100644 --- a/core/lib/Thelia/Core/Event/CartEvent.php +++ b/core/lib/Thelia/Core/Event/CartEvent.php @@ -29,30 +29,13 @@ use Thelia\Model\Cart; class CartEvent extends InternalEvent { - protected $cart; - protected $modified; + public $cart; 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/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index c086f4fa9..883ea5aff 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -88,4 +88,9 @@ final class TheliaEvents * Sent before customer insertion, to allow modules to create a custom customer reference. */ const CREATECUSTOMER_CUSTOMREF = "customer.creation.customref"; + + /** + * sent when a new existing cat id duplicated. This append when current customer is different from current cart + */ + const CART_DUPLICATE = "cart.duplicate"; } \ No newline at end of file diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 8d74c6f20..2e2a1206c 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -8,14 +8,6 @@ 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(); @@ -50,9 +42,4 @@ class Cart extends BaseCart return $cart; } - - protected function dispatchEvent($name) - { - - } } From 0b2bdd196ff53a81692d45f6992ed97df410a995 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 2 Aug 2013 16:16:04 +0200 Subject: [PATCH 02/29] fix broken tests --- core/lib/Thelia/Action/Cart.php | 2 +- core/lib/Thelia/Tests/Action/CartTest.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index e4255aa30..28b5b7531 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -205,7 +205,7 @@ class Cart implements EventSubscriberInterface $session->setCart($newCart->getId()); $cartEvent = new CartEvent($newCart); - $this->dispatcher->dispatch(TheliaEvents::CART_DUPLICATE, $newCart); + $this->dispatcher->dispatch(TheliaEvents::CART_DUPLICATE, $cartEvent); return $cartEvent->cart; } diff --git a/core/lib/Thelia/Tests/Action/CartTest.php b/core/lib/Thelia/Tests/Action/CartTest.php index 4b9712efc..fb56f1f73 100644 --- a/core/lib/Thelia/Tests/Action/CartTest.php +++ b/core/lib/Thelia/Tests/Action/CartTest.php @@ -50,9 +50,13 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->uniqid = uniqid('', true); + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + $this->actionCart = $this->getMock( "\Thelia\Action\Cart", - array("generateCookie") + array("generateCookie"), + array($dispatcher) + ); $this->actionCart From 17daf2821faea37ef432130e0b72de6d29ad477b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:14:13 +0200 Subject: [PATCH 03/29] add some phpdoc --- core/lib/Thelia/Action/Cart.php | 35 ++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 28b5b7531..1883dd733 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -36,11 +36,23 @@ use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\Customer; - +/** + * + * Class Cart where all actions are manage like adding, modifying or delete items. + * + * Class Cart + * @package Thelia\Action + */ class Cart implements EventSubscriberInterface { + /** + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ protected $dispatcher; + /** + * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher + */ public function __construct(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; @@ -132,6 +144,13 @@ class Cart implements EventSubscriberInterface ); } + /** + * + * search if cart already exists in session. If not try to create a new one or duplicate an old one. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Thelia\Model\Cart + */ public function getCart(Request $request) { @@ -173,8 +192,8 @@ class Cart implements EventSubscriberInterface } /** - * @param Session $session - * @return CartModel + * @param \Thelia\Core\HttpFoundation\Session\Session $session + * @return \Thelia\Model\Cart */ protected function createCart(Session $session) { @@ -194,10 +213,12 @@ class Cart implements EventSubscriberInterface /** - * @param CartModel $cart - * @param Session $session - * @param Customer $customer - * @return CartModel + * try to duplicate existing Cart. Customer is here to determine if this cart belong to him. + * + * @param \Thelia\Model\Cart $cart + * @param \Thelia\Core\HttpFoundation\Session\Session $session + * @param \Thelia\Model\Customer $customer + * @return \Thelia\Model\Cart */ protected function duplicateCart(CartModel $cart, Session $session, Customer $customer = null) { From dcfb4edda34c416e87efa83949f340e6f26dab5d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:50:19 +0200 Subject: [PATCH 04/29] allow possibility to fix cookie end of life --- core/lib/Thelia/Action/Cart.php | 10 +++++++--- core/lib/Thelia/Model/Cart.php | 1 + local/config/schema.xml | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 1883dd733..5fb1847a2 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -34,6 +34,7 @@ use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Form\CartAdd; use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; +use Thelia\Model\ConfigQuery; use Thelia\Model\Customer; /** @@ -233,9 +234,12 @@ class Cart implements EventSubscriberInterface protected function generateCookie() { - $id = uniqid('', true); - setcookie("thelia_cart", $id, time()+(60*60*24*365)); + if (ConfigQuery::read("cart.session_only", 0) == 0) { + $id = uniqid('', true); + setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365)); + + return $id; + } - return $id; } } diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 2e2a1206c..9c0441d81 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -35,6 +35,7 @@ class Cart extends BaseCart $item->setCart($cart); $item->setProductId($cartItem->getProductId()); $item->setQuantity($cartItem->getQuantity()); + $item->setProductSaleElements($productSaleElements); $item->save(); } diff --git a/local/config/schema.xml b/local/config/schema.xml index 46850f8b2..b6c6e4ed1 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -392,7 +392,6 @@ - @@ -964,6 +963,9 @@ + + + From 3262d017916b1b042cea0abf2df22ce9953e981d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:52:41 +0200 Subject: [PATCH 05/29] update model --- core/lib/Thelia/Model/Base/CartItem.php | 204 +++++++++++++++++- core/lib/Thelia/Model/Base/CartItemQuery.php | 139 +++++++++++- core/lib/Thelia/Model/Base/Folder.php | 128 +++-------- core/lib/Thelia/Model/Base/FolderQuery.php | 35 +-- core/lib/Thelia/Model/Base/FolderVersion.php | 126 +++-------- .../Thelia/Model/Base/FolderVersionQuery.php | 35 +-- .../lib/Thelia/Model/Map/CartItemTableMap.php | 52 +++-- core/lib/Thelia/Model/Map/FolderTableMap.php | 36 ++-- .../Model/Map/FolderVersionTableMap.php | 40 ++-- 9 files changed, 471 insertions(+), 324 deletions(-) diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index fa187435a..1297b1de6 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -91,6 +91,24 @@ abstract class CartItem implements ActiveRecordInterface */ protected $product_sale_elements_id; + /** + * The value for the price field. + * @var double + */ + protected $price; + + /** + * The value for the promo_price field. + * @var double + */ + protected $promo_price; + + /** + * The value for the price_end of life field. + * @var string + */ + protected $price_end of life; + /** * The value for the created_at field. * @var string @@ -448,6 +466,48 @@ abstract class CartItem implements ActiveRecordInterface return $this->product_sale_elements_id; } + /** + * Get the [price] column value. + * + * @return double + */ + public function getPrice() + { + + return $this->price; + } + + /** + * Get the [promo_price] column value. + * + * @return double + */ + public function getPromoPrice() + { + + return $this->promo_price; + } + + /** + * Get the [optionally formatted] temporal [price_end of life] 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 getPriceEnd of life($format = NULL) + { + if ($format === null) { + return $this->price_end of life; + } else { + return $this->price_end of life !== null ? $this->price_end of life->format($format) : null; + } + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -605,6 +665,69 @@ abstract class CartItem implements ActiveRecordInterface return $this; } // setProductSaleElementsId() + /** + * Set the value of [price] column. + * + * @param double $v new value + * @return \Thelia\Model\CartItem The current object (for fluent API support) + */ + public function setPrice($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->price !== $v) { + $this->price = $v; + $this->modifiedColumns[] = CartItemTableMap::PRICE; + } + + + return $this; + } // setPrice() + + /** + * Set the value of [promo_price] column. + * + * @param double $v new value + * @return \Thelia\Model\CartItem The current object (for fluent API support) + */ + public function setPromoPrice($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->promo_price !== $v) { + $this->promo_price = $v; + $this->modifiedColumns[] = CartItemTableMap::PROMO_PRICE; + } + + + return $this; + } // setPromoPrice() + + /** + * Sets the value of [price_end of life] 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\CartItem The current object (for fluent API support) + */ + public function setPriceEnd of life($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->price_end of life !== null || $dt !== null) { + if ($dt !== $this->price_end of life) { + $this->price_end of life = $dt; + $this->modifiedColumns[] = CartItemTableMap::PRICE_END OF LIFE; + } + } // if either are not null + + + return $this; + } // setPriceEnd of life() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -703,13 +826,25 @@ abstract class CartItem implements ActiveRecordInterface $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)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CartItemTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartItemTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartItemTableMap::translateFieldName('PriceEnd of life', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->price_end of life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::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 ? 6 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -722,7 +857,7 @@ abstract class CartItem implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = CartItemTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 10; // 10 = CartItemTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e); @@ -995,6 +1130,15 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID)) { $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_ID'; } + if ($this->isColumnModified(CartItemTableMap::PRICE)) { + $modifiedColumns[':p' . $index++] = 'PRICE'; + } + if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) { + $modifiedColumns[':p' . $index++] = 'PROMO_PRICE'; + } + if ($this->isColumnModified(CartItemTableMap::PRICE_END OF LIFE)) { + $modifiedColumns[':p' . $index++] = 'PRICE_END OF LIFE'; + } if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1027,6 +1171,15 @@ abstract class CartItem implements ActiveRecordInterface case 'PRODUCT_SALE_ELEMENTS_ID': $stmt->bindValue($identifier, $this->product_sale_elements_id, PDO::PARAM_INT); break; + case 'PRICE': + $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); + break; + case 'PROMO_PRICE': + $stmt->bindValue($identifier, $this->promo_price, PDO::PARAM_STR); + break; + case 'PRICE_END OF LIFE': + $stmt->bindValue($identifier, $this->price_end of life ? $this->price_end of life->format("Y-m-d H:i:s") : null, 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; @@ -1111,9 +1264,18 @@ abstract class CartItem implements ActiveRecordInterface return $this->getProductSaleElementsId(); break; case 5: - return $this->getCreatedAt(); + return $this->getPrice(); break; case 6: + return $this->getPromoPrice(); + break; + case 7: + return $this->getPriceEnd of life(); + break; + case 8: + return $this->getCreatedAt(); + break; + case 9: return $this->getUpdatedAt(); break; default: @@ -1150,8 +1312,11 @@ abstract class CartItem implements ActiveRecordInterface $keys[2] => $this->getProductId(), $keys[3] => $this->getQuantity(), $keys[4] => $this->getProductSaleElementsId(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[5] => $this->getPrice(), + $keys[6] => $this->getPromoPrice(), + $keys[7] => $this->getPriceEnd of life(), + $keys[8] => $this->getCreatedAt(), + $keys[9] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1219,9 +1384,18 @@ abstract class CartItem implements ActiveRecordInterface $this->setProductSaleElementsId($value); break; case 5: - $this->setCreatedAt($value); + $this->setPrice($value); break; case 6: + $this->setPromoPrice($value); + break; + case 7: + $this->setPriceEnd of life($value); + break; + case 8: + $this->setCreatedAt($value); + break; + case 9: $this->setUpdatedAt($value); break; } // switch() @@ -1253,8 +1427,11 @@ abstract class CartItem implements ActiveRecordInterface 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->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]]); + if (array_key_exists($keys[5], $arr)) $this->setPrice($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setPriceEnd of life($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); } /** @@ -1271,6 +1448,9 @@ abstract class CartItem implements ActiveRecordInterface 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::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); + if ($this->isColumnModified(CartItemTableMap::PRICE)) $criteria->add(CartItemTableMap::PRICE, $this->price); + if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price); + if ($this->isColumnModified(CartItemTableMap::PRICE_END OF LIFE)) $criteria->add(CartItemTableMap::PRICE_END OF LIFE, $this->price_end of life); 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); @@ -1340,6 +1520,9 @@ abstract class CartItem implements ActiveRecordInterface $copyObj->setProductId($this->getProductId()); $copyObj->setQuantity($this->getQuantity()); $copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); + $copyObj->setPrice($this->getPrice()); + $copyObj->setPromoPrice($this->getPromoPrice()); + $copyObj->setPriceEnd of life($this->getPriceEnd of life()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1533,6 +1716,9 @@ abstract class CartItem implements ActiveRecordInterface $this->product_id = null; $this->quantity = null; $this->product_sale_elements_id = null; + $this->price = null; + $this->promo_price = null; + $this->price_end of life = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CartItemQuery.php b/core/lib/Thelia/Model/Base/CartItemQuery.php index a7258d60d..a9f694fd8 100644 --- a/core/lib/Thelia/Model/Base/CartItemQuery.php +++ b/core/lib/Thelia/Model/Base/CartItemQuery.php @@ -26,6 +26,9 @@ use Thelia\Model\Map\CartItemTableMap; * @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 orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column + * @method ChildCartItemQuery orderByPrice($order = Criteria::ASC) Order by the price column + * @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column + * @method ChildCartItemQuery orderByPriceEnd of life($order = Criteria::ASC) Order by the price_end of life 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 * @@ -34,6 +37,9 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery groupByProductId() Group by the product_id column * @method ChildCartItemQuery groupByQuantity() Group by the quantity column * @method ChildCartItemQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column + * @method ChildCartItemQuery groupByPrice() Group by the price column + * @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column + * @method ChildCartItemQuery groupByPriceEnd of life() Group by the price_end of life column * @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column * @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column * @@ -61,6 +67,9 @@ use Thelia\Model\Map\CartItemTableMap; * @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 findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildCartItem filtered by the product_sale_elements_id column + * @method ChildCartItem findOneByPrice(double $price) Return the first ChildCartItem filtered by the price column + * @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column + * @method ChildCartItem findOneByPriceEnd of life(string $price_end of life) Return the first ChildCartItem filtered by the price_end of life 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 * @@ -69,6 +78,9 @@ use Thelia\Model\Map\CartItemTableMap; * @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 findByProductSaleElementsId(int $product_sale_elements_id) Return ChildCartItem objects filtered by the product_sale_elements_id column + * @method array findByPrice(double $price) Return ChildCartItem objects filtered by the price column + * @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column + * @method array findByPriceEnd of life(string $price_end of life) Return ChildCartItem objects filtered by the price_end of life 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 +171,7 @@ abstract class CartItemQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; + $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END OF LIFE, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -459,6 +471,131 @@ abstract class CartItemQuery extends ModelCriteria return $this->addUsingAlias(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $productSaleElementsId, $comparison); } + /** + * Filter the query on the price column + * + * Example usage: + * + * $query->filterByPrice(1234); // WHERE price = 1234 + * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) + * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 + * + * + * @param mixed $price 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 ChildCartItemQuery The current query, for fluid interface + */ + public function filterByPrice($price = null, $comparison = null) + { + if (is_array($price)) { + $useMinMax = false; + if (isset($price['min'])) { + $this->addUsingAlias(CartItemTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($price['max'])) { + $this->addUsingAlias(CartItemTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CartItemTableMap::PRICE, $price, $comparison); + } + + /** + * Filter the query on the promo_price column + * + * Example usage: + * + * $query->filterByPromoPrice(1234); // WHERE promo_price = 1234 + * $query->filterByPromoPrice(array(12, 34)); // WHERE promo_price IN (12, 34) + * $query->filterByPromoPrice(array('min' => 12)); // WHERE promo_price > 12 + * + * + * @param mixed $promoPrice 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 ChildCartItemQuery The current query, for fluid interface + */ + public function filterByPromoPrice($promoPrice = null, $comparison = null) + { + if (is_array($promoPrice)) { + $useMinMax = false; + if (isset($promoPrice['min'])) { + $this->addUsingAlias(CartItemTableMap::PROMO_PRICE, $promoPrice['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($promoPrice['max'])) { + $this->addUsingAlias(CartItemTableMap::PROMO_PRICE, $promoPrice['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CartItemTableMap::PROMO_PRICE, $promoPrice, $comparison); + } + + /** + * Filter the query on the price_end of life column + * + * Example usage: + * + * $query->filterByPriceEnd of life('2011-03-14'); // WHERE price_end of life = '2011-03-14' + * $query->filterByPriceEnd of life('now'); // WHERE price_end of life = '2011-03-14' + * $query->filterByPriceEnd of life(array('max' => 'yesterday')); // WHERE price_end of life > '2011-03-13' + * + * + * @param mixed $priceEnd of life 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 ChildCartItemQuery The current query, for fluid interface + */ + public function filterByPriceEnd of life($priceEnd of life = null, $comparison = null) + { + if (is_array($priceEnd of life)) { + $useMinMax = false; + if (isset($priceEnd of life['min'])) { + $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($priceEnd of life['max'])) { + $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index 094ab27ba..b246b9e34 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -82,12 +82,6 @@ abstract class Folder implements ActiveRecordInterface */ protected $parent; - /** - * The value for the link field. - * @var string - */ - protected $link; - /** * The value for the visible field. * @var int @@ -533,17 +527,6 @@ abstract class Folder implements ActiveRecordInterface return $this->parent; } - /** - * Get the [link] column value. - * - * @return string - */ - public function getLink() - { - - return $this->link; - } - /** * Get the [visible] column value. * @@ -690,27 +673,6 @@ abstract class Folder implements ActiveRecordInterface return $this; } // setParent() - /** - * Set the value of [link] column. - * - * @param string $v new value - * @return \Thelia\Model\Folder The current object (for fluent API support) - */ - public function setLink($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->link !== $v) { - $this->link = $v; - $this->modifiedColumns[] = FolderTableMap::LINK; - } - - - return $this; - } // setLink() - /** * Set the value of [visible] column. * @@ -905,37 +867,34 @@ abstract class Folder implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; - $this->link = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; $this->visible = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderTableMap::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 ? 6 + $startcol : FolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderTableMap::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; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -945,7 +904,7 @@ abstract class Folder implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = FolderTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = FolderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Folder object", 0, $e); @@ -1325,9 +1284,6 @@ abstract class Folder implements ActiveRecordInterface if ($this->isColumnModified(FolderTableMap::PARENT)) { $modifiedColumns[':p' . $index++] = 'PARENT'; } - if ($this->isColumnModified(FolderTableMap::LINK)) { - $modifiedColumns[':p' . $index++] = 'LINK'; - } if ($this->isColumnModified(FolderTableMap::VISIBLE)) { $modifiedColumns[':p' . $index++] = 'VISIBLE'; } @@ -1366,9 +1322,6 @@ abstract class Folder implements ActiveRecordInterface case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case 'LINK': - $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); - break; case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; @@ -1459,27 +1412,24 @@ abstract class Folder implements ActiveRecordInterface return $this->getParent(); break; case 2: - return $this->getLink(); - break; - case 3: return $this->getVisible(); break; - case 4: + case 3: return $this->getPosition(); break; - case 5: + case 4: return $this->getCreatedAt(); break; - case 6: + case 5: return $this->getUpdatedAt(); break; - case 7: + case 6: return $this->getVersion(); break; - case 8: + case 7: return $this->getVersionCreatedAt(); break; - case 9: + case 8: return $this->getVersionCreatedBy(); break; default: @@ -1513,14 +1463,13 @@ abstract class Folder implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getParent(), - $keys[2] => $this->getLink(), - $keys[3] => $this->getVisible(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), + $keys[2] => $this->getVisible(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + $keys[6] => $this->getVersion(), + $keys[7] => $this->getVersionCreatedAt(), + $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1588,27 +1537,24 @@ abstract class Folder implements ActiveRecordInterface $this->setParent($value); break; case 2: - $this->setLink($value); - break; - case 3: $this->setVisible($value); break; - case 4: + case 3: $this->setPosition($value); break; - case 5: + case 4: $this->setCreatedAt($value); break; - case 6: + case 5: $this->setUpdatedAt($value); break; - case 7: + case 6: $this->setVersion($value); break; - case 8: + case 7: $this->setVersionCreatedAt($value); break; - case 9: + case 8: $this->setVersionCreatedBy($value); break; } // switch() @@ -1637,14 +1583,13 @@ abstract class Folder implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($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]]); - if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]); + if (array_key_exists($keys[2], $arr)) $this->setVisible($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]); } /** @@ -1658,7 +1603,6 @@ abstract class Folder implements ActiveRecordInterface if ($this->isColumnModified(FolderTableMap::ID)) $criteria->add(FolderTableMap::ID, $this->id); if ($this->isColumnModified(FolderTableMap::PARENT)) $criteria->add(FolderTableMap::PARENT, $this->parent); - if ($this->isColumnModified(FolderTableMap::LINK)) $criteria->add(FolderTableMap::LINK, $this->link); if ($this->isColumnModified(FolderTableMap::VISIBLE)) $criteria->add(FolderTableMap::VISIBLE, $this->visible); if ($this->isColumnModified(FolderTableMap::POSITION)) $criteria->add(FolderTableMap::POSITION, $this->position); if ($this->isColumnModified(FolderTableMap::CREATED_AT)) $criteria->add(FolderTableMap::CREATED_AT, $this->created_at); @@ -1730,7 +1674,6 @@ abstract class Folder implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setParent($this->getParent()); - $copyObj->setLink($this->getLink()); $copyObj->setVisible($this->getVisible()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); @@ -3602,7 +3545,6 @@ abstract class Folder implements ActiveRecordInterface { $this->id = null; $this->parent = null; - $this->link = null; $this->visible = null; $this->position = null; $this->created_at = null; @@ -3970,7 +3912,6 @@ abstract class Folder implements ActiveRecordInterface $version = new ChildFolderVersion(); $version->setId($this->getId()); $version->setParent($this->getParent()); - $version->setLink($this->getLink()); $version->setVisible($this->getVisible()); $version->setPosition($this->getPosition()); $version->setCreatedAt($this->getCreatedAt()); @@ -4017,7 +3958,6 @@ abstract class Folder implements ActiveRecordInterface $loadedObjects['ChildFolder'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setParent($version->getParent()); - $this->setLink($version->getLink()); $this->setVisible($version->getVisible()); $this->setPosition($version->getPosition()); $this->setCreatedAt($version->getCreatedAt()); diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index 101ab3974..6c7d91701 100644 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -24,7 +24,6 @@ use Thelia\Model\Map\FolderTableMap; * * @method ChildFolderQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildFolderQuery orderByParent($order = Criteria::ASC) Order by the parent column - * @method ChildFolderQuery orderByLink($order = Criteria::ASC) Order by the link column * @method ChildFolderQuery orderByVisible($order = Criteria::ASC) Order by the visible column * @method ChildFolderQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFolderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column @@ -35,7 +34,6 @@ use Thelia\Model\Map\FolderTableMap; * * @method ChildFolderQuery groupById() Group by the id column * @method ChildFolderQuery groupByParent() Group by the parent column - * @method ChildFolderQuery groupByLink() Group by the link column * @method ChildFolderQuery groupByVisible() Group by the visible column * @method ChildFolderQuery groupByPosition() Group by the position column * @method ChildFolderQuery groupByCreatedAt() Group by the created_at column @@ -77,7 +75,6 @@ use Thelia\Model\Map\FolderTableMap; * * @method ChildFolder findOneById(int $id) Return the first ChildFolder filtered by the id column * @method ChildFolder findOneByParent(int $parent) Return the first ChildFolder filtered by the parent column - * @method ChildFolder findOneByLink(string $link) Return the first ChildFolder filtered by the link column * @method ChildFolder findOneByVisible(int $visible) Return the first ChildFolder filtered by the visible column * @method ChildFolder findOneByPosition(int $position) Return the first ChildFolder filtered by the position column * @method ChildFolder findOneByCreatedAt(string $created_at) Return the first ChildFolder filtered by the created_at column @@ -88,7 +85,6 @@ use Thelia\Model\Map\FolderTableMap; * * @method array findById(int $id) Return ChildFolder objects filtered by the id column * @method array findByParent(int $parent) Return ChildFolder objects filtered by the parent column - * @method array findByLink(string $link) Return ChildFolder objects filtered by the link column * @method array findByVisible(int $visible) Return ChildFolder objects filtered by the visible column * @method array findByPosition(int $position) Return ChildFolder objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFolder objects filtered by the created_at column @@ -191,7 +187,7 @@ abstract class FolderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder WHERE ID = :p0'; + $sql = 'SELECT ID, PARENT, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -362,35 +358,6 @@ abstract class FolderQuery extends ModelCriteria return $this->addUsingAlias(FolderTableMap::PARENT, $parent, $comparison); } - /** - * Filter the query on the link column - * - * Example usage: - * - * $query->filterByLink('fooValue'); // WHERE link = 'fooValue' - * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%' - * - * - * @param string $link 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 ChildFolderQuery The current query, for fluid interface - */ - public function filterByLink($link = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($link)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $link)) { - $link = str_replace('*', '%', $link); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderTableMap::LINK, $link, $comparison); - } - /** * Filter the query on the visible column * diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php index 609d41d9d..4f6305b7e 100644 --- a/core/lib/Thelia/Model/Base/FolderVersion.php +++ b/core/lib/Thelia/Model/Base/FolderVersion.php @@ -67,12 +67,6 @@ abstract class FolderVersion implements ActiveRecordInterface */ protected $parent; - /** - * The value for the link field. - * @var string - */ - protected $link; - /** * The value for the visible field. * @var int @@ -418,17 +412,6 @@ abstract class FolderVersion implements ActiveRecordInterface return $this->parent; } - /** - * Get the [link] column value. - * - * @return string - */ - public function getLink() - { - - return $this->link; - } - /** * Get the [visible] column value. * @@ -579,27 +562,6 @@ abstract class FolderVersion implements ActiveRecordInterface return $this; } // setParent() - /** - * Set the value of [link] column. - * - * @param string $v new value - * @return \Thelia\Model\FolderVersion The current object (for fluent API support) - */ - public function setLink($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->link !== $v) { - $this->link = $v; - $this->modifiedColumns[] = FolderVersionTableMap::LINK; - } - - - return $this; - } // setLink() - /** * Set the value of [visible] column. * @@ -794,37 +756,34 @@ abstract class FolderVersion implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; - $this->link = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; $this->visible = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderVersionTableMap::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 ? 6 + $startcol : FolderVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderVersionTableMap::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; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; $this->version = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); @@ -834,7 +793,7 @@ abstract class FolderVersion implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = FolderVersionTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 9; // 9 = FolderVersionTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\FolderVersion object", 0, $e); @@ -1061,9 +1020,6 @@ abstract class FolderVersion implements ActiveRecordInterface if ($this->isColumnModified(FolderVersionTableMap::PARENT)) { $modifiedColumns[':p' . $index++] = 'PARENT'; } - if ($this->isColumnModified(FolderVersionTableMap::LINK)) { - $modifiedColumns[':p' . $index++] = 'LINK'; - } if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) { $modifiedColumns[':p' . $index++] = 'VISIBLE'; } @@ -1102,9 +1058,6 @@ abstract class FolderVersion implements ActiveRecordInterface case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case 'LINK': - $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); - break; case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; @@ -1188,27 +1141,24 @@ abstract class FolderVersion implements ActiveRecordInterface return $this->getParent(); break; case 2: - return $this->getLink(); - break; - case 3: return $this->getVisible(); break; - case 4: + case 3: return $this->getPosition(); break; - case 5: + case 4: return $this->getCreatedAt(); break; - case 6: + case 5: return $this->getUpdatedAt(); break; - case 7: + case 6: return $this->getVersion(); break; - case 8: + case 7: return $this->getVersionCreatedAt(); break; - case 9: + case 8: return $this->getVersionCreatedBy(); break; default: @@ -1242,14 +1192,13 @@ abstract class FolderVersion implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getParent(), - $keys[2] => $this->getLink(), - $keys[3] => $this->getVisible(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), + $keys[2] => $this->getVisible(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + $keys[6] => $this->getVersion(), + $keys[7] => $this->getVersionCreatedAt(), + $keys[8] => $this->getVersionCreatedBy(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1302,27 +1251,24 @@ abstract class FolderVersion implements ActiveRecordInterface $this->setParent($value); break; case 2: - $this->setLink($value); - break; - case 3: $this->setVisible($value); break; - case 4: + case 3: $this->setPosition($value); break; - case 5: + case 4: $this->setCreatedAt($value); break; - case 6: + case 5: $this->setUpdatedAt($value); break; - case 7: + case 6: $this->setVersion($value); break; - case 8: + case 7: $this->setVersionCreatedAt($value); break; - case 9: + case 8: $this->setVersionCreatedBy($value); break; } // switch() @@ -1351,14 +1297,13 @@ abstract class FolderVersion implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($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]]); - if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]); + if (array_key_exists($keys[2], $arr)) $this->setVisible($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]); } /** @@ -1372,7 +1317,6 @@ abstract class FolderVersion implements ActiveRecordInterface if ($this->isColumnModified(FolderVersionTableMap::ID)) $criteria->add(FolderVersionTableMap::ID, $this->id); if ($this->isColumnModified(FolderVersionTableMap::PARENT)) $criteria->add(FolderVersionTableMap::PARENT, $this->parent); - if ($this->isColumnModified(FolderVersionTableMap::LINK)) $criteria->add(FolderVersionTableMap::LINK, $this->link); if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) $criteria->add(FolderVersionTableMap::VISIBLE, $this->visible); if ($this->isColumnModified(FolderVersionTableMap::POSITION)) $criteria->add(FolderVersionTableMap::POSITION, $this->position); if ($this->isColumnModified(FolderVersionTableMap::CREATED_AT)) $criteria->add(FolderVersionTableMap::CREATED_AT, $this->created_at); @@ -1452,7 +1396,6 @@ abstract class FolderVersion implements ActiveRecordInterface { $copyObj->setId($this->getId()); $copyObj->setParent($this->getParent()); - $copyObj->setLink($this->getLink()); $copyObj->setVisible($this->getVisible()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); @@ -1545,7 +1488,6 @@ abstract class FolderVersion implements ActiveRecordInterface { $this->id = null; $this->parent = null; - $this->link = null; $this->visible = null; $this->position = null; $this->created_at = null; diff --git a/core/lib/Thelia/Model/Base/FolderVersionQuery.php b/core/lib/Thelia/Model/Base/FolderVersionQuery.php index 8cf9ac440..22090d7be 100644 --- a/core/lib/Thelia/Model/Base/FolderVersionQuery.php +++ b/core/lib/Thelia/Model/Base/FolderVersionQuery.php @@ -23,7 +23,6 @@ use Thelia\Model\Map\FolderVersionTableMap; * * @method ChildFolderVersionQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildFolderVersionQuery orderByParent($order = Criteria::ASC) Order by the parent column - * @method ChildFolderVersionQuery orderByLink($order = Criteria::ASC) Order by the link column * @method ChildFolderVersionQuery orderByVisible($order = Criteria::ASC) Order by the visible column * @method ChildFolderVersionQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFolderVersionQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column @@ -34,7 +33,6 @@ use Thelia\Model\Map\FolderVersionTableMap; * * @method ChildFolderVersionQuery groupById() Group by the id column * @method ChildFolderVersionQuery groupByParent() Group by the parent column - * @method ChildFolderVersionQuery groupByLink() Group by the link column * @method ChildFolderVersionQuery groupByVisible() Group by the visible column * @method ChildFolderVersionQuery groupByPosition() Group by the position column * @method ChildFolderVersionQuery groupByCreatedAt() Group by the created_at column @@ -56,7 +54,6 @@ use Thelia\Model\Map\FolderVersionTableMap; * * @method ChildFolderVersion findOneById(int $id) Return the first ChildFolderVersion filtered by the id column * @method ChildFolderVersion findOneByParent(int $parent) Return the first ChildFolderVersion filtered by the parent column - * @method ChildFolderVersion findOneByLink(string $link) Return the first ChildFolderVersion filtered by the link column * @method ChildFolderVersion findOneByVisible(int $visible) Return the first ChildFolderVersion filtered by the visible column * @method ChildFolderVersion findOneByPosition(int $position) Return the first ChildFolderVersion filtered by the position column * @method ChildFolderVersion findOneByCreatedAt(string $created_at) Return the first ChildFolderVersion filtered by the created_at column @@ -67,7 +64,6 @@ use Thelia\Model\Map\FolderVersionTableMap; * * @method array findById(int $id) Return ChildFolderVersion objects filtered by the id column * @method array findByParent(int $parent) Return ChildFolderVersion objects filtered by the parent column - * @method array findByLink(string $link) Return ChildFolderVersion objects filtered by the link column * @method array findByVisible(int $visible) Return ChildFolderVersion objects filtered by the visible column * @method array findByPosition(int $position) Return ChildFolderVersion objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFolderVersion objects filtered by the created_at column @@ -163,7 +159,7 @@ abstract class FolderVersionQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder_version WHERE ID = :p0 AND VERSION = :p1'; + $sql = 'SELECT ID, PARENT, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder_version WHERE ID = :p0 AND VERSION = :p1'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); @@ -348,35 +344,6 @@ abstract class FolderVersionQuery extends ModelCriteria return $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent, $comparison); } - /** - * Filter the query on the link column - * - * Example usage: - * - * $query->filterByLink('fooValue'); // WHERE link = 'fooValue' - * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%' - * - * - * @param string $link 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 ChildFolderVersionQuery The current query, for fluid interface - */ - public function filterByLink($link = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($link)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $link)) { - $link = str_replace('*', '%', $link); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderVersionTableMap::LINK, $link, $comparison); - } - /** * Filter the query on the visible column * diff --git a/core/lib/Thelia/Model/Map/CartItemTableMap.php b/core/lib/Thelia/Model/Map/CartItemTableMap.php index 49335f9ec..3283e0975 100644 --- a/core/lib/Thelia/Model/Map/CartItemTableMap.php +++ b/core/lib/Thelia/Model/Map/CartItemTableMap.php @@ -57,7 +57,7 @@ class CartItemTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 10; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CartItemTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 10; /** * the column name for the ID field @@ -94,6 +94,21 @@ class CartItemTableMap extends TableMap */ const PRODUCT_SALE_ELEMENTS_ID = 'cart_item.PRODUCT_SALE_ELEMENTS_ID'; + /** + * the column name for the PRICE field + */ + const PRICE = 'cart_item.PRICE'; + + /** + * the column name for the PROMO_PRICE field + */ + const PROMO_PRICE = 'cart_item.PROMO_PRICE'; + + /** + * the column name for the PRICE_END OF LIFE field + */ + const PRICE_END OF LIFE = 'cart_item.PRICE_END OF LIFE'; + /** * the column name for the CREATED_AT field */ @@ -116,12 +131,12 @@ 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', '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, ) + self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEnd of life', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEnd of life', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END OF LIFE, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END OF LIFE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end of life', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -131,12 +146,12 @@ 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, '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, ) + self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEnd of life' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEnd of life' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + 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::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END OF LIFE => 7, CartItemTableMap::CREATED_AT => 8, CartItemTableMap::UPDATED_AT => 9, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END OF LIFE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), + self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end of life' => 7, 'created_at' => 8, 'updated_at' => 9, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -160,6 +175,9 @@ class CartItemTableMap extends TableMap $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', false, null, 1); $this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null); + $this->addColumn('PRICE', 'Price', 'FLOAT', false, null, null); + $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); + $this->addColumn('PRICE_END OF LIFE', 'PriceEnd of life', 'TIMESTAMP', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -330,6 +348,9 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn(CartItemTableMap::PRODUCT_ID); $criteria->addSelectColumn(CartItemTableMap::QUANTITY); $criteria->addSelectColumn(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID); + $criteria->addSelectColumn(CartItemTableMap::PRICE); + $criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE); + $criteria->addSelectColumn(CartItemTableMap::PRICE_END OF LIFE); $criteria->addSelectColumn(CartItemTableMap::CREATED_AT); $criteria->addSelectColumn(CartItemTableMap::UPDATED_AT); } else { @@ -338,6 +359,9 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.QUANTITY'); $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); + $criteria->addSelectColumn($alias . '.PRICE'); + $criteria->addSelectColumn($alias . '.PROMO_PRICE'); + $criteria->addSelectColumn($alias . '.PRICE_END OF LIFE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index c26e23dc8..cc791d467 100644 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -57,7 +57,7 @@ class FolderTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FolderTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -79,11 +79,6 @@ class FolderTableMap extends TableMap */ const PARENT = 'folder.PARENT'; - /** - * the column name for the LINK field - */ - const LINK = 'folder.LINK'; - /** * the column name for the VISIBLE field */ @@ -140,12 +135,12 @@ class FolderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), - self::TYPE_COLNAME => array(FolderTableMap::ID, FolderTableMap::PARENT, FolderTableMap::LINK, FolderTableMap::VISIBLE, FolderTableMap::POSITION, FolderTableMap::CREATED_AT, FolderTableMap::UPDATED_AT, FolderTableMap::VERSION, FolderTableMap::VERSION_CREATED_AT, FolderTableMap::VERSION_CREATED_BY, ), - self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), - self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'Parent', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(FolderTableMap::ID, FolderTableMap::PARENT, FolderTableMap::VISIBLE, FolderTableMap::POSITION, FolderTableMap::CREATED_AT, FolderTableMap::UPDATED_AT, FolderTableMap::VERSION, FolderTableMap::VERSION_CREATED_AT, FolderTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -155,12 +150,12 @@ class FolderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), - self::TYPE_COLNAME => array(FolderTableMap::ID => 0, FolderTableMap::PARENT => 1, FolderTableMap::LINK => 2, FolderTableMap::VISIBLE => 3, FolderTableMap::POSITION => 4, FolderTableMap::CREATED_AT => 5, FolderTableMap::UPDATED_AT => 6, FolderTableMap::VERSION => 7, FolderTableMap::VERSION_CREATED_AT => 8, FolderTableMap::VERSION_CREATED_BY => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Visible' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ), + self::TYPE_COLNAME => array(FolderTableMap::ID => 0, FolderTableMap::PARENT => 1, FolderTableMap::VISIBLE => 2, FolderTableMap::POSITION => 3, FolderTableMap::CREATED_AT => 4, FolderTableMap::UPDATED_AT => 5, FolderTableMap::VERSION => 6, FolderTableMap::VERSION_CREATED_AT => 7, FolderTableMap::VERSION_CREATED_BY => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'VISIBLE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -181,7 +176,6 @@ class FolderTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); @@ -374,7 +368,6 @@ class FolderTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(FolderTableMap::ID); $criteria->addSelectColumn(FolderTableMap::PARENT); - $criteria->addSelectColumn(FolderTableMap::LINK); $criteria->addSelectColumn(FolderTableMap::VISIBLE); $criteria->addSelectColumn(FolderTableMap::POSITION); $criteria->addSelectColumn(FolderTableMap::CREATED_AT); @@ -385,7 +378,6 @@ class FolderTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); $criteria->addSelectColumn($alias . '.VISIBLE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); diff --git a/core/lib/Thelia/Model/Map/FolderVersionTableMap.php b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php index c686b7da1..440b6d1ae 100644 --- a/core/lib/Thelia/Model/Map/FolderVersionTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php @@ -57,7 +57,7 @@ class FolderVersionTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 9; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FolderVersionTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 9; /** * the column name for the ID field @@ -79,11 +79,6 @@ class FolderVersionTableMap extends TableMap */ const PARENT = 'folder_version.PARENT'; - /** - * the column name for the LINK field - */ - const LINK = 'folder_version.LINK'; - /** * the column name for the VISIBLE field */ @@ -131,12 +126,12 @@ class FolderVersionTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), - self::TYPE_COLNAME => array(FolderVersionTableMap::ID, FolderVersionTableMap::PARENT, FolderVersionTableMap::LINK, FolderVersionTableMap::VISIBLE, FolderVersionTableMap::POSITION, FolderVersionTableMap::CREATED_AT, FolderVersionTableMap::UPDATED_AT, FolderVersionTableMap::VERSION, FolderVersionTableMap::VERSION_CREATED_AT, FolderVersionTableMap::VERSION_CREATED_BY, ), - self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), - self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'Parent', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(FolderVersionTableMap::ID, FolderVersionTableMap::PARENT, FolderVersionTableMap::VISIBLE, FolderVersionTableMap::POSITION, FolderVersionTableMap::CREATED_AT, FolderVersionTableMap::UPDATED_AT, FolderVersionTableMap::VERSION, FolderVersionTableMap::VERSION_CREATED_AT, FolderVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -146,12 +141,12 @@ class FolderVersionTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), - self::TYPE_COLNAME => array(FolderVersionTableMap::ID => 0, FolderVersionTableMap::PARENT => 1, FolderVersionTableMap::LINK => 2, FolderVersionTableMap::VISIBLE => 3, FolderVersionTableMap::POSITION => 4, FolderVersionTableMap::CREATED_AT => 5, FolderVersionTableMap::UPDATED_AT => 6, FolderVersionTableMap::VERSION => 7, FolderVersionTableMap::VERSION_CREATED_AT => 8, FolderVersionTableMap::VERSION_CREATED_BY => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Visible' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ), + self::TYPE_COLNAME => array(FolderVersionTableMap::ID => 0, FolderVersionTableMap::PARENT => 1, FolderVersionTableMap::VISIBLE => 2, FolderVersionTableMap::POSITION => 3, FolderVersionTableMap::CREATED_AT => 4, FolderVersionTableMap::UPDATED_AT => 5, FolderVersionTableMap::VERSION => 6, FolderVersionTableMap::VERSION_CREATED_AT => 7, FolderVersionTableMap::VERSION_CREATED_BY => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'VISIBLE' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'visible' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) ); /** @@ -172,7 +167,6 @@ class FolderVersionTableMap extends TableMap // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null); - $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null); $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); @@ -257,11 +251,11 @@ class FolderVersionTableMap 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 && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', 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 ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { return null; } - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', 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 ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); } /** @@ -379,7 +373,6 @@ class FolderVersionTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(FolderVersionTableMap::ID); $criteria->addSelectColumn(FolderVersionTableMap::PARENT); - $criteria->addSelectColumn(FolderVersionTableMap::LINK); $criteria->addSelectColumn(FolderVersionTableMap::VISIBLE); $criteria->addSelectColumn(FolderVersionTableMap::POSITION); $criteria->addSelectColumn(FolderVersionTableMap::CREATED_AT); @@ -390,7 +383,6 @@ class FolderVersionTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.PARENT'); - $criteria->addSelectColumn($alias . '.LINK'); $criteria->addSelectColumn($alias . '.VISIBLE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); From 33933a63cbe264c757f85c2ee9eb369da4916a92 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:53:15 +0200 Subject: [PATCH 06/29] update sql creation --- install/thelia.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install/thelia.sql b/install/thelia.sql index 0cf0efe7f..6ddfa3948 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -537,7 +537,6 @@ CREATE TABLE `folder` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `parent` INTEGER NOT NULL, - `link` VARCHAR(255), `visible` TINYINT, `position` INTEGER, `created_at` DATETIME, @@ -1312,6 +1311,9 @@ CREATE TABLE `cart_item` `product_id` INTEGER NOT NULL, `quantity` FLOAT DEFAULT 1, `product_sale_elements_id` INTEGER NOT NULL, + `price` FLOAT, + `promo_price` FLOAT, + `price_end of life` DATETIME, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -1845,7 +1847,6 @@ CREATE TABLE `folder_version` ( `id` INTEGER NOT NULL, `parent` INTEGER NOT NULL, - `link` VARCHAR(255), `visible` TINYINT, `position` INTEGER, `created_at` DATETIME, From 2b656336c7fbcde32eb73f85d7966f7f9e12ff4d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:56:19 +0200 Subject: [PATCH 07/29] fix typo in CartItem Model --- local/config/schema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local/config/schema.xml b/local/config/schema.xml index b6c6e4ed1..7db8aa26b 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -965,7 +965,7 @@ - + From c97f0e462a2c091638971c7fc2e4391117f02d21 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 09:57:14 +0200 Subject: [PATCH 08/29] regenerate modeland sql fixing typo in CartItem table --- core/lib/Thelia/Model/Base/CartItem.php | 52 +++++++++---------- core/lib/Thelia/Model/Base/CartItemQuery.php | 34 ++++++------ .../lib/Thelia/Model/Map/CartItemTableMap.php | 30 +++++------ install/thelia.sql | 2 +- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 1297b1de6..3c5711022 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -104,10 +104,10 @@ abstract class CartItem implements ActiveRecordInterface protected $promo_price; /** - * The value for the price_end of life field. + * The value for the price_end_of_life field. * @var string */ - protected $price_end of life; + protected $price_end_of_life; /** * The value for the created_at field. @@ -489,7 +489,7 @@ abstract class CartItem implements ActiveRecordInterface } /** - * Get the [optionally formatted] temporal [price_end of life] column value. + * Get the [optionally formatted] temporal [price_end_of_life] column value. * * * @param string $format The date/time format string (either date()-style or strftime()-style). @@ -499,12 +499,12 @@ abstract class CartItem implements ActiveRecordInterface * * @throws PropelException - if unable to parse/validate the date/time value. */ - public function getPriceEnd of life($format = NULL) + public function getPriceEndOfLife($format = NULL) { if ($format === null) { - return $this->price_end of life; + return $this->price_end_of_life; } else { - return $this->price_end of life !== null ? $this->price_end of life->format($format) : null; + return $this->price_end_of_life !== null ? $this->price_end_of_life->format($format) : null; } } @@ -708,25 +708,25 @@ abstract class CartItem implements ActiveRecordInterface } // setPromoPrice() /** - * Sets the value of [price_end of life] column to a normalized version of the date/time value specified. + * Sets the value of [price_end_of_life] 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\CartItem The current object (for fluent API support) */ - public function setPriceEnd of life($v) + public function setPriceEndOfLife($v) { $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->price_end of life !== null || $dt !== null) { - if ($dt !== $this->price_end of life) { - $this->price_end of life = $dt; - $this->modifiedColumns[] = CartItemTableMap::PRICE_END OF LIFE; + if ($this->price_end_of_life !== null || $dt !== null) { + if ($dt !== $this->price_end_of_life) { + $this->price_end_of_life = $dt; + $this->modifiedColumns[] = CartItemTableMap::PRICE_END_OF_LIFE; } } // if either are not null return $this; - } // setPriceEnd of life() + } // setPriceEndOfLife() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -832,11 +832,11 @@ abstract class CartItem implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CartItemTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; $this->promo_price = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartItemTableMap::translateFieldName('PriceEnd of life', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CartItemTableMap::translateFieldName('PriceEndOfLife', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } - $this->price_end of life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->price_end_of_life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -1136,8 +1136,8 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) { $modifiedColumns[':p' . $index++] = 'PROMO_PRICE'; } - if ($this->isColumnModified(CartItemTableMap::PRICE_END OF LIFE)) { - $modifiedColumns[':p' . $index++] = 'PRICE_END OF LIFE'; + if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) { + $modifiedColumns[':p' . $index++] = 'PRICE_END_OF_LIFE'; } if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -1177,8 +1177,8 @@ abstract class CartItem implements ActiveRecordInterface case 'PROMO_PRICE': $stmt->bindValue($identifier, $this->promo_price, PDO::PARAM_STR); break; - case 'PRICE_END OF LIFE': - $stmt->bindValue($identifier, $this->price_end of life ? $this->price_end of life->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + case 'PRICE_END_OF_LIFE': + $stmt->bindValue($identifier, $this->price_end_of_life ? $this->price_end_of_life->format("Y-m-d H:i:s") : null, 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); @@ -1270,7 +1270,7 @@ abstract class CartItem implements ActiveRecordInterface return $this->getPromoPrice(); break; case 7: - return $this->getPriceEnd of life(); + return $this->getPriceEndOfLife(); break; case 8: return $this->getCreatedAt(); @@ -1314,7 +1314,7 @@ abstract class CartItem implements ActiveRecordInterface $keys[4] => $this->getProductSaleElementsId(), $keys[5] => $this->getPrice(), $keys[6] => $this->getPromoPrice(), - $keys[7] => $this->getPriceEnd of life(), + $keys[7] => $this->getPriceEndOfLife(), $keys[8] => $this->getCreatedAt(), $keys[9] => $this->getUpdatedAt(), ); @@ -1390,7 +1390,7 @@ abstract class CartItem implements ActiveRecordInterface $this->setPromoPrice($value); break; case 7: - $this->setPriceEnd of life($value); + $this->setPriceEndOfLife($value); break; case 8: $this->setCreatedAt($value); @@ -1429,7 +1429,7 @@ abstract class CartItem implements ActiveRecordInterface if (array_key_exists($keys[4], $arr)) $this->setProductSaleElementsId($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPrice($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPriceEnd of life($arr[$keys[7]]); + if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); } @@ -1450,7 +1450,7 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID)) $criteria->add(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, $this->product_sale_elements_id); if ($this->isColumnModified(CartItemTableMap::PRICE)) $criteria->add(CartItemTableMap::PRICE, $this->price); if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price); - if ($this->isColumnModified(CartItemTableMap::PRICE_END OF LIFE)) $criteria->add(CartItemTableMap::PRICE_END OF LIFE, $this->price_end of life); + if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life); 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); @@ -1522,7 +1522,7 @@ abstract class CartItem implements ActiveRecordInterface $copyObj->setProductSaleElementsId($this->getProductSaleElementsId()); $copyObj->setPrice($this->getPrice()); $copyObj->setPromoPrice($this->getPromoPrice()); - $copyObj->setPriceEnd of life($this->getPriceEnd of life()); + $copyObj->setPriceEndOfLife($this->getPriceEndOfLife()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1718,7 +1718,7 @@ abstract class CartItem implements ActiveRecordInterface $this->product_sale_elements_id = null; $this->price = null; $this->promo_price = null; - $this->price_end of life = null; + $this->price_end_of_life = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/CartItemQuery.php b/core/lib/Thelia/Model/Base/CartItemQuery.php index a9f694fd8..d26ceb965 100644 --- a/core/lib/Thelia/Model/Base/CartItemQuery.php +++ b/core/lib/Thelia/Model/Base/CartItemQuery.php @@ -28,7 +28,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery orderByProductSaleElementsId($order = Criteria::ASC) Order by the product_sale_elements_id column * @method ChildCartItemQuery orderByPrice($order = Criteria::ASC) Order by the price column * @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column - * @method ChildCartItemQuery orderByPriceEnd of life($order = Criteria::ASC) Order by the price_end of life column + * @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life 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 * @@ -39,7 +39,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery groupByProductSaleElementsId() Group by the product_sale_elements_id column * @method ChildCartItemQuery groupByPrice() Group by the price column * @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column - * @method ChildCartItemQuery groupByPriceEnd of life() Group by the price_end of life column + * @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column * @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column * @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column * @@ -69,7 +69,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItem findOneByProductSaleElementsId(int $product_sale_elements_id) Return the first ChildCartItem filtered by the product_sale_elements_id column * @method ChildCartItem findOneByPrice(double $price) Return the first ChildCartItem filtered by the price column * @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column - * @method ChildCartItem findOneByPriceEnd of life(string $price_end of life) Return the first ChildCartItem filtered by the price_end of life column + * @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life 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 * @@ -80,7 +80,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method array findByProductSaleElementsId(int $product_sale_elements_id) Return ChildCartItem objects filtered by the product_sale_elements_id column * @method array findByPrice(double $price) Return ChildCartItem objects filtered by the price column * @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column - * @method array findByPriceEnd of life(string $price_end of life) Return ChildCartItem objects filtered by the price_end of life column + * @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life 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 * @@ -171,7 +171,7 @@ abstract class CartItemQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END OF LIFE, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; + $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -554,16 +554,16 @@ abstract class CartItemQuery extends ModelCriteria } /** - * Filter the query on the price_end of life column + * Filter the query on the price_end_of_life column * * Example usage: * - * $query->filterByPriceEnd of life('2011-03-14'); // WHERE price_end of life = '2011-03-14' - * $query->filterByPriceEnd of life('now'); // WHERE price_end of life = '2011-03-14' - * $query->filterByPriceEnd of life(array('max' => 'yesterday')); // WHERE price_end of life > '2011-03-13' + * $query->filterByPriceEndOfLife('2011-03-14'); // WHERE price_end_of_life = '2011-03-14' + * $query->filterByPriceEndOfLife('now'); // WHERE price_end_of_life = '2011-03-14' + * $query->filterByPriceEndOfLife(array('max' => 'yesterday')); // WHERE price_end_of_life > '2011-03-13' * * - * @param mixed $priceEnd of life The value to use as filter. + * @param mixed $priceEndOfLife 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. @@ -573,16 +573,16 @@ abstract class CartItemQuery extends ModelCriteria * * @return ChildCartItemQuery The current query, for fluid interface */ - public function filterByPriceEnd of life($priceEnd of life = null, $comparison = null) + public function filterByPriceEndOfLife($priceEndOfLife = null, $comparison = null) { - if (is_array($priceEnd of life)) { + if (is_array($priceEndOfLife)) { $useMinMax = false; - if (isset($priceEnd of life['min'])) { - $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life['min'], Criteria::GREATER_EQUAL); + if (isset($priceEndOfLife['min'])) { + $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($priceEnd of life['max'])) { - $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life['max'], Criteria::LESS_EQUAL); + if (isset($priceEndOfLife['max'])) { + $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -593,7 +593,7 @@ abstract class CartItemQuery extends ModelCriteria } } - return $this->addUsingAlias(CartItemTableMap::PRICE_END OF LIFE, $priceEnd of life, $comparison); + return $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife, $comparison); } /** diff --git a/core/lib/Thelia/Model/Map/CartItemTableMap.php b/core/lib/Thelia/Model/Map/CartItemTableMap.php index 3283e0975..687b1cd68 100644 --- a/core/lib/Thelia/Model/Map/CartItemTableMap.php +++ b/core/lib/Thelia/Model/Map/CartItemTableMap.php @@ -105,9 +105,9 @@ class CartItemTableMap extends TableMap const PROMO_PRICE = 'cart_item.PROMO_PRICE'; /** - * the column name for the PRICE_END OF LIFE field + * the column name for the PRICE_END_OF_LIFE field */ - const PRICE_END OF LIFE = 'cart_item.PRICE_END OF LIFE'; + const PRICE_END_OF_LIFE = 'cart_item.PRICE_END_OF_LIFE'; /** * the column name for the CREATED_AT field @@ -131,11 +131,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', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEnd of life', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEnd of life', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END OF LIFE, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END OF LIFE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end of life', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); @@ -146,11 +146,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, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEnd of life' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEnd of life' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), - 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::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END OF LIFE => 7, CartItemTableMap::CREATED_AT => 8, CartItemTableMap::UPDATED_AT => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END OF LIFE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end of life' => 7, 'created_at' => 8, 'updated_at' => 9, ), + self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + 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::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::CREATED_AT => 8, CartItemTableMap::UPDATED_AT => 9, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), + self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'created_at' => 8, 'updated_at' => 9, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); @@ -177,7 +177,7 @@ class CartItemTableMap extends TableMap $this->addForeignKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER', 'product_sale_elements', 'ID', true, null, null); $this->addColumn('PRICE', 'Price', 'FLOAT', false, null, null); $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); - $this->addColumn('PRICE_END OF LIFE', 'PriceEnd of life', 'TIMESTAMP', false, null, null); + $this->addColumn('PRICE_END_OF_LIFE', 'PriceEndOfLife', 'TIMESTAMP', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -350,7 +350,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn(CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID); $criteria->addSelectColumn(CartItemTableMap::PRICE); $criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE); - $criteria->addSelectColumn(CartItemTableMap::PRICE_END OF LIFE); + $criteria->addSelectColumn(CartItemTableMap::PRICE_END_OF_LIFE); $criteria->addSelectColumn(CartItemTableMap::CREATED_AT); $criteria->addSelectColumn(CartItemTableMap::UPDATED_AT); } else { @@ -361,7 +361,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_ID'); $criteria->addSelectColumn($alias . '.PRICE'); $criteria->addSelectColumn($alias . '.PROMO_PRICE'); - $criteria->addSelectColumn($alias . '.PRICE_END OF LIFE'); + $criteria->addSelectColumn($alias . '.PRICE_END_OF_LIFE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/install/thelia.sql b/install/thelia.sql index 6ddfa3948..bba595ae6 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1313,7 +1313,7 @@ CREATE TABLE `cart_item` `product_sale_elements_id` INTEGER NOT NULL, `price` FLOAT, `promo_price` FLOAT, - `price_end of life` DATETIME, + `price_end_of_life` DATETIME, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), From 89e15c9bc4b6ee978d7272ada35829af9549d178 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 10:37:51 +0200 Subject: [PATCH 09/29] check if price is already valid on duplicate cart --- core/lib/Thelia/Model/Cart.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 9c0441d81..f84d68280 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -24,7 +24,7 @@ class Cart extends BaseCart } $cart->save(); - + $currentDateTime = new \DateTime(); foreach ($cartItems as $cartItem){ $product = $cartItem->getProduct(); @@ -36,6 +36,12 @@ class Cart extends BaseCart $item->setProductId($cartItem->getProductId()); $item->setQuantity($cartItem->getQuantity()); $item->setProductSaleElements($productSaleElements); + if ($currentDateTime <= $cartItem->getPriceEndOfLife()) { + $item->setPrice($cartItem->getPrice()); + $item->setPromoPrice($cartItem->getPromoPrice()); + // TODO : new price EOF or duplicate current priceEOF from $cartItem ? + $item->setPriceEndOfLife($cartItem->getPriceEndOfLife()); + } $item->save(); } From 1d1bd65a948fe04daf41219d64f02bfdcbd5e76d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 11:15:01 +0200 Subject: [PATCH 10/29] add new price if priceis not valid anymore in cart --- core/lib/Thelia/Model/Cart.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index f84d68280..fa67a4a41 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -4,7 +4,8 @@ namespace Thelia\Model; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Model\Base\Cart as BaseCart; -use Thelia\Model\Base\ProductSaleElementsQuery; +use Thelia\Model\ProductSaleElementsQuery; +use Thelia\Model\ProductPriceQuery; class Cart extends BaseCart { @@ -41,6 +42,12 @@ class Cart extends BaseCart $item->setPromoPrice($cartItem->getPromoPrice()); // TODO : new price EOF or duplicate current priceEOF from $cartItem ? $item->setPriceEndOfLife($cartItem->getPriceEndOfLife()); + } else { + $productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne(); + + $item->setPrice($productPrices->getPrice()); + $item->setPromoPrice($productPrices->getPromoPrice()); + $item->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)); } $item->save(); } From e0be762236fa40012f378ea515c13f12096692f4 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 11:23:52 +0200 Subject: [PATCH 11/29] check if we have to verify stock on duplicate cart --- core/lib/Thelia/Model/Cart.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index fa67a4a41..9a17e3160 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -30,7 +30,11 @@ class Cart extends BaseCart $product = $cartItem->getProduct(); $productSaleElements = $cartItem->getProductSaleElements(); - if ($product && $productSaleElements && $product->getVisible() == 1 && $productSaleElements->getQuantity() > $cartItem->getQuantity()) { + if ($product && + $productSaleElements && + $product->getVisible() == 1 && + ($productSaleElements->getQuantity() > $cartItem->getQuantity() || ! ConfigQuery::read("verifyStock", 1))) + { $item = new CartItem(); $item->setCart($cart); From b18a09b94b8b75e8c2afa92a28218bb4c1da0c33 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 11:53:30 +0200 Subject: [PATCH 12/29] allow token to be null in cart table --- core/lib/Thelia/Action/Cart.php | 4 +++- core/lib/Thelia/Model/Customer.php | 13 ++++++++++--- install/faker.php | 22 ++++++++++++++++++++++ install/thelia.sql | 2 +- local/config/schema.xml | 8 ++++---- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 5fb1847a2..949010384 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -234,12 +234,14 @@ class Cart implements EventSubscriberInterface protected function generateCookie() { + $id = null; if (ConfigQuery::read("cart.session_only", 0) == 0) { $id = uniqid('', true); setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365)); - return $id; } + return $id; + } } diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index b6379380b..5d36b639a 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -45,6 +45,7 @@ class Customer extends BaseCustomer implements UserInterface * @param string $phone customer phone number * @param string $cellphone customer cellphone number * @param string $zipcode customer zipcode + * @param string $city * @param int $countryId customer country id (from Country table) * @param string $email customer email, must be unique * @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password @@ -53,7 +54,7 @@ class Customer extends BaseCustomer implements UserInterface * @param null $sponsor * @param int $discount */ - public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this ->setTitleId($titleId) @@ -79,7 +80,7 @@ class Customer extends BaseCustomer implements UserInterface $address = new Address(); $address - ->setCustomerTitleId($titleId) + ->setTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setAddress1($address1) @@ -119,9 +120,15 @@ class Customer extends BaseCustomer implements UserInterface return uniqid(substr($this->getLastname(), 0, (strlen($this->getLastname()) >= 3) ? 3 : strlen($this->getLastname())), true); } + /** + * create hash for plain password and set it in Customer object + * + * @param string $password plain password before hashing + * @return $this|Customer + * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + */ public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); if ($this->isNew() && ($password === null || trim($password) == "")) { throw new InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/install/faker.php b/install/faker.php index 85a338ebe..de3992c68 100755 --- a/install/faker.php +++ b/install/faker.php @@ -20,6 +20,28 @@ try { ->find(); $product->delete(); + $customer = Thelia\Model\CustomerQuery::create() + ->find(); + $customer->delete(); + + $customer = new Thelia\Model\Customer(); + $customer->createOrUpdate( + 1, + "thelia", + "thelia", + "5 rue rochon", + "", + "", + "0102030405", + "0601020304", + "63000", + "clermont-ferrand", + 64, + "test@thelia.net", + "azerty" + ); + + //first category $sweet = new Thelia\Model\Category(); $sweet->setParent(0); diff --git a/install/thelia.sql b/install/thelia.sql index bba595ae6..8c01bc96f 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -1271,7 +1271,7 @@ DROP TABLE IF EXISTS `cart`; CREATE TABLE `cart` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `token` VARCHAR(255) NOT NULL, + `token` VARCHAR(255), `customer_id` INTEGER, `address_delivery_id` INTEGER, `address_invoice_id` INTEGER, diff --git a/local/config/schema.xml b/local/config/schema.xml index 7db8aa26b..935a156ff 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -923,7 +923,7 @@
- + @@ -940,9 +940,6 @@ - - - @@ -955,6 +952,9 @@ + + +
From ea81889aeaa8990fac3b67f5ba5bf1d9197c33f1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 12:08:12 +0200 Subject: [PATCH 13/29] create method for retriving last item added to cart --- core/lib/Thelia/Model/Cart.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 9a17e3160..7493546ae 100644 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -2,10 +2,12 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Model\Base\Cart as BaseCart; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; +use Thelia\Model\CartItemQuery; class Cart extends BaseCart { @@ -60,4 +62,13 @@ class Cart extends BaseCart return $cart; } + + public function getLastCartItemAdded() + { + $items = CartItemQuery::create() + ->filterByCartId($this->getId()) + ->orderByCreatedAt(Criteria::DESC) + ->findOne() + ; + } } From 7343e7ee02b220cdf9ecbce085230fd565852615 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 12:32:22 +0200 Subject: [PATCH 14/29] initialize cart item add --- core/lib/Thelia/Action/Cart.php | 47 +++++++++++++++++---- core/lib/Thelia/Core/Event/TheliaEvents.php | 10 +++++ core/lib/Thelia/Model/CartItem.php | 21 +++++++++ 3 files changed, 69 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 949010384..e41309279 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -32,6 +32,8 @@ use Thelia\Core\Event\CartEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Form\CartAdd; +use Thelia\Model\ProductPriceQuery; +use Thelia\Model\CartItem; use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; @@ -67,9 +69,43 @@ class Cart implements EventSubscriberInterface */ public function addArticle(ActionEvent $event) { - var_dump($this); $request = $event->getRequest(); + $form = $this->getAddCartForm($request); + + $form->bind($request); + + if($form->isValid()) { + $cart = $this->getCart($request); + + $productSaleElementsId = $form->get("product_sale_elements_id")->getData(); + + $productPrice = ProductPriceQuery::create() + ->filterByProductSaleElementsId($productSaleElementsId) + ->findOne() + ; + + $cartItem = new CartItem(); + $cartItem + ->setCart($cart) + ->setProductId($form->get("product")->getData()) + ->setProductSaleElementsId($productSaleElementsId) + ->setQuantity($form->get("quantity")->getData()) + ->setPrice($productPrice->getPrice()) + ->setPromoPrice($productPrice->getPromoPrice()) + ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) + ->save(); + ; + + + } else { + + + } + } + + private function getAddCartForm(Request $request) + { if ($request->isMethod("post")) { $cartAdd = new CartAdd($request); } else { @@ -83,14 +119,7 @@ class Cart implements EventSubscriberInterface ); } - $form = $cartAdd->getForm(); - - $form->bind($request); - - if($form->isValid()) { - - } else { - } + return $cartAdd->getForm(); } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 883ea5aff..41c5694c6 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -93,4 +93,14 @@ final class TheliaEvents * sent when a new existing cat id duplicated. This append when current customer is different from current cart */ const CART_DUPLICATE = "cart.duplicate"; + + /** + * sent when a new item is added to current cart + */ + const CART_ADDITEM = "cart.addItem"; + + /** + * sent when a cart item is modify + */ + const CART_MODIFYITEM = "cart.modifyItem"; } \ No newline at end of file diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 4b7e2971c..b58323e07 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -2,9 +2,30 @@ namespace Thelia\Model; +use Propel\Runtime\Connection\ConnectionInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; class CartItem extends BaseCartItem { + protected $dispatcher; + + public function setDisptacher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + public function postInsert(ConnectionInterface $con = null) + { + if ($this->dispatcher) { + $cartEvent = new CartEvent($this->getCart()); + + $this->dispatcher->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent); + } + } + + } From 86161f032052b0ccd95e145479d57cf4cde93c7b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 13:00:08 +0200 Subject: [PATCH 15/29] set dispatcher to cartItem on adding new item on cart --- core/lib/Thelia/Action/Cart.php | 1 + core/lib/Thelia/Core/Event/CartItemEvent.php | 42 ++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 core/lib/Thelia/Core/Event/CartItemEvent.php diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index e41309279..6ef171c41 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -86,6 +86,7 @@ class Cart implements EventSubscriberInterface ; $cartItem = new CartItem(); + $cartItem->setDisptacher($event->getDispatcher()); $cartItem ->setCart($cart) ->setProductId($form->get("product")->getData()) diff --git a/core/lib/Thelia/Core/Event/CartItemEvent.php b/core/lib/Thelia/Core/Event/CartItemEvent.php new file mode 100644 index 000000000..710e44473 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CartItemEvent.php @@ -0,0 +1,42 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + + +use Thelia\Model\CartItem; + +class CartItemEvent extends InternalEvent { + + protected $cartItem; + + public function __construct(CartItem $cartItem) + { + $this->cartItem = $cartItem; + } + + public function getCartItem() + { + return $this->cartItem; + } +} \ No newline at end of file From 75929e1d4fe6322f0b922360a091824e53510cc8 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 16:13:34 +0200 Subject: [PATCH 16/29] create new method allowing to add paramter to the current query string --- core/lib/Thelia/Action/Cart.php | 52 +++++++++++-------- .../Thelia/Core/HttpFoundation/Request.php | 45 +++++++++++++--- .../Tests/Core/HttpFoundation/RequestTest.php | 43 +++++++++++++++ 3 files changed, 111 insertions(+), 29 deletions(-) create mode 100644 core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 6ef171c41..46c12cfe5 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -23,6 +23,7 @@ namespace Thelia\Action; +use Propel\Runtime\Exception\PropelException; use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; @@ -38,6 +39,7 @@ use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; use Thelia\Model\Customer; +use Thelia\Tools\Redirect; /** * @@ -71,37 +73,45 @@ class Cart implements EventSubscriberInterface { $request = $event->getRequest(); - $form = $this->getAddCartForm($request); + $cartAdd = $this->getAddCartForm($request); + + $form = $cartAdd->getForm(); $form->bind($request); if($form->isValid()) { - $cart = $this->getCart($request); + try { + $cart = $this->getCart($request); - $productSaleElementsId = $form->get("product_sale_elements_id")->getData(); + $productSaleElementsId = $form->get("product_sale_elements_id")->getData(); - $productPrice = ProductPriceQuery::create() - ->filterByProductSaleElementsId($productSaleElementsId) - ->findOne() - ; + $productPrice = ProductPriceQuery::create() + ->filterByProductSaleElementsId($productSaleElementsId) + ->findOne() + ; - $cartItem = new CartItem(); - $cartItem->setDisptacher($event->getDispatcher()); - $cartItem - ->setCart($cart) - ->setProductId($form->get("product")->getData()) - ->setProductSaleElementsId($productSaleElementsId) - ->setQuantity($form->get("quantity")->getData()) - ->setPrice($productPrice->getPrice()) - ->setPromoPrice($productPrice->getPromoPrice()) - ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) - ->save(); - ; + $cartItem = new CartItem(); + $cartItem->setDisptacher($event->getDispatcher()); + $cartItem + ->setCart($cart) + ->setProductId($form->get("product")->getData()) + ->setProductSaleElementsId($productSaleElementsId) + ->setQuantity($form->get("quantity")->getData()) + ->setPrice($productPrice->getPrice()) + ->setPromoPrice($productPrice->getPromoPrice()) + ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) + ->save(); + ; + Redirect::exec($cartAdd->getSuccessUrl()); + } catch (PropelException $e) { + \Thelia\Log\Tlog::getInstance()->error(sptinf("error on adding item to cart with message : %s", $e->getMessage())); + $message = "Impossible to add this article to your cart, please try again"; + } } else { - + $message = "Missing or invalid data"; } } @@ -120,7 +130,7 @@ class Cart implements EventSubscriberInterface ); } - return $cartAdd->getForm(); + return $cartAdd; } diff --git a/core/lib/Thelia/Core/HttpFoundation/Request.php b/core/lib/Thelia/Core/HttpFoundation/Request.php index e2ed963d0..573cfe228 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Request.php +++ b/core/lib/Thelia/Core/HttpFoundation/Request.php @@ -1,12 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Core\HttpFoundation; use Symfony\Component\HttpFoundation\Request as BaseRequest; @@ -19,4 +32,20 @@ class Request extends BaseRequest{ return $this->get("product_id"); } + public function getUriAddingParameters(array $parameters = null) + { + $uri = $this->getUri(); + + $additionalQs = ''; + + foreach ($parameters as $key => $value) { + $additionalQs .= sprintf("&%s=%s", $key, $value); + } + + if ('' == $this->getQueryString()) { + $additionalQs = '?'. ltrim($additionalQs, '&'); + } + return $uri . $additionalQs; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php b/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php new file mode 100644 index 000000000..1745da6f7 --- /dev/null +++ b/core/lib/Thelia/Tests/Core/HttpFoundation/RequestTest.php @@ -0,0 +1,43 @@ +getMock( + "Thelia\Core\HttpFoundation\Request", + array("getUri", "getQueryString") + ); + + $request->expects($this->any()) + ->method("getUri") + ->will($this->onConsecutiveCalls( + "http://localhost/", + "http://localhost/?test=fu" + )); + + $request->expects($this->any()) + ->method("getQueryString") + ->will($this->onConsecutiveCalls( + "", + "test=fu" + )); + + $result = $request->getUriAddingParameters(array("foo" => "bar")); + + $this->assertEquals("http://localhost/?foo=bar", $result); + + $result = $request->getUriAddingParameters(array("foo" => "bar")); + + $this->assertEquals("http://localhost/?test=fu&foo=bar", $result); + + + } + +} \ No newline at end of file From b0c3112d71a7b7e34853a570648365078164fc77 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 16:31:39 +0200 Subject: [PATCH 17/29] fix default successUrl on addArticle action --- core/lib/Thelia/Action/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 46c12cfe5..ab39d227b 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -103,7 +103,7 @@ class Cart implements EventSubscriberInterface ->save(); ; - Redirect::exec($cartAdd->getSuccessUrl()); + Redirect::exec($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); } catch (PropelException $e) { \Thelia\Log\Tlog::getInstance()->error(sptinf("error on adding item to cart with message : %s", $e->getMessage())); $message = "Impossible to add this article to your cart, please try again"; From f727fe42031830c2d5100f6a51a3a04635e5213b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 6 Aug 2013 16:37:08 +0200 Subject: [PATCH 18/29] set error message to form in addArticle action --- core/lib/Thelia/Action/Cart.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index ab39d227b..7a055d4b2 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -113,6 +113,11 @@ class Cart implements EventSubscriberInterface $message = "Missing or invalid data"; } + + $cartAdd->setError(true); + $cartAdd->setErrorMessage($message); + + $event->setErrorForm($cartAdd); } private function getAddCartForm(Request $request) From 14f12437fc8316ef69a59b33cc6374fdac568846 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 09:57:54 +0200 Subject: [PATCH 19/29] fix argument call --- core/lib/Thelia/Core/Template/Loop/Category.php | 2 +- core/lib/Thelia/Tests/Action/CartTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 87ea0ec08..7c79811bf 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -165,7 +165,7 @@ class Category extends BaseLoop foreach ($categories as $category) { - if ($this->not_empty && $category->countAllProducts() == 0) continue; + if ($this->getNot_empty() && $category->countAllProducts() == 0) continue; $loopResultRow = new LoopResultRow(); diff --git a/core/lib/Thelia/Tests/Action/CartTest.php b/core/lib/Thelia/Tests/Action/CartTest.php index fb56f1f73..9442e526f 100644 --- a/core/lib/Thelia/Tests/Action/CartTest.php +++ b/core/lib/Thelia/Tests/Action/CartTest.php @@ -240,4 +240,9 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->assertEquals($customer->getId(), $getCart->getCustomerId()); } + public function testAddArticle() + { + + } + } \ No newline at end of file From 3fbb72b36c21a1ee18d20ebf0d4543f8aab14846 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 10:20:04 +0200 Subject: [PATCH 20/29] complete INTALL-TODO --- core/lib/Thelia/Action/Cart.php | 2 +- .../Thelia/Tests/Core/Template/Loop/ProductTest.php | 4 ++-- install/INSTALL-TODO.txt | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 7a055d4b2..742994a78 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -282,7 +282,7 @@ class Cart implements EventSubscriberInterface $id = null; if (ConfigQuery::read("cart.session_only", 0) == 0) { $id = uniqid('', true); - setcookie("thelia_cart", $id, time()+ConfigQuery::read("cookie.lifetime", 60*60*24*365)); + setcookie("thelia_cart", $id, time()+ConfigQuery::read("cart.cookie_lifetime", 60*60*24*365)); } diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index 58eaf55fd..1ac5cb3b3 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -32,7 +32,7 @@ use Thelia\Core\Template\Loop\Product; * @author Etienne Roudeix * */ -class ProductTest extends BaseLoopTestor +/*class ProductTest extends BaseLoopTestor { public function getTestedClassName() { @@ -48,4 +48,4 @@ class ProductTest extends BaseLoopTestor { return array(); } -} +}*/ diff --git a/install/INSTALL-TODO.txt b/install/INSTALL-TODO.txt index 748a1788c..e1ffb2202 100644 --- a/install/INSTALL-TODO.txt +++ b/install/INSTALL-TODO.txt @@ -9,3 +9,13 @@ Variables Config à initialiser: - asset_dir_from_web_root : le chemin relatif à /web du repertoires des assets (ex. assets) - active_template: chemin du template front relatif au repertoire template (ex. default) - thelia_version: la version de Thelia (ex. 2.0.0 alpha) +- cart.priceEOF : durée de vie d'un prix dans le panier (par défaut 1 mois 60*60*24*30) +- cart.session_only : pour rattacher le panier uniquement à la session (défaut 0 donc cookie crée) +- cart.cookie_lifetime : durée de vie du cookie du panier (défaut 1 an 60*60*24*365) +- one_domain_foreach_lang : un domaine par langue, défaut 0 +- session_config.default : laisser la configuration par défaut de la session +- session_config.save_path : dossier en absolu dans lequel les sessions sont enregistrés +- default_lang_without_translation : si pas de traduction, prendre la traduction par défaut +- password.length : longueur du mot de passe, défaut 4 +- form.secret : token csrf +- verifyStock : vérification du stock lors du paiement/ajout au panier. Defaut 1 From 9f20740dae7a8ecf9f016d5e1b5a55b93c2c55a3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 10:31:46 +0200 Subject: [PATCH 21/29] remove old part of Tpex --- .../Thelia/Core/Template/BaseParam/Secure.php | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100755 core/lib/Thelia/Core/Template/BaseParam/Secure.php diff --git a/core/lib/Thelia/Core/Template/BaseParam/Secure.php b/core/lib/Thelia/Core/Template/BaseParam/Secure.php deleted file mode 100755 index ecc36299e..000000000 --- a/core/lib/Thelia/Core/Template/BaseParam/Secure.php +++ /dev/null @@ -1,39 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Template\BaseParam; - -use Thelia\Tpex\BaseParam\BaseParam; -use Thelia\Tools\Redirect; - -class Secure extends BaseParam -{ - public function exec() - { - $request = $this->getRequest(); - - if (!$request->getSession()->get('connected') && $this->baseParamValue) { - Redirect::unauthorize(); - } - } -} From 154d8e4d48b849dd980b76d8b7f5de01a682a768 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 10:32:01 +0200 Subject: [PATCH 22/29] remove Redirect::unauthorize method, 401 Code is not a redirect code --- core/lib/Thelia/Tools/Redirect.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/lib/Thelia/Tools/Redirect.php b/core/lib/Thelia/Tools/Redirect.php index 92ae28fa9..66898b0ad 100755 --- a/core/lib/Thelia/Tools/Redirect.php +++ b/core/lib/Thelia/Tools/Redirect.php @@ -28,11 +28,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse; class Redirect { - public static function unauthorize($url) - { - self::exec($url, 401); - } - public static function exec($url, $status = 302) { $response = new RedirectResponse($url, $status); From 69f80d29f583a60706c0bebe731bff1d4ce80873 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 10:42:19 +0200 Subject: [PATCH 23/29] create an abstract class for base action method --- core/lib/Thelia/Action/BaseAction.php | 38 +++++++++++++++++++++++++++ core/lib/Thelia/Action/Cart.php | 5 ++-- core/lib/Thelia/Action/Customer.php | 5 ++-- 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 core/lib/Thelia/Action/BaseAction.php diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php new file mode 100644 index 000000000..dab3cd4f5 --- /dev/null +++ b/core/lib/Thelia/Action/BaseAction.php @@ -0,0 +1,38 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Action; + +use Symfony\Component\HttpFoundation\RedirectResponse; + +abstract class BaseAction +{ + + public function redirect($url, $status = 302) + { + $response = new RedirectResponse($url, $status); + + $response->send(); + exit; + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 742994a78..64f343aa2 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -39,7 +39,6 @@ use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; use Thelia\Model\Customer; -use Thelia\Tools\Redirect; /** * @@ -48,7 +47,7 @@ use Thelia\Tools\Redirect; * Class Cart * @package Thelia\Action */ -class Cart implements EventSubscriberInterface +class Cart extends BaseAction implements EventSubscriberInterface { /** * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface @@ -103,7 +102,7 @@ class Cart implements EventSubscriberInterface ->save(); ; - Redirect::exec($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); + $this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); } catch (PropelException $e) { \Thelia\Log\Tlog::getInstance()->error(sptinf("error on adding item to cart with message : %s", $e->getMessage())); $message = "Impossible to add this article to your cart, please try again"; diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 6ed4b480d..21f599c37 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -37,14 +37,13 @@ use Thelia\Form\CustomerLogin; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\SecurityContext; use Thelia\Model\ConfigQuery; -use Thelia\Tools\Redirect; use Symfony\Component\Validator\Exception\ValidatorException; use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\UsernameNotFoundException; use Propel\Runtime\Exception\PropelException; -class Customer implements EventSubscriberInterface +class Customer extends BaseAction implements EventSubscriberInterface { /** * @var Thelia\Core\Security\SecurityContext @@ -291,7 +290,7 @@ class Customer implements EventSubscriberInterface if ($sendLoginEvent) $event->getDispatcher()->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event); // Redirect to the success URL - Redirect::exec($form->getSuccessUrl()); + $this->redirect($form->getSuccessUrl()); } /** From 77334ee2ce059708e0fa0d7ff4fbae8b4f08d21e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 11:25:41 +0200 Subject: [PATCH 24/29] initialize test on AddARticle action --- core/lib/Thelia/Tests/Action/CartTest.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Tests/Action/CartTest.php b/core/lib/Thelia/Tests/Action/CartTest.php index 9442e526f..7570df1d6 100644 --- a/core/lib/Thelia/Tests/Action/CartTest.php +++ b/core/lib/Thelia/Tests/Action/CartTest.php @@ -23,10 +23,12 @@ namespace Thelia\Tests\Action; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +use Thelia\Core\Event\DefaultActionEvent; use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Model\Cart; use Thelia\Model\Customer; +use Thelia\Model\ProductQuery; class CartTest extends \PHPUnit_Framework_TestCase { @@ -54,7 +56,7 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->actionCart = $this->getMock( "\Thelia\Action\Cart", - array("generateCookie"), + array("generateCookie", "redirect"), array($dispatcher) ); @@ -63,6 +65,10 @@ class CartTest extends \PHPUnit_Framework_TestCase ->expects($this->any()) ->method("generateCookie") ->will($this->returnValue($this->uniqid)); + + $this->actionCart + ->expects($this->any()) + ->method("redirect"); } /** @@ -206,7 +212,7 @@ class CartTest extends \PHPUnit_Framework_TestCase * * A new cart must be created (duplicated) containing customer id */ - public function testGetCartWithExistinsCartAndCustomerButNotSameCustomerId() + public function testGetCartWithExistingCartAndCustomerButNotSameCustomerId() { $actionCart = $this->actionCart; @@ -240,9 +246,20 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->assertEquals($customer->getId(), $getCart->getCustomerId()); } - public function testAddArticle() + + /** + * AddArticle action without data in the request, the form must not be valid + */ + public function testAddArticleWithError() { + $actionEvent = new DefaultActionEvent($this->request, "AddArticle"); + + $this->actionCart->addArticle($actionEvent); + + $this->assertTrue($actionEvent->hasErrorForm(), "no data in the request, so the action must failed and a form error must be present"); } + + } \ No newline at end of file From 80496641c61f40d6903be6ff6095143270e99694 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 14:55:27 +0200 Subject: [PATCH 25/29] try to test form --- core/lib/Thelia/Action/Cart.php | 1 - core/lib/Thelia/Config/Resources/config.xml | 3 +- .../Core/Template/Smarty/Plugins/Assetic.php | 3 +- core/lib/Thelia/Form/CartAdd.php | 28 ++++++++--------- core/lib/Thelia/Tests/Action/CartTest.php | 31 +++++++++++++++++-- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 64f343aa2..bfff73470 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -73,7 +73,6 @@ class Cart extends BaseAction implements EventSubscriberInterface $request = $event->getRequest(); $cartAdd = $this->getAddCartForm($request); - $form = $cartAdd->getForm(); $form->bind($request); diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index c4b517c38..4eb259842 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -29,6 +29,7 @@
+ @@ -84,7 +85,7 @@ - true + false %kernel.environment% %kernel.debug% diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php index 7fca50151..954bb58da 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php @@ -26,6 +26,7 @@ namespace Thelia\Core\Template\Smarty\Plugins; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager; +use Thelia\Model\ConfigQuery; class Assetic extends AbstractSmartyPlugin { @@ -35,7 +36,7 @@ class Assetic extends AbstractSmartyPlugin { $web_root = THELIA_WEB_DIR; - $asset_dir_from_web_root = 'assets/admin/default'; // FIXME + $asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets'); $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root); } diff --git a/core/lib/Thelia/Form/CartAdd.php b/core/lib/Thelia/Form/CartAdd.php index 36f10f2ec..46db7868d 100644 --- a/core/lib/Thelia/Form/CartAdd.php +++ b/core/lib/Thelia/Form/CartAdd.php @@ -57,28 +57,28 @@ class CartAdd extends BaseForm protected function buildForm() { $this->formBuilder - ->add("product", "hidden", array( + ->add("product", "text", array( "constraints" => array( new Constraints\NotBlank(), - new Constraints\Callback(array( - "methods" => array($this, "checkProduct") - )) + new Constraints\Callback(array("methods" => array( + array($this, "checkProduct") + ))) ) )) - ->add("product_sale_elements_id", "hidden", array( + ->add("product_sale_elements_id", "text", array( "constraints" => array( - new Constraints\Callback(array( - "methods" => array($this, "checkStockAvailability") - )) + new Constraints\Callback(array("methods" => array( + array($this, "checkStockAvailability") + ))) ) )) ->add("quantity", "text", array( "constraints" => array( new Constraints\NotBlank(), - new Constraints\Callback(array( - "methods" => array($this, "checkStock") - )), + new Constraints\Callback(array("methods" => array( + array($this, "checkStock") + ))), new Constraints\GreaterThanOrEqual(array( "value" => 0 )) @@ -89,7 +89,7 @@ class CartAdd extends BaseForm ; } - protected function checkProduct($value, ExecutionContextInterface $context) + public function checkProduct($value, ExecutionContextInterface $context) { $product = ProductQuery::create()->findPk($value); @@ -98,7 +98,7 @@ class CartAdd extends BaseForm } } - protected function checkStockAvailability($value, ExecutionContextInterface $context) + public function checkStockAvailability($value, ExecutionContextInterface $context) { if ($value) { $data = $context->getRoot()->getData(); @@ -114,7 +114,7 @@ class CartAdd extends BaseForm } } - protected function checkStock($value, ExecutionContextInterface $context) + public function checkStock($value, ExecutionContextInterface $context) { $data = $context->getRoot()->getData(); diff --git a/core/lib/Thelia/Tests/Action/CartTest.php b/core/lib/Thelia/Tests/Action/CartTest.php index 7570df1d6..c513b2058 100644 --- a/core/lib/Thelia/Tests/Action/CartTest.php +++ b/core/lib/Thelia/Tests/Action/CartTest.php @@ -29,6 +29,7 @@ use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Model\Cart; use Thelia\Model\Customer; use Thelia\Model\ProductQuery; +use Thelia\Model\ProductSaleElementsQuery; class CartTest extends \PHPUnit_Framework_TestCase { @@ -68,7 +69,9 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->actionCart ->expects($this->any()) - ->method("redirect"); + ->method("redirect") + ->will($this->returnValue(true)) + ; } /** @@ -250,7 +253,7 @@ class CartTest extends \PHPUnit_Framework_TestCase /** * AddArticle action without data in the request, the form must not be valid */ - public function testAddArticleWithError() +/* public function testAddArticleWithError() { $actionEvent = new DefaultActionEvent($this->request, "AddArticle"); @@ -258,8 +261,30 @@ class CartTest extends \PHPUnit_Framework_TestCase $this->assertTrue($actionEvent->hasErrorForm(), "no data in the request, so the action must failed and a form error must be present"); - } + }*/ + +/* public function testAddArticleWithValidDataInRequest() + { + $request = $this->request; + $actionCart = $this->actionCart; + + //find valid product + + $product = ProductQuery::create()->findOne(); + $productSalementElements = ProductSaleElementsQuery::create()->filterByProduct($product)->findOne(); + + $request->query->set("thelia_cart_add[product]", $product->getId()); + $request->query->set("thelia_cart_add[product_sale_elements_id]", $productSalementElements->getId()); + $request->query->set("thelia_cart_add[quantity]", 1); + $request->setMethod('GET'); + + $actionEvent = new DefaultActionEvent($request, "AddArticle"); + + $actionCart->addArticle($actionEvent); + + $this->assertFalse($actionEvent->hasErrorForm(), "there is data in the request, form must be valid"); + }*/ } \ No newline at end of file From 02faa94cb41b9d7640a53efe75b11bae92c59e4f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 16:46:25 +0200 Subject: [PATCH 26/29] apply treatment for append and newness when adding item to cart --- core/lib/Thelia/Action/Cart.php | 68 +++++++++++++++++++++++------- core/lib/Thelia/Model/CartItem.php | 5 +++ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index bfff73470..a9bc21118 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -33,8 +33,10 @@ use Thelia\Core\Event\CartEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Session\Session; use Thelia\Form\CartAdd; +use Thelia\Model\ProductPrice; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItem; +use Thelia\Model\CartItemQuery; use Thelia\Model\CartQuery; use Thelia\Model\Cart as CartModel; use Thelia\Model\ConfigQuery; @@ -80,26 +82,29 @@ class Cart extends BaseAction implements EventSubscriberInterface if($form->isValid()) { try { $cart = $this->getCart($request); + $newness = $form->get("newness")->getData(); + $append = $form->get("append")->getData(); + $quantity = $form->get("quantity")->getData(); $productSaleElementsId = $form->get("product_sale_elements_id")->getData(); + $productId = $form->get("product")->getData(); - $productPrice = ProductPriceQuery::create() - ->filterByProductSaleElementsId($productSaleElementsId) - ->findOne() - ; + $cartItem = $this->findItem($cart->getId(), $productId, $productSaleElementsId); + + if($cartItem === null || $newness) + { + $productPrice = ProductPriceQuery::create() + ->filterByProductSaleElementsId($productSaleElementsId) + ->findOne() + ; + + $this->addItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice); + } + + if($append && $cartItem !== null) { + $this->updateQuantity($cartItem, $quantity); + } - $cartItem = new CartItem(); - $cartItem->setDisptacher($event->getDispatcher()); - $cartItem - ->setCart($cart) - ->setProductId($form->get("product")->getData()) - ->setProductSaleElementsId($productSaleElementsId) - ->setQuantity($form->get("quantity")->getData()) - ->setPrice($productPrice->getPrice()) - ->setPromoPrice($productPrice->getPromoPrice()) - ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) - ->save(); - ; $this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1)))); } catch (PropelException $e) { @@ -118,6 +123,37 @@ class Cart extends BaseAction implements EventSubscriberInterface $event->setErrorForm($cartAdd); } + protected function updateQuantity(CartItem $cartItem, $quantity) + { + $cartItem->setDisptacher($this->dispatcher); + $cartItem->addQuantity($quantity) + ->save(); + } + + protected function addItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice) + { + $cartItem = new CartItem(); + $cartItem->setDisptacher($this->dispatcher); + $cartItem + ->setCart($cart) + ->setProductId($productId) + ->setProductSaleElementsId($productSaleElementsId) + ->setQuantity($quantity) + ->setPrice($productPrice->getPrice()) + ->setPromoPrice($productPrice->getPromoPrice()) + ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30)) + ->save(); + } + + protected function findItem($cartId, $productId, $productSaleElementsId) + { + return CartItemQuery::create() + ->filterByCartId($cartId) + ->filterByProductId($productId) + ->filterByProductSaleElementsId($productSaleElementsId) + ->findOne(); + } + private function getAddCartForm(Request $request) { if ($request->isMethod("post")) { diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index b58323e07..f61eb7914 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -26,6 +26,11 @@ class CartItem extends BaseCartItem } } + public function addQuantity($value) + { + $this->setQuantity($this->getQuantity() + $value); + return $this; + } } From de171e3a26113f254c3db142f5b283130554c0bd Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 17:03:30 +0200 Subject: [PATCH 27/29] modify addQuantity method --- core/lib/Thelia/Model/CartItem.php | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index f61eb7914..cfe174989 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -7,6 +7,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\CartEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; +use Thelia\Model\ConfigQuery; class CartItem extends BaseCartItem { @@ -26,9 +27,41 @@ class CartItem extends BaseCartItem } } + public function postUpdate(ConnectionInterface $con = null) + { + if ($this->dispatcher) { + $cartEvent = new CartEvent($this->getCart()); + + $this->dispatcher->dispatch(TheliaEvents::CART_MODIFYITEM, $cartEvent); + } + } + + + /** + * @param $value + * @return $this + */ public function addQuantity($value) { - $this->setQuantity($this->getQuantity() + $value); + $currentQuantity = $this->getQuantity(); + + $newQuantity = $currentQuantity + $value; + + if($newQuantity <= 0) + { + $newQuantity = $currentQuantity; + } + + if(ConfigQuery::read("verifyStock", 1) == 1) + { + $productSaleElements = $this->getProductSaleElements(); + + if($productSaleElements->getQuantity() < $newQuantity) { + $newQuantity = $currentQuantity; + } + } + + $this->setQuantity($currentQuantity); return $this; } From 815ec1fe00f4753cfce49fd6b78574e854efd350 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 7 Aug 2013 17:11:46 +0200 Subject: [PATCH 28/29] change new Quantity value in CartItem::addQuantity --- core/lib/Thelia/Model/CartItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index cfe174989..01381f267 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -61,7 +61,7 @@ class CartItem extends BaseCartItem } } - $this->setQuantity($currentQuantity); + $this->setQuantity($newQuantity); return $this; } From 57b6cc10a005338f61697c0b94315f7a2388a819 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 8 Aug 2013 10:09:24 +0200 Subject: [PATCH 29/29] implement modifyArticle method --- core/lib/Thelia/Action/Cart.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index a9bc21118..ca2768b03 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -181,18 +181,38 @@ class Cart extends BaseAction implements EventSubscriberInterface */ public function deleteArticle(ActionEvent $event) { + $request = $event->getRequest(); + if (null !== $cartItem = $request->get('cartItem')) { + + } } /** * * Modify article's quantity * + * don't use Form here just test the Request. + * * @param \Thelia\Core\Event\ActionEvent $event */ public function modifyArticle(ActionEvent $event) { + $request = $event->getRequest(); + $message = ""; + + if(null !== $cartItemId = $request->get("cartItem") && null !== $quantity = $request->get("quantity")) { + $cart = $this->getCart($request); + $cartItem = CartItemQuery::create() + ->filterByCartId($cart->getId()) + ->filterById($cartItemId) + ->findOne(); + + if($cartItem) { + $this->updateQuantity($cartItem, $quantity); + } + } } /**