From 1d969e38ec25e952d85ee244b49dc3f2309cf8f1 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 19 Sep 2013 18:30:13 +0200 Subject: [PATCH 1/6] order tables --- core/lib/Thelia/Action/Order.php | 31 +- ...duct.php => OrderAttributeCombination.php} | 948 ++++++--------- .../Base/OrderAttributeCombinationQuery.php | 897 +++++++++++++++ .../Thelia/Model/Base/OrderProductQuery.php | 1022 ----------------- ... => OrderAttributeCombinationTableMap.php} | 224 ++-- .../Model/OrderAttributeCombination.php | 10 + ...php => OrderAttributeCombinationQuery.php} | 9 +- core/lib/Thelia/Model/OrderProduct.php | 9 - install/thelia.sql | 28 +- local/config/schema.xml | 24 +- 10 files changed, 1406 insertions(+), 1796 deletions(-) rename core/lib/Thelia/Model/Base/{OrderProduct.php => OrderAttributeCombination.php} (58%) create mode 100644 core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php delete mode 100644 core/lib/Thelia/Model/Base/OrderProductQuery.php rename core/lib/Thelia/Model/Map/{OrderProductTableMap.php => OrderAttributeCombinationTableMap.php} (51%) create mode 100644 core/lib/Thelia/Model/OrderAttributeCombination.php rename core/lib/Thelia/Model/{OrderProductQuery.php => OrderAttributeCombinationQuery.php} (55%) mode change 100755 => 100644 delete mode 100755 core/lib/Thelia/Model/OrderProduct.php diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 4a982673a..c5926acea 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -30,6 +30,7 @@ use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\AddressQuery; use Thelia\Model\ModuleQuery; +use Thelia\Model\OrderProduct; use Thelia\Model\OrderStatus; use Thelia\Model\Map\OrderTableMap; use Thelia\Model\OrderAddress; @@ -108,14 +109,17 @@ class Order extends BaseAction implements EventSubscriberInterface /* use a copy to avoid errored reccord in session */ $placedOrder = $sessionOrder->copy(); + $placedOrder->setDispatcher($this->getDispatcher()); $customer = $this->getSecurityContext()->getCustomerUser(); $currency = $this->getSession()->getCurrency(); $lang = $this->getSession()->getLang(); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); + $cart = $this->getSession()->getCart(); + $cartItems = $cart->getCartItems(); - $paymentModule = ModuleQuery::findPk($placedOrder->getPaymentModuleId()); + $paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId()); /* fulfill order */ $placedOrder->setCustomerId($customer->getId()); @@ -163,7 +167,16 @@ class Order extends BaseAction implements EventSubscriberInterface $placedOrder->save($con); - /* fulfill order_products and decrease stock // @todo dispatch event */ + /* fulfill order_products and decrease stock // @todo + dispatch event */ + + foreach($cartItems as $cartItem) { + $orderProduct = new OrderProduct(); + $orderProduct + ->setOrderId($placedOrder->getId()) + ; + + $in = true; + } /* discount @todo */ @@ -171,14 +184,15 @@ class Order extends BaseAction implements EventSubscriberInterface /* T1style : dispatch mail event ? */ - /* clear session ? */ + /* clear session @todo : remove comment below + test */ + //$sessionOrder = new \Thelia\Model\Order(); /* call pay method */ $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); $paymentModuleInstance = $paymentModuleReflection->newInstance(); - $paymentModuleInstance->setRequest($this->request); - $paymentModuleInstance->setDispatcher($this->dispatcher); + $paymentModuleInstance->setRequest($this->getRequest()); + $paymentModuleInstance->setDispatcher($this->getDispatcher()); $paymentModuleInstance->pay(); } @@ -188,14 +202,13 @@ class Order extends BaseAction implements EventSubscriberInterface */ public function setReference(OrderEvent $event) { - $x = true; - - $this->setRef($this->generateRef()); + $event->getOrder()->setRef($this->generateRef()); } public function generateRef() { - return sprintf('O', uniqid('', true), $this->getId()); + /* order addresses are unique */ + return uniqid('ORD', true); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderAttributeCombination.php similarity index 58% rename from core/lib/Thelia/Model/Base/OrderProduct.php rename to core/lib/Thelia/Model/Base/OrderAttributeCombination.php index 2bf9c7ace..09bd77c28 100644 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderAttributeCombination.php @@ -10,27 +10,24 @@ use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Collection\Collection; -use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\BadMethodCallException; use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Order as ChildOrder; -use Thelia\Model\OrderFeature as ChildOrderFeature; -use Thelia\Model\OrderFeatureQuery as ChildOrderFeatureQuery; +use Thelia\Model\OrderAttributeCombination as ChildOrderAttributeCombination; +use Thelia\Model\OrderAttributeCombinationQuery as ChildOrderAttributeCombinationQuery; use Thelia\Model\OrderProduct as ChildOrderProduct; use Thelia\Model\OrderProductQuery as ChildOrderProductQuery; -use Thelia\Model\OrderQuery as ChildOrderQuery; -use Thelia\Model\Map\OrderProductTableMap; +use Thelia\Model\Map\OrderAttributeCombinationTableMap; -abstract class OrderProduct implements ActiveRecordInterface +abstract class OrderAttributeCombination implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\OrderProductTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\OrderAttributeCombinationTableMap'; /** @@ -66,58 +63,58 @@ abstract class OrderProduct implements ActiveRecordInterface protected $id; /** - * The value for the order_id field. + * The value for the order_product_id field. * @var int */ - protected $order_id; + protected $order_product_id; /** - * The value for the product_ref field. + * The value for the attribute_title field. * @var string */ - protected $product_ref; + protected $attribute_title; /** - * The value for the title field. + * The value for the attribute_chapo field. * @var string */ - protected $title; + protected $attribute_chapo; /** - * The value for the description field. + * The value for the attribute_description field. * @var string */ - protected $description; + protected $attribute_description; /** - * The value for the chapo field. + * The value for the attribute_postscriptumn field. * @var string */ - protected $chapo; + protected $attribute_postscriptumn; /** - * The value for the quantity field. - * @var double + * The value for the attribute_av_title field. + * @var string */ - protected $quantity; + protected $attribute_av_title; /** - * The value for the price field. - * @var double + * The value for the attribute_av_chapo field. + * @var string */ - protected $price; + protected $attribute_av_chapo; /** - * The value for the tax field. - * @var double + * The value for the attribute_av_description field. + * @var string */ - protected $tax; + protected $attribute_av_description; /** - * The value for the parent field. - * @var int + * The value for the attribute_av_postscriptum field. + * @var string */ - protected $parent; + protected $attribute_av_postscriptum; /** * The value for the created_at field. @@ -132,15 +129,9 @@ abstract class OrderProduct implements ActiveRecordInterface protected $updated_at; /** - * @var Order + * @var OrderProduct */ - protected $aOrder; - - /** - * @var ObjectCollection|ChildOrderFeature[] Collection to store aggregation of ChildOrderFeature objects. - */ - protected $collOrderFeatures; - protected $collOrderFeaturesPartial; + protected $aOrderProduct; /** * Flag to prevent endless save loop, if this object is referenced @@ -151,13 +142,7 @@ abstract class OrderProduct implements ActiveRecordInterface protected $alreadyInSave = false; /** - * An array of objects scheduled for deletion. - * @var ObjectCollection - */ - protected $orderFeaturesScheduledForDeletion = null; - - /** - * Initializes internal state of Thelia\Model\Base\OrderProduct object. + * Initializes internal state of Thelia\Model\Base\OrderAttributeCombination object. */ public function __construct() { @@ -252,9 +237,9 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Compares this with another OrderProduct instance. If - * obj is an instance of OrderProduct, delegates to - * equals(OrderProduct). Otherwise, returns false. + * Compares this with another OrderAttributeCombination instance. If + * obj is an instance of OrderAttributeCombination, delegates to + * equals(OrderAttributeCombination). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -335,7 +320,7 @@ abstract class OrderProduct implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return OrderProduct The current object, for fluid interface + * @return OrderAttributeCombination The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -367,7 +352,7 @@ abstract class OrderProduct implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return OrderProduct The current object, for fluid interface + * @return OrderAttributeCombination The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -422,102 +407,102 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [order_id] column value. + * Get the [order_product_id] column value. * * @return int */ - public function getOrderId() + public function getOrderProductId() { - return $this->order_id; + return $this->order_product_id; } /** - * Get the [product_ref] column value. + * Get the [attribute_title] column value. * * @return string */ - public function getProductRef() + public function getAttributeTitle() { - return $this->product_ref; + return $this->attribute_title; } /** - * Get the [title] column value. + * Get the [attribute_chapo] column value. * * @return string */ - public function getTitle() + public function getAttributeChapo() { - return $this->title; + return $this->attribute_chapo; } /** - * Get the [description] column value. + * Get the [attribute_description] column value. * * @return string */ - public function getDescription() + public function getAttributeDescription() { - return $this->description; + return $this->attribute_description; } /** - * Get the [chapo] column value. + * Get the [attribute_postscriptumn] column value. * * @return string */ - public function getChapo() + public function getAttributePostscriptumn() { - return $this->chapo; + return $this->attribute_postscriptumn; } /** - * Get the [quantity] column value. + * Get the [attribute_av_title] column value. * - * @return double + * @return string */ - public function getQuantity() + public function getAttributeAvTitle() { - return $this->quantity; + return $this->attribute_av_title; } /** - * Get the [price] column value. + * Get the [attribute_av_chapo] column value. * - * @return double + * @return string */ - public function getPrice() + public function getAttributeAvChapo() { - return $this->price; + return $this->attribute_av_chapo; } /** - * Get the [tax] column value. + * Get the [attribute_av_description] column value. * - * @return double + * @return string */ - public function getTax() + public function getAttributeAvDescription() { - return $this->tax; + return $this->attribute_av_description; } /** - * Get the [parent] column value. + * Get the [attribute_av_postscriptum] column value. * - * @return int + * @return string */ - public function getParent() + public function getAttributeAvPostscriptum() { - return $this->parent; + return $this->attribute_av_postscriptum; } /** @@ -564,7 +549,7 @@ abstract class OrderProduct implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ public function setId($v) { @@ -574,7 +559,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderProductTableMap::ID; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ID; } @@ -582,204 +567,204 @@ abstract class OrderProduct implements ActiveRecordInterface } // setId() /** - * Set the value of [order_id] column. + * Set the value of [order_product_id] column. * * @param int $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setOrderId($v) + public function setOrderProductId($v) { if ($v !== null) { $v = (int) $v; } - if ($this->order_id !== $v) { - $this->order_id = $v; - $this->modifiedColumns[] = OrderProductTableMap::ORDER_ID; + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID; } - if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { - $this->aOrder = null; + if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { + $this->aOrderProduct = null; } return $this; - } // setOrderId() + } // setOrderProductId() /** - * Set the value of [product_ref] column. + * Set the value of [attribute_title] column. * * @param string $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setProductRef($v) + public function setAttributeTitle($v) { if ($v !== null) { $v = (string) $v; } - if ($this->product_ref !== $v) { - $this->product_ref = $v; - $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_REF; + if ($this->attribute_title !== $v) { + $this->attribute_title = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE; } return $this; - } // setProductRef() + } // setAttributeTitle() /** - * Set the value of [title] column. + * Set the value of [attribute_chapo] column. * * @param string $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setTitle($v) + public function setAttributeChapo($v) { if ($v !== null) { $v = (string) $v; } - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = OrderProductTableMap::TITLE; + if ($this->attribute_chapo !== $v) { + $this->attribute_chapo = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO; } return $this; - } // setTitle() + } // setAttributeChapo() /** - * Set the value of [description] column. + * Set the value of [attribute_description] column. * * @param string $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setDescription($v) + public function setAttributeDescription($v) { if ($v !== null) { $v = (string) $v; } - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = OrderProductTableMap::DESCRIPTION; + if ($this->attribute_description !== $v) { + $this->attribute_description = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION; } return $this; - } // setDescription() + } // setAttributeDescription() /** - * Set the value of [chapo] column. + * Set the value of [attribute_postscriptumn] column. * * @param string $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setChapo($v) + public function setAttributePostscriptumn($v) { if ($v !== null) { $v = (string) $v; } - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + if ($this->attribute_postscriptumn !== $v) { + $this->attribute_postscriptumn = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN; } return $this; - } // setChapo() + } // setAttributePostscriptumn() /** - * Set the value of [quantity] column. + * Set the value of [attribute_av_title] column. * - * @param double $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setQuantity($v) + public function setAttributeAvTitle($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->quantity !== $v) { - $this->quantity = $v; - $this->modifiedColumns[] = OrderProductTableMap::QUANTITY; + if ($this->attribute_av_title !== $v) { + $this->attribute_av_title = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE; } return $this; - } // setQuantity() + } // setAttributeAvTitle() /** - * Set the value of [price] column. + * Set the value of [attribute_av_chapo] column. * - * @param double $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setPrice($v) + public function setAttributeAvChapo($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->price !== $v) { - $this->price = $v; - $this->modifiedColumns[] = OrderProductTableMap::PRICE; + if ($this->attribute_av_chapo !== $v) { + $this->attribute_av_chapo = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO; } return $this; - } // setPrice() + } // setAttributeAvChapo() /** - * Set the value of [tax] column. + * Set the value of [attribute_av_description] column. * - * @param double $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setTax($v) + public function setAttributeAvDescription($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->tax !== $v) { - $this->tax = $v; - $this->modifiedColumns[] = OrderProductTableMap::TAX; + if ($this->attribute_av_description !== $v) { + $this->attribute_av_description = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION; } return $this; - } // setTax() + } // setAttributeAvDescription() /** - * Set the value of [parent] column. + * Set the value of [attribute_av_postscriptum] column. * - * @param int $v new value - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ - public function setParent($v) + public function setAttributeAvPostscriptum($v) { if ($v !== null) { - $v = (int) $v; + $v = (string) $v; } - if ($this->parent !== $v) { - $this->parent = $v; - $this->modifiedColumns[] = OrderProductTableMap::PARENT; + if ($this->attribute_av_postscriptum !== $v) { + $this->attribute_av_postscriptum = $v; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM; } return $this; - } // setParent() + } // setAttributeAvPostscriptum() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -787,7 +772,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = OrderProductTableMap::CREATED_AT; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::CREATED_AT; } } // if either are not null @@ -800,7 +785,7 @@ abstract class OrderProduct implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -808,7 +793,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::UPDATED_AT; } } // if either are not null @@ -853,43 +838,43 @@ abstract class OrderProduct implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->order_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)]; - $this->product_ref = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; - $this->description = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; - $this->chapo = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributePostscriptumn', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_postscriptumn = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; - $this->quantity = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; - $this->price = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvChapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_chapo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; - $this->tax = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; - $this->parent = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvPostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_postscriptum = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderAttributeCombinationTableMap::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 ? 11 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -902,10 +887,10 @@ abstract class OrderProduct implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 12; // 12 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 12; // 12 = OrderAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\OrderAttributeCombination object", 0, $e); } } @@ -924,8 +909,8 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function ensureConsistency() { - if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { - $this->aOrder = null; + if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { + $this->aOrderProduct = null; } } // ensureConsistency @@ -950,13 +935,13 @@ abstract class OrderProduct implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildOrderProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildOrderAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -966,9 +951,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->aOrder = null; - $this->collOrderFeatures = null; - + $this->aOrderProduct = null; } // if (deep) } @@ -978,8 +961,8 @@ abstract class OrderProduct implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see OrderProduct::setDeleted() - * @see OrderProduct::isDeleted() + * @see OrderAttributeCombination::setDeleted() + * @see OrderAttributeCombination::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -988,12 +971,12 @@ abstract class OrderProduct implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildOrderProductQuery::create() + $deleteQuery = ChildOrderAttributeCombinationQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1030,7 +1013,7 @@ abstract class OrderProduct implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1040,16 +1023,16 @@ abstract class OrderProduct implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderProductTableMap::CREATED_AT)) { + if (!$this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -1061,7 +1044,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - OrderProductTableMap::addInstanceToPool($this); + OrderAttributeCombinationTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1096,11 +1079,11 @@ abstract class OrderProduct implements ActiveRecordInterface // method. This object relates to these object(s) by a // foreign key reference. - if ($this->aOrder !== null) { - if ($this->aOrder->isModified() || $this->aOrder->isNew()) { - $affectedRows += $this->aOrder->save($con); + if ($this->aOrderProduct !== null) { + if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { + $affectedRows += $this->aOrderProduct->save($con); } - $this->setOrder($this->aOrder); + $this->setOrderProduct($this->aOrderProduct); } if ($this->isNew() || $this->isModified()) { @@ -1114,23 +1097,6 @@ abstract class OrderProduct implements ActiveRecordInterface $this->resetModified(); } - if ($this->orderFeaturesScheduledForDeletion !== null) { - if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) { - \Thelia\Model\OrderFeatureQuery::create() - ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->orderFeaturesScheduledForDeletion = null; - } - } - - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - $this->alreadyInSave = false; } @@ -1151,51 +1117,51 @@ abstract class OrderProduct implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderProductTableMap::ID; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAttributeCombinationTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderProductTableMap::ID)) { + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = 'ORDER_ID'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; } - if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) { - $modifiedColumns[':p' . $index++] = 'PRODUCT_REF'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_TITLE'; } - if ($this->isColumnModified(OrderProductTableMap::TITLE)) { - $modifiedColumns[':p' . $index++] = 'TITLE'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_CHAPO'; } - if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_DESCRIPTION'; } - if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { - $modifiedColumns[':p' . $index++] = 'CHAPO'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUMN'; } - if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) { - $modifiedColumns[':p' . $index++] = 'QUANTITY'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_TITLE'; } - if ($this->isColumnModified(OrderProductTableMap::PRICE)) { - $modifiedColumns[':p' . $index++] = 'PRICE'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_CHAPO'; } - if ($this->isColumnModified(OrderProductTableMap::TAX)) { - $modifiedColumns[':p' . $index++] = 'TAX'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_DESCRIPTION'; } - if ($this->isColumnModified(OrderProductTableMap::PARENT)) { - $modifiedColumns[':p' . $index++] = 'PARENT'; + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_POSTSCRIPTUM'; } - if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) { + if ($this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + if ($this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO order_product (%s) VALUES (%s)', + 'INSERT INTO order_attribute_combination (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1207,32 +1173,32 @@ abstract class OrderProduct implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'ORDER_ID': - $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); + case 'ORDER_PRODUCT_ID': + $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); break; - case 'PRODUCT_REF': - $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); + case 'ATTRIBUTE_TITLE': + $stmt->bindValue($identifier, $this->attribute_title, PDO::PARAM_STR); break; - case 'TITLE': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + case 'ATTRIBUTE_CHAPO': + $stmt->bindValue($identifier, $this->attribute_chapo, PDO::PARAM_STR); break; - case 'DESCRIPTION': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + case 'ATTRIBUTE_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_description, PDO::PARAM_STR); break; - case 'CHAPO': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + case 'ATTRIBUTE_POSTSCRIPTUMN': + $stmt->bindValue($identifier, $this->attribute_postscriptumn, PDO::PARAM_STR); break; - case 'QUANTITY': - $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); + case 'ATTRIBUTE_AV_TITLE': + $stmt->bindValue($identifier, $this->attribute_av_title, PDO::PARAM_STR); break; - case 'PRICE': - $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); + case 'ATTRIBUTE_AV_CHAPO': + $stmt->bindValue($identifier, $this->attribute_av_chapo, PDO::PARAM_STR); break; - case 'TAX': - $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); + case 'ATTRIBUTE_AV_DESCRIPTION': + $stmt->bindValue($identifier, $this->attribute_av_description, PDO::PARAM_STR); break; - case 'PARENT': - $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); + case 'ATTRIBUTE_AV_POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->attribute_av_postscriptum, 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); @@ -1286,7 +1252,7 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = OrderAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1306,31 +1272,31 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getOrderId(); + return $this->getOrderProductId(); break; case 2: - return $this->getProductRef(); + return $this->getAttributeTitle(); break; case 3: - return $this->getTitle(); + return $this->getAttributeChapo(); break; case 4: - return $this->getDescription(); + return $this->getAttributeDescription(); break; case 5: - return $this->getChapo(); + return $this->getAttributePostscriptumn(); break; case 6: - return $this->getQuantity(); + return $this->getAttributeAvTitle(); break; case 7: - return $this->getPrice(); + return $this->getAttributeAvChapo(); break; case 8: - return $this->getTax(); + return $this->getAttributeAvDescription(); break; case 9: - return $this->getParent(); + return $this->getAttributeAvPostscriptum(); break; case 10: return $this->getCreatedAt(); @@ -1361,22 +1327,22 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['OrderAttributeCombination'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()] = true; - $keys = OrderProductTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['OrderAttributeCombination'][$this->getPrimaryKey()] = true; + $keys = OrderAttributeCombinationTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getOrderId(), - $keys[2] => $this->getProductRef(), - $keys[3] => $this->getTitle(), - $keys[4] => $this->getDescription(), - $keys[5] => $this->getChapo(), - $keys[6] => $this->getQuantity(), - $keys[7] => $this->getPrice(), - $keys[8] => $this->getTax(), - $keys[9] => $this->getParent(), + $keys[1] => $this->getOrderProductId(), + $keys[2] => $this->getAttributeTitle(), + $keys[3] => $this->getAttributeChapo(), + $keys[4] => $this->getAttributeDescription(), + $keys[5] => $this->getAttributePostscriptumn(), + $keys[6] => $this->getAttributeAvTitle(), + $keys[7] => $this->getAttributeAvChapo(), + $keys[8] => $this->getAttributeAvDescription(), + $keys[9] => $this->getAttributeAvPostscriptum(), $keys[10] => $this->getCreatedAt(), $keys[11] => $this->getUpdatedAt(), ); @@ -1387,11 +1353,8 @@ abstract class OrderProduct implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->aOrder) { - $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collOrderFeatures) { - $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->aOrderProduct) { + $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } @@ -1411,7 +1374,7 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = OrderAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1431,31 +1394,31 @@ abstract class OrderProduct implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setOrderId($value); + $this->setOrderProductId($value); break; case 2: - $this->setProductRef($value); + $this->setAttributeTitle($value); break; case 3: - $this->setTitle($value); + $this->setAttributeChapo($value); break; case 4: - $this->setDescription($value); + $this->setAttributeDescription($value); break; case 5: - $this->setChapo($value); + $this->setAttributePostscriptumn($value); break; case 6: - $this->setQuantity($value); + $this->setAttributeAvTitle($value); break; case 7: - $this->setPrice($value); + $this->setAttributeAvChapo($value); break; case 8: - $this->setTax($value); + $this->setAttributeAvDescription($value); break; case 9: - $this->setParent($value); + $this->setAttributeAvPostscriptum($value); break; case 10: $this->setCreatedAt($value); @@ -1485,18 +1448,18 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderProductTableMap::getFieldNames($keyType); + $keys = OrderAttributeCombinationTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setParent($arr[$keys[9]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAttributeTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAttributeChapo($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAttributeDescription($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptumn($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setAttributeAvTitle($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setAttributeAvChapo($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setAttributeAvDescription($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setAttributeAvPostscriptum($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); } @@ -1508,20 +1471,20 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); - if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id); - if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id); - if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref); - if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title); - if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo); - if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity); - if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price); - if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); - if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); - if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ID)) $criteria->add(OrderAttributeCombinationTableMap::ID, $this->id); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, $this->attribute_title); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $this->attribute_chapo); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $this->attribute_description); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $this->attribute_postscriptumn); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $this->attribute_av_title); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $this->attribute_av_chapo); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $this->attribute_av_description); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $this->attribute_av_postscriptum); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) $criteria->add(OrderAttributeCombinationTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) $criteria->add(OrderAttributeCombinationTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1536,8 +1499,8 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); - $criteria->add(OrderProductTableMap::ID, $this->id); + $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderAttributeCombinationTableMap::ID, $this->id); return $criteria; } @@ -1578,38 +1541,24 @@ abstract class OrderProduct implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\OrderProduct (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\OrderAttributeCombination (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setOrderId($this->getOrderId()); - $copyObj->setProductRef($this->getProductRef()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setQuantity($this->getQuantity()); - $copyObj->setPrice($this->getPrice()); - $copyObj->setTax($this->getTax()); - $copyObj->setParent($this->getParent()); + $copyObj->setOrderProductId($this->getOrderProductId()); + $copyObj->setAttributeTitle($this->getAttributeTitle()); + $copyObj->setAttributeChapo($this->getAttributeChapo()); + $copyObj->setAttributeDescription($this->getAttributeDescription()); + $copyObj->setAttributePostscriptumn($this->getAttributePostscriptumn()); + $copyObj->setAttributeAvTitle($this->getAttributeAvTitle()); + $copyObj->setAttributeAvChapo($this->getAttributeAvChapo()); + $copyObj->setAttributeAvDescription($this->getAttributeAvDescription()); + $copyObj->setAttributeAvPostscriptum($this->getAttributeAvPostscriptum()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - - foreach ($this->getOrderFeatures() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderFeature($relObj->copy($deepCopy)); - } - } - - } // if ($deepCopy) - if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value @@ -1625,7 +1574,7 @@ abstract class OrderProduct implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\OrderProduct Clone of current object. + * @return \Thelia\Model\OrderAttributeCombination Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1639,26 +1588,26 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Declares an association between this object and a ChildOrder object. + * Declares an association between this object and a ChildOrderProduct object. * - * @param ChildOrder $v - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) * @throws PropelException */ - public function setOrder(ChildOrder $v = null) + public function setOrderProduct(ChildOrderProduct $v = null) { if ($v === null) { - $this->setOrderId(NULL); + $this->setOrderProductId(NULL); } else { - $this->setOrderId($v->getId()); + $this->setOrderProductId($v->getId()); } - $this->aOrder = $v; + $this->aOrderProduct = $v; // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildOrder object, it will not be re-added. + // If this object has already been added to the ChildOrderProduct object, it will not be re-added. if ($v !== null) { - $v->addOrderProduct($this); + $v->addOrderAttributeCombination($this); } @@ -1667,260 +1616,26 @@ abstract class OrderProduct implements ActiveRecordInterface /** - * Get the associated ChildOrder object + * Get the associated ChildOrderProduct object * * @param ConnectionInterface $con Optional Connection object. - * @return ChildOrder The associated ChildOrder object. + * @return ChildOrderProduct The associated ChildOrderProduct object. * @throws PropelException */ - public function getOrder(ConnectionInterface $con = null) + public function getOrderProduct(ConnectionInterface $con = null) { - if ($this->aOrder === null && ($this->order_id !== null)) { - $this->aOrder = ChildOrderQuery::create()->findPk($this->order_id, $con); + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aOrder->addOrderProducts($this); + $this->aOrderProduct->addOrderAttributeCombinations($this); */ } - return $this->aOrder; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('OrderFeature' == $relationName) { - return $this->initOrderFeatures(); - } - } - - /** - * Clears out the collOrderFeatures collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addOrderFeatures() - */ - public function clearOrderFeatures() - { - $this->collOrderFeatures = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collOrderFeatures collection loaded partially. - */ - public function resetPartialOrderFeatures($v = true) - { - $this->collOrderFeaturesPartial = $v; - } - - /** - * Initializes the collOrderFeatures collection. - * - * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrderFeatures($overrideExisting = true) - { - if (null !== $this->collOrderFeatures && !$overrideExisting) { - return; - } - $this->collOrderFeatures = new ObjectCollection(); - $this->collOrderFeatures->setModel('\Thelia\Model\OrderFeature'); - } - - /** - * Gets an array of ChildOrderFeature objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildOrderProduct is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildOrderFeature[] List of ChildOrderFeature objects - * @throws PropelException - */ - public function getOrderFeatures($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { - // return empty collection - $this->initOrderFeatures(); - } else { - $collOrderFeatures = ChildOrderFeatureQuery::create(null, $criteria) - ->filterByOrderProduct($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) { - $this->initOrderFeatures(false); - - foreach ($collOrderFeatures as $obj) { - if (false == $this->collOrderFeatures->contains($obj)) { - $this->collOrderFeatures->append($obj); - } - } - - $this->collOrderFeaturesPartial = true; - } - - $collOrderFeatures->getInternalIterator()->rewind(); - - return $collOrderFeatures; - } - - if ($partial && $this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $obj) { - if ($obj->isNew()) { - $collOrderFeatures[] = $obj; - } - } - } - - $this->collOrderFeatures = $collOrderFeatures; - $this->collOrderFeaturesPartial = false; - } - } - - return $this->collOrderFeatures; - } - - /** - * Sets a collection of OrderFeature objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $orderFeatures A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildOrderProduct The current object (for fluent API support) - */ - public function setOrderFeatures(Collection $orderFeatures, ConnectionInterface $con = null) - { - $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); - - - $this->orderFeaturesScheduledForDeletion = $orderFeaturesToDelete; - - foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { - $orderFeatureRemoved->setOrderProduct(null); - } - - $this->collOrderFeatures = null; - foreach ($orderFeatures as $orderFeature) { - $this->addOrderFeature($orderFeature); - } - - $this->collOrderFeatures = $orderFeatures; - $this->collOrderFeaturesPartial = false; - - return $this; - } - - /** - * Returns the number of related OrderFeature objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related OrderFeature objects. - * @throws PropelException - */ - public function countOrderFeatures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getOrderFeatures()); - } - - $query = ChildOrderFeatureQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderProduct($this) - ->count($con); - } - - return count($this->collOrderFeatures); - } - - /** - * Method called to associate a ChildOrderFeature object to this object - * through the ChildOrderFeature foreign key attribute. - * - * @param ChildOrderFeature $l ChildOrderFeature - * @return \Thelia\Model\OrderProduct The current object (for fluent API support) - */ - public function addOrderFeature(ChildOrderFeature $l) - { - if ($this->collOrderFeatures === null) { - $this->initOrderFeatures(); - $this->collOrderFeaturesPartial = true; - } - - if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderFeature($l); - } - - return $this; - } - - /** - * @param OrderFeature $orderFeature The orderFeature object to add. - */ - protected function doAddOrderFeature($orderFeature) - { - $this->collOrderFeatures[]= $orderFeature; - $orderFeature->setOrderProduct($this); - } - - /** - * @param OrderFeature $orderFeature The orderFeature object to remove. - * @return ChildOrderProduct The current object (for fluent API support) - */ - public function removeOrderFeature($orderFeature) - { - if ($this->getOrderFeatures()->contains($orderFeature)) { - $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature)); - if (null === $this->orderFeaturesScheduledForDeletion) { - $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures; - $this->orderFeaturesScheduledForDeletion->clear(); - } - $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature; - $orderFeature->setOrderProduct(null); - } - - return $this; + return $this->aOrderProduct; } /** @@ -1929,15 +1644,15 @@ abstract class OrderProduct implements ActiveRecordInterface public function clear() { $this->id = null; - $this->order_id = null; - $this->product_ref = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->quantity = null; - $this->price = null; - $this->tax = null; - $this->parent = null; + $this->order_product_id = null; + $this->attribute_title = null; + $this->attribute_chapo = null; + $this->attribute_description = null; + $this->attribute_postscriptumn = null; + $this->attribute_av_title = null; + $this->attribute_av_chapo = null; + $this->attribute_av_description = null; + $this->attribute_av_postscriptum = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1959,18 +1674,9 @@ abstract class OrderProduct implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $o) { - $o->clearAllReferences($deep); - } - } } // if ($deep) - if ($this->collOrderFeatures instanceof Collection) { - $this->collOrderFeatures->clearIterator(); - } - $this->collOrderFeatures = null; - $this->aOrder = null; + $this->aOrderProduct = null; } /** @@ -1980,7 +1686,7 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(OrderProductTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(OrderAttributeCombinationTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1988,11 +1694,11 @@ abstract class OrderProduct implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildOrderProduct The current object (for fluent API support) + * @return ChildOrderAttributeCombination The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; + $this->modifiedColumns[] = OrderAttributeCombinationTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php new file mode 100644 index 000000000..0c7e7bfd8 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php @@ -0,0 +1,897 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderAttributeCombination|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderAttributeCombination A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUMN, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_attribute_combination WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderAttributeCombination(); + $obj->hydrate($row); + OrderAttributeCombinationTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderAttributeCombination|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_product_id column + * + * Example usage: + * + * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 + * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 + * + * + * @see filterByOrderProduct() + * + * @param mixed $orderProductId 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProductId($orderProductId = null, $comparison = null) + { + if (is_array($orderProductId)) { + $useMinMax = false; + if (isset($orderProductId['min'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderProductId['max'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); + } + + /** + * Filter the query on the attribute_title column + * + * Example usage: + * + * $query->filterByAttributeTitle('fooValue'); // WHERE attribute_title = 'fooValue' + * $query->filterByAttributeTitle('%fooValue%'); // WHERE attribute_title LIKE '%fooValue%' + * + * + * @param string $attributeTitle 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeTitle($attributeTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeTitle)) { + $attributeTitle = str_replace('*', '%', $attributeTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, $attributeTitle, $comparison); + } + + /** + * Filter the query on the attribute_chapo column + * + * Example usage: + * + * $query->filterByAttributeChapo('fooValue'); // WHERE attribute_chapo = 'fooValue' + * $query->filterByAttributeChapo('%fooValue%'); // WHERE attribute_chapo LIKE '%fooValue%' + * + * + * @param string $attributeChapo 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeChapo($attributeChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeChapo)) { + $attributeChapo = str_replace('*', '%', $attributeChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $attributeChapo, $comparison); + } + + /** + * Filter the query on the attribute_description column + * + * Example usage: + * + * $query->filterByAttributeDescription('fooValue'); // WHERE attribute_description = 'fooValue' + * $query->filterByAttributeDescription('%fooValue%'); // WHERE attribute_description LIKE '%fooValue%' + * + * + * @param string $attributeDescription 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeDescription($attributeDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeDescription)) { + $attributeDescription = str_replace('*', '%', $attributeDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $attributeDescription, $comparison); + } + + /** + * Filter the query on the attribute_postscriptumn column + * + * Example usage: + * + * $query->filterByAttributePostscriptumn('fooValue'); // WHERE attribute_postscriptumn = 'fooValue' + * $query->filterByAttributePostscriptumn('%fooValue%'); // WHERE attribute_postscriptumn LIKE '%fooValue%' + * + * + * @param string $attributePostscriptumn 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributePostscriptumn($attributePostscriptumn = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributePostscriptumn)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributePostscriptumn)) { + $attributePostscriptumn = str_replace('*', '%', $attributePostscriptumn); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $attributePostscriptumn, $comparison); + } + + /** + * Filter the query on the attribute_av_title column + * + * Example usage: + * + * $query->filterByAttributeAvTitle('fooValue'); // WHERE attribute_av_title = 'fooValue' + * $query->filterByAttributeAvTitle('%fooValue%'); // WHERE attribute_av_title LIKE '%fooValue%' + * + * + * @param string $attributeAvTitle 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvTitle($attributeAvTitle = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvTitle)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvTitle)) { + $attributeAvTitle = str_replace('*', '%', $attributeAvTitle); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $attributeAvTitle, $comparison); + } + + /** + * Filter the query on the attribute_av_chapo column + * + * Example usage: + * + * $query->filterByAttributeAvChapo('fooValue'); // WHERE attribute_av_chapo = 'fooValue' + * $query->filterByAttributeAvChapo('%fooValue%'); // WHERE attribute_av_chapo LIKE '%fooValue%' + * + * + * @param string $attributeAvChapo 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvChapo($attributeAvChapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvChapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvChapo)) { + $attributeAvChapo = str_replace('*', '%', $attributeAvChapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $attributeAvChapo, $comparison); + } + + /** + * Filter the query on the attribute_av_description column + * + * Example usage: + * + * $query->filterByAttributeAvDescription('fooValue'); // WHERE attribute_av_description = 'fooValue' + * $query->filterByAttributeAvDescription('%fooValue%'); // WHERE attribute_av_description LIKE '%fooValue%' + * + * + * @param string $attributeAvDescription 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvDescription($attributeAvDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvDescription)) { + $attributeAvDescription = str_replace('*', '%', $attributeAvDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $attributeAvDescription, $comparison); + } + + /** + * Filter the query on the attribute_av_postscriptum column + * + * Example usage: + * + * $query->filterByAttributeAvPostscriptum('fooValue'); // WHERE attribute_av_postscriptum = 'fooValue' + * $query->filterByAttributeAvPostscriptum('%fooValue%'); // WHERE attribute_av_postscriptum LIKE '%fooValue%' + * + * + * @param string $attributeAvPostscriptum 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByAttributeAvPostscriptum($attributeAvPostscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeAvPostscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeAvPostscriptum)) { + $attributeAvPostscriptum = str_replace('*', '%', $attributeAvPostscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $attributeAvPostscriptum, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProduct object + * + * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function filterByOrderProduct($orderProduct, $comparison = null) + { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { + return $this + ->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProduct relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProduct'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProduct'); + } + + return $this; + } + + /** + * Use the OrderProduct relation OrderProduct object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query + */ + public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProduct($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderAttributeCombination $orderAttributeCombination Object to remove from the list of results + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function prune($orderAttributeCombination = null) + { + if ($orderAttributeCombination) { + $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $orderAttributeCombination->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderAttributeCombinationTableMap::clearInstancePool(); + OrderAttributeCombinationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderAttributeCombinationTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderAttributeCombinationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderAttributeCombinationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderAttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderAttributeCombinationTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderAttributeCombinationTableMap::CREATED_AT); + } + +} // OrderAttributeCombinationQuery diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php deleted file mode 100644 index b007c89e1..000000000 --- a/core/lib/Thelia/Model/Base/OrderProductQuery.php +++ /dev/null @@ -1,1022 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildOrderProduct A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, TITLE, DESCRIPTION, CHAPO, QUANTITY, PRICE, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildOrderProduct(); - $obj->hydrate($row); - OrderProductTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderProductTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderProductTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the order_id column - * - * Example usage: - * - * $query->filterByOrderId(1234); // WHERE order_id = 1234 - * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) - * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 - * - * - * @see filterByOrder() - * - * @param mixed $orderId 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByOrderId($orderId = null, $comparison = null) - { - if (is_array($orderId)) { - $useMinMax = false; - if (isset($orderId['min'])) { - $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($orderId['max'])) { - $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId, $comparison); - } - - /** - * Filter the query on the product_ref column - * - * Example usage: - * - * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue' - * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%' - * - * - * @param string $productRef 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByProductRef($productRef = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($productRef)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $productRef)) { - $productRef = str_replace('*', '%', $productRef); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductTableMap::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the quantity column - * - * Example usage: - * - * $query->filterByQuantity(1234); // WHERE quantity = 1234 - * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) - * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 - * - * - * @param mixed $quantity 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByQuantity($quantity = null, $comparison = null) - { - if (is_array($quantity)) { - $useMinMax = false; - if (isset($quantity['min'])) { - $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($quantity['max'])) { - $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity, $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 ChildOrderProductQuery 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(OrderProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($price['max'])) { - $this->addUsingAlias(OrderProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::PRICE, $price, $comparison); - } - - /** - * Filter the query on the tax column - * - * Example usage: - * - * $query->filterByTax(1234); // WHERE tax = 1234 - * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 - * - * - * @param mixed $tax 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByTax($tax = null, $comparison = null) - { - if (is_array($tax)) { - $useMinMax = false; - if (isset($tax['min'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); - } - - /** - * Filter the query on the parent column - * - * Example usage: - * - * $query->filterByParent(1234); // WHERE parent = 1234 - * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 - * - * - * @param mixed $parent 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 ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByParent($parent = null, $comparison = null) - { - if (is_array($parent)) { - $useMinMax = false; - if (isset($parent['min'])) { - $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($parent['max'])) { - $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::PARENT, $parent, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Order object - * - * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof \Thelia\Model\Order) { - return $this - ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->getId(), $comparison); - } elseif ($order instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\OrderFeature object - * - * @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function filterByOrderFeature($orderFeature, $comparison = null) - { - if ($orderFeature instanceof \Thelia\Model\OrderFeature) { - return $this - ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison); - } elseif ($orderFeature instanceof ObjectCollection) { - return $this - ->useOrderFeatureQuery() - ->filterByPrimaryKeys($orderFeature->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderFeature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderFeature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderFeature'); - } - - return $this; - } - - /** - * Use the OrderFeature relation OrderFeature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query - */ - public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrderFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery'); - } - - /** - * Exclude object from result - * - * @param ChildOrderProduct $orderProduct Object to remove from the list of results - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function prune($orderProduct = null) - { - if ($orderProduct) { - $this->addUsingAlias(OrderProductTableMap::ID, $orderProduct->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the order_product table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderProductTableMap::clearInstancePool(); - OrderProductTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildOrderProduct or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildOrderProduct object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(OrderProductTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - OrderProductTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - OrderProductTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderProductTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderProductTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderProductTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildOrderProductQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderProductTableMap::CREATED_AT); - } - -} // OrderProductQuery diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php similarity index 51% rename from core/lib/Thelia/Model/Map/OrderProductTableMap.php rename to core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php index 038d12863..f87e8d59e 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\OrderProduct; -use Thelia\Model\OrderProductQuery; +use Thelia\Model\OrderAttributeCombination; +use Thelia\Model\OrderAttributeCombinationQuery; /** - * This class defines the structure of the 'order_product' table. + * This class defines the structure of the 'order_attribute_combination' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\OrderProductQuery; * (i.e. if it's a text column type). * */ -class OrderProductTableMap extends TableMap +class OrderAttributeCombinationTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.OrderProductTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.OrderAttributeCombinationTableMap'; /** * The default database name for this class @@ -42,17 +42,17 @@ class OrderProductTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'order_product'; + const TABLE_NAME = 'order_attribute_combination'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\OrderProduct'; + const OM_CLASS = '\\Thelia\\Model\\OrderAttributeCombination'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.OrderProduct'; + const CLASS_DEFAULT = 'Thelia.Model.OrderAttributeCombination'; /** * The total number of columns @@ -72,62 +72,62 @@ class OrderProductTableMap extends TableMap /** * the column name for the ID field */ - const ID = 'order_product.ID'; + const ID = 'order_attribute_combination.ID'; /** - * the column name for the ORDER_ID field + * the column name for the ORDER_PRODUCT_ID field */ - const ORDER_ID = 'order_product.ORDER_ID'; + const ORDER_PRODUCT_ID = 'order_attribute_combination.ORDER_PRODUCT_ID'; /** - * the column name for the PRODUCT_REF field + * the column name for the ATTRIBUTE_TITLE field */ - const PRODUCT_REF = 'order_product.PRODUCT_REF'; + const ATTRIBUTE_TITLE = 'order_attribute_combination.ATTRIBUTE_TITLE'; /** - * the column name for the TITLE field + * the column name for the ATTRIBUTE_CHAPO field */ - const TITLE = 'order_product.TITLE'; + const ATTRIBUTE_CHAPO = 'order_attribute_combination.ATTRIBUTE_CHAPO'; /** - * the column name for the DESCRIPTION field + * the column name for the ATTRIBUTE_DESCRIPTION field */ - const DESCRIPTION = 'order_product.DESCRIPTION'; + const ATTRIBUTE_DESCRIPTION = 'order_attribute_combination.ATTRIBUTE_DESCRIPTION'; /** - * the column name for the CHAPO field + * the column name for the ATTRIBUTE_POSTSCRIPTUMN field */ - const CHAPO = 'order_product.CHAPO'; + const ATTRIBUTE_POSTSCRIPTUMN = 'order_attribute_combination.ATTRIBUTE_POSTSCRIPTUMN'; /** - * the column name for the QUANTITY field + * the column name for the ATTRIBUTE_AV_TITLE field */ - const QUANTITY = 'order_product.QUANTITY'; + const ATTRIBUTE_AV_TITLE = 'order_attribute_combination.ATTRIBUTE_AV_TITLE'; /** - * the column name for the PRICE field + * the column name for the ATTRIBUTE_AV_CHAPO field */ - const PRICE = 'order_product.PRICE'; + const ATTRIBUTE_AV_CHAPO = 'order_attribute_combination.ATTRIBUTE_AV_CHAPO'; /** - * the column name for the TAX field + * the column name for the ATTRIBUTE_AV_DESCRIPTION field */ - const TAX = 'order_product.TAX'; + const ATTRIBUTE_AV_DESCRIPTION = 'order_attribute_combination.ATTRIBUTE_AV_DESCRIPTION'; /** - * the column name for the PARENT field + * the column name for the ATTRIBUTE_AV_POSTSCRIPTUM field */ - const PARENT = 'order_product.PARENT'; + const ATTRIBUTE_AV_POSTSCRIPTUM = 'order_attribute_combination.ATTRIBUTE_AV_POSTSCRIPTUM'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'order_product.CREATED_AT'; + const CREATED_AT = 'order_attribute_combination.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_product.UPDATED_AT'; + const UPDATED_AT = 'order_attribute_combination.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -141,11 +141,11 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptumn', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptumn', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderAttributeCombinationTableMap::ID, OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderAttributeCombinationTableMap::CREATED_AT, OrderAttributeCombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUMN', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptumn', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); @@ -156,11 +156,11 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptumn' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptumn' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(OrderAttributeCombinationTableMap::ID => 0, OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN => 5, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderAttributeCombinationTableMap::CREATED_AT => 10, OrderAttributeCombinationTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUMN' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptumn' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); @@ -174,22 +174,22 @@ class OrderProductTableMap extends TableMap public function initialize() { // attributes - $this->setName('order_product'); - $this->setPhpName('OrderProduct'); - $this->setClassName('\\Thelia\\Model\\OrderProduct'); + $this->setName('order_attribute_combination'); + $this->setPhpName('OrderAttributeCombination'); + $this->setClassName('\\Thelia\\Model\\OrderAttributeCombination'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); - $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); - $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); - $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); + $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); + $this->addColumn('ATTRIBUTE_TITLE', 'AttributeTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_CHAPO', 'AttributeChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_DESCRIPTION', 'AttributeDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_POSTSCRIPTUMN', 'AttributePostscriptumn', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_TITLE', 'AttributeAvTitle', 'VARCHAR', true, 255, null); + $this->addColumn('ATTRIBUTE_AV_CHAPO', 'AttributeAvChapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_AV_DESCRIPTION', 'AttributeAvDescription', 'CLOB', false, null, null); + $this->addColumn('ATTRIBUTE_AV_POSTSCRIPTUM', 'AttributeAvPostscriptum', 'LONGVARCHAR', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -199,8 +199,7 @@ class OrderProductTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures'); + $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** @@ -215,15 +214,6 @@ class OrderProductTableMap extends TableMap 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), ); } // getBehaviors() - /** - * Method to invalidate the instance pool of all tables related to order_product * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderFeatureTableMap::clearInstancePool(); - } /** * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. @@ -281,7 +271,7 @@ class OrderProductTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? OrderProductTableMap::CLASS_DEFAULT : OrderProductTableMap::OM_CLASS; + return $withPrefix ? OrderAttributeCombinationTableMap::CLASS_DEFAULT : OrderAttributeCombinationTableMap::OM_CLASS; } /** @@ -295,21 +285,21 @@ class OrderProductTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (OrderProduct object, last column rank) + * @return array (OrderAttributeCombination object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) { + $key = OrderAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + OrderProductTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + OrderAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = OrderProductTableMap::OM_CLASS; + $cls = OrderAttributeCombinationTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - OrderProductTableMap::addInstanceToPool($obj, $key); + OrderAttributeCombinationTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -332,8 +322,8 @@ class OrderProductTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) { + $key = OrderAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -342,7 +332,7 @@ class OrderProductTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - OrderProductTableMap::addInstanceToPool($obj, $key); + OrderAttributeCombinationTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -363,29 +353,29 @@ class OrderProductTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(OrderProductTableMap::ID); - $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID); - $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF); - $criteria->addSelectColumn(OrderProductTableMap::TITLE); - $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); - $criteria->addSelectColumn(OrderProductTableMap::CHAPO); - $criteria->addSelectColumn(OrderProductTableMap::QUANTITY); - $criteria->addSelectColumn(OrderProductTableMap::PRICE); - $criteria->addSelectColumn(OrderProductTableMap::TAX); - $criteria->addSelectColumn(OrderProductTableMap::PARENT); - $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); - $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ID); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderAttributeCombinationTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ORDER_ID'); - $criteria->addSelectColumn($alias . '.PRODUCT_REF'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.QUANTITY'); - $criteria->addSelectColumn($alias . '.PRICE'); - $criteria->addSelectColumn($alias . '.TAX'); - $criteria->addSelectColumn($alias . '.PARENT'); + $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUMN'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_TITLE'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_CHAPO'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_DESCRIPTION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -400,7 +390,7 @@ class OrderProductTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME)->getTable(OrderProductTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(OrderAttributeCombinationTableMap::DATABASE_NAME)->getTable(OrderAttributeCombinationTableMap::TABLE_NAME); } /** @@ -408,16 +398,16 @@ class OrderProductTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(OrderProductTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new OrderProductTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderAttributeCombinationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderAttributeCombinationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderAttributeCombinationTableMap()); } } /** - * Performs a DELETE on the database, given a OrderProduct or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a OrderAttributeCombination or Criteria object OR a primary key value. * - * @param mixed $values Criteria or OrderProduct object or primary key or array of primary keys + * @param mixed $values Criteria or OrderAttributeCombination object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -428,25 +418,25 @@ class OrderProductTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\OrderProduct) { // it's a model object + } elseif ($values instanceof \Thelia\Model\OrderAttributeCombination) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); - $criteria->add(OrderProductTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(OrderAttributeCombinationTableMap::ID, (array) $values, Criteria::IN); } - $query = OrderProductQuery::create()->mergeWith($criteria); + $query = OrderAttributeCombinationQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { OrderProductTableMap::clearInstancePool(); + if ($values instanceof Criteria) { OrderAttributeCombinationTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { OrderProductTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { OrderAttributeCombinationTableMap::removeInstanceFromPool($singleval); } } @@ -454,20 +444,20 @@ class OrderProductTableMap extends TableMap } /** - * Deletes all rows from the order_product table. + * Deletes all rows from the order_attribute_combination table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return OrderProductQuery::create()->doDeleteAll($con); + return OrderAttributeCombinationQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a OrderProduct or Criteria object. + * Performs an INSERT on the database, given a OrderAttributeCombination or Criteria object. * - * @param mixed $criteria Criteria or OrderProduct object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or OrderAttributeCombination object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -476,22 +466,22 @@ class OrderProductTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from OrderProduct object + $criteria = $criteria->buildCriteria(); // build Criteria from OrderAttributeCombination object } - if ($criteria->containsKey(OrderProductTableMap::ID) && $criteria->keyContainsValue(OrderProductTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTableMap::ID.')'); + if ($criteria->containsKey(OrderAttributeCombinationTableMap::ID) && $criteria->keyContainsValue(OrderAttributeCombinationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAttributeCombinationTableMap::ID.')'); } // Set the correct dbName - $query = OrderProductQuery::create()->mergeWith($criteria); + $query = OrderAttributeCombinationQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -507,7 +497,7 @@ class OrderProductTableMap extends TableMap return $pk; } -} // OrderProductTableMap +} // OrderAttributeCombinationTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -OrderProductTableMap::buildTableMap(); +OrderAttributeCombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/OrderAttributeCombination.php b/core/lib/Thelia/Model/OrderAttributeCombination.php new file mode 100644 index 000000000..896cda895 --- /dev/null +++ b/core/lib/Thelia/Model/OrderAttributeCombination.php @@ -0,0 +1,10 @@ + - + + - + + + + + + - + @@ -626,11 +632,17 @@ - +
- - + + + + + + + + From 6e9af5940361ecb446c3b2874a2366467a5b15b3 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 19 Sep 2013 19:56:59 +0200 Subject: [PATCH 2/6] order creation --- core/lib/Thelia/Action/Order.php | 111 +- .../Controller/Front/BaseFrontController.php | 6 +- .../Controller/Front/OrderController.php | 5 +- core/lib/Thelia/Core/Event/TheliaEvents.php | 5 +- core/lib/Thelia/Exception/OrderException.php | 3 + core/lib/Thelia/Form/OrderDelivery.php | 2 +- core/lib/Thelia/Model/Base/OrderProduct.php | 2466 +++++++++++++++++ .../Thelia/Model/Base/OrderProductQuery.php | 1244 +++++++++ .../Thelia/Model/Map/OrderProductTableMap.php | 561 ++++ core/lib/Thelia/Model/Order.php | 180 +- core/lib/Thelia/Model/OrderProduct.php | 31 + core/lib/Thelia/Model/OrderProductQuery.php | 21 + 12 files changed, 4622 insertions(+), 13 deletions(-) create mode 100644 core/lib/Thelia/Model/Base/OrderProduct.php create mode 100644 core/lib/Thelia/Model/Base/OrderProductQuery.php create mode 100644 core/lib/Thelia/Model/Map/OrderProductTableMap.php create mode 100644 core/lib/Thelia/Model/OrderProduct.php create mode 100644 core/lib/Thelia/Model/OrderProductQuery.php diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index c5926acea..fda052316 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -23,12 +23,23 @@ namespace Thelia\Action; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Propel\Runtime\Exception\PropelException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Base\AddressQuery; +use Thelia\Exception\OrderException; +use Thelia\Model\AttributeAvI18n; +use Thelia\Model\AttributeAvI18nQuery; +use Thelia\Model\AttributeI18n; +use Thelia\Model\AttributeI18nQuery; +use Thelia\Model\AttributeQuery; +use Thelia\Model\AddressQuery; +use Thelia\Model\OrderAttributeCombination; +use Thelia\Model\ProductI18nQuery; +use Thelia\Model\Lang; use Thelia\Model\ModuleQuery; use Thelia\Model\OrderProduct; use Thelia\Model\OrderStatus; @@ -36,6 +47,7 @@ use Thelia\Model\Map\OrderTableMap; use Thelia\Model\OrderAddress; use Thelia\Model\OrderStatusQuery; use Thelia\Model\ConfigQuery; +use Thelia\Model\ProductI18n; /** * @@ -167,15 +179,68 @@ class Order extends BaseAction implements EventSubscriberInterface $placedOrder->save($con); - /* fulfill order_products and decrease stock // @todo + dispatch event */ + /* fulfill order_products and decrease stock */ foreach($cartItems as $cartItem) { + $product = $cartItem->getProduct(); + + /* get customer translation */ + $productI18n = $this->getI18n(ProductI18nQuery::create(), new ProductI18n(), $product->getId()); + + $pse = $cartItem->getProductSaleElements(); + + /* check still in stock */ + if($cartItem->getQuantity() > $pse->getQuantity()) { + $e = new OrderException("Not enough stock", OrderException::NOT_ENOUGH_STOCK); + $e->cartItem = $cartItem; + throw $e; + } + + /* decrease stock */ + $pse->setQuantity( + $pse->getQuantity() - $cartItem->getQuantity() + ); + $pse->save(); + $orderProduct = new OrderProduct(); $orderProduct ->setOrderId($placedOrder->getId()) + ->setProductRef($product->getRef()) + ->setProductSaleElementsRef($pse->getRef()) + ->setTitle($productI18n->getTitle()) + ->setChapo($productI18n->getChapo()) + ->setDescription($productI18n->getDescription()) + ->setPostscriptum($productI18n->getPostscriptum()) + ->setQuantity($cartItem->getQuantity()) + ->setPrice($cartItem->getPrice()) + ->setPromoPrice($cartItem->getPromoPrice()) + ->setWasNew($pse->getNewness()) + ->setWasInPromo($cartItem->getPromo()) + ->setWeight($pse->getWeight()) ; + $orderProduct->setDispatcher($this->getDispatcher()); + $orderProduct->save(); - $in = true; + /* fulfill order_attribute_combination and decrease stock */ + foreach($pse->getAttributeCombinations() as $attributeCombination) { + $attribute = $this->getI18n(AttributeI18nQuery::create(), new AttributeI18n(), $attributeCombination->getAttributeId()); + $attributeAv = $this->getI18n(AttributeAvI18nQuery::create(), new AttributeAvI18n(), $attributeCombination->getAttributeAvId()); + + $orderAttributeCombination = new OrderAttributeCombination(); + $orderAttributeCombination + ->setOrderProductId($orderProduct->getId()) + ->setAttributeTitle($attribute->getTitle()) + ->setAttributeChapo($attribute->getChapo()) + ->setAttributeDescription($attribute->getDescription()) + ->setAttributePostscriptumn($attribute->getPostscriptum()) + ->setAttributeAvTitle($attributeAv->getTitle()) + ->setAttributeAvChapo($attributeAv->getChapo()) + ->setAttributeAvDescription($attributeAv->getDescription()) + ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) + ; + + $orderAttributeCombination->save(); + } } /* discount @todo */ @@ -239,7 +304,7 @@ class Order extends BaseAction implements EventSubscriberInterface TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128), TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), TheliaEvents::ORDER_PAY => array("create", 128), - TheliaEvents::ORDER_SET_REFERENCE => array("setReference", 128), + TheliaEvents::ORDER_BEFORE_CREATE => array("setReference", 128), ); } @@ -272,4 +337,42 @@ class Order extends BaseAction implements EventSubscriberInterface return $request->getSession(); } + + /** + * @param ModelCriteria $query + * @param ActiveRecordInterface $object + * @param $id + * @param array $needed = array('Title') + * + * @return ProductI18n + */ + protected function getI18n(ModelCriteria $query, ActiveRecordInterface $object, $id, $needed = array('Title')) + { + $i18n = $query + ->filterById($id) + ->filterByLocale( + $this->getSession()->getLang()->getLocale() + )->findOne(); + /* or default translation */ + if(null === $i18n) { + $i18n = $query + ->filterById($id) + ->filterByLocale( + Lang::getDefaultLanguage()->getLocale() + )->findOne(); + } + if(null === $i18n) { // @todo something else ? + $i18n = $object; + foreach($needed as $need) { + $method = sprintf('get%s', $need); + if(method_exists($i18n, $method)) { + $i18n->$method('DEFAULT ' . strtoupper($need)); + } else { + // @todo throw sg ? + } + } + } + + return $i18n; + } } diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index b8a7c6a98..152c2c10e 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -24,6 +24,8 @@ namespace Thelia\Controller\Front; use Symfony\Component\Routing\Router; use Thelia\Controller\BaseController; +use Thelia\Model\AddressQuery; +use Thelia\Model\ModuleQuery; use Thelia\Tools\URL; class BaseFrontController extends BaseController @@ -69,7 +71,7 @@ class BaseFrontController extends BaseController protected function checkValidDelivery() { $order = $this->getSession()->getOrder(); - if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) { + if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) { $this->redirectToRoute("order.delivery"); } } @@ -77,7 +79,7 @@ class BaseFrontController extends BaseController protected function checkValidInvoice() { $order = $this->getSession()->getOrder(); - if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId()) { + if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) { $this->redirectToRoute("order.invoice"); } } diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php index 53d1e070b..4dd678a82 100755 --- a/core/lib/Thelia/Controller/Front/OrderController.php +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -78,11 +78,8 @@ class OrderController extends BaseFrontController throw new \Exception("Delivery module cannot be use with selected delivery address"); } - /* try to get postage amount */ + /* get postage amount */ $moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace()); - if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { - throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode())); - } $moduleInstance = $moduleReflection->newInstance(); $postage = $moduleInstance->getPostage($deliveryAddress->getCountry()); diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 3b049bfef..80d87cc8c 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -220,7 +220,10 @@ final class TheliaEvents const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress"; const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule"; const ORDER_PAY = "action.order.pay"; - const ORDER_SET_REFERENCE = "action.order.setReference"; + const ORDER_BEFORE_CREATE = "action.order.beforeCreate"; + const ORDER_AFTER_CREATE = "action.order.afterCreate"; + const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; + const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; /** * Sent on image processing diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php index 70fd21c01..68eb36474 100755 --- a/core/lib/Thelia/Exception/OrderException.php +++ b/core/lib/Thelia/Exception/OrderException.php @@ -30,6 +30,7 @@ class OrderException extends \RuntimeException */ public $cartRoute = "cart.view"; public $orderDeliveryRoute = "order.delivery"; + public $cartItem = null; public $arguments = array(); @@ -39,6 +40,8 @@ class OrderException extends \RuntimeException const UNDEFINED_DELIVERY = 200; + const NOT_ENOUGH_STOCK = 300; + public function __construct($message, $code = null, $arguments = array(), $previous = null) { if(is_array($arguments)) { diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php index e23ae92b2..8cddb5bd9 100755 --- a/core/lib/Thelia/Form/OrderDelivery.php +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -80,7 +80,7 @@ class OrderDelivery extends BaseForm ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) ->filterByActivate(1) ->filterById($value) - ->find(); + ->findOne(); if(null === $module) { $context->addViolation("Delivery module ID not found"); diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php new file mode 100644 index 000000000..3d72eee6e --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -0,0 +1,2466 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProduct instance. If + * obj is an instance of OrderProduct, delegates to + * equals(OrderProduct). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProduct The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProduct The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [order_id] column value. + * + * @return int + */ + public function getOrderId() + { + + return $this->order_id; + } + + /** + * Get the [product_ref] column value. + * + * @return string + */ + public function getProductRef() + { + + return $this->product_ref; + } + + /** + * Get the [product_sale_elements_ref] column value. + * + * @return string + */ + public function getProductSaleElementsRef() + { + + return $this->product_sale_elements_ref; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Get the [quantity] column value. + * + * @return double + */ + public function getQuantity() + { + + return $this->quantity; + } + + /** + * Get the [price] column value. + * + * @return double + */ + public function getPrice() + { + + return $this->price; + } + + /** + * Get the [promo_price] column value. + * + * @return string + */ + public function getPromoPrice() + { + + return $this->promo_price; + } + + /** + * Get the [was_new] column value. + * + * @return int + */ + public function getWasNew() + { + + return $this->was_new; + } + + /** + * Get the [was_in_promo] column value. + * + * @return int + */ + public function getWasInPromo() + { + + return $this->was_in_promo; + } + + /** + * Get the [weight] column value. + * + * @return string + */ + public function getWeight() + { + + return $this->weight; + } + + /** + * Get the [tax] column value. + * + * @return double + */ + public function getTax() + { + + return $this->tax; + } + + /** + * Get the [parent] column value. + * not managed yet + * @return int + */ + public function getParent() + { + + return $this->parent; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderProductTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setOrderId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_id !== $v) { + $this->order_id = $v; + $this->modifiedColumns[] = OrderProductTableMap::ORDER_ID; + } + + if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { + $this->aOrder = null; + } + + + return $this; + } // setOrderId() + + /** + * Set the value of [product_ref] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setProductRef($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->product_ref !== $v) { + $this->product_ref = $v; + $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_REF; + } + + + return $this; + } // setProductRef() + + /** + * Set the value of [product_sale_elements_ref] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setProductSaleElementsRef($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->product_sale_elements_ref !== $v) { + $this->product_sale_elements_ref = $v; + $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF; + } + + + return $this; + } // setProductSaleElementsRef() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = OrderProductTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = OrderProductTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = OrderProductTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = OrderProductTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Set the value of [quantity] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setQuantity($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->quantity !== $v) { + $this->quantity = $v; + $this->modifiedColumns[] = OrderProductTableMap::QUANTITY; + } + + + return $this; + } // setQuantity() + + /** + * Set the value of [price] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProduct 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[] = OrderProductTableMap::PRICE; + } + + + return $this; + } // setPrice() + + /** + * Set the value of [promo_price] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setPromoPrice($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->promo_price !== $v) { + $this->promo_price = $v; + $this->modifiedColumns[] = OrderProductTableMap::PROMO_PRICE; + } + + + return $this; + } // setPromoPrice() + + /** + * Set the value of [was_new] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasNew($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_new !== $v) { + $this->was_new = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_NEW; + } + + + return $this; + } // setWasNew() + + /** + * Set the value of [was_in_promo] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWasInPromo($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->was_in_promo !== $v) { + $this->was_in_promo = $v; + $this->modifiedColumns[] = OrderProductTableMap::WAS_IN_PROMO; + } + + + return $this; + } // setWasInPromo() + + /** + * Set the value of [weight] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setWeight($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->weight !== $v) { + $this->weight = $v; + $this->modifiedColumns[] = OrderProductTableMap::WEIGHT; + } + + + return $this; + } // setWeight() + + /** + * Set the value of [tax] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTax($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->tax !== $v) { + $this->tax = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX; + } + + + return $this; + } // setTax() + + /** + * Set the value of [parent] column. + * not managed yet + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setParent($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->parent !== $v) { + $this->parent = $v; + $this->modifiedColumns[] = OrderProductTableMap::PARENT; + } + + + return $this; + } // setParent() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('ProductSaleElementsRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_sale_elements_ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $this->quantity = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('PromoPrice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_price = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('WasNew', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_new = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderProductTableMap::translateFieldName('WasInPromo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->was_in_promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->weight = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::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 ? 17 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 18; // 18 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { + $this->aOrder = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrder = null; + $this->collOrderAttributeCombinations = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderProduct::setDeleted() + * @see OrderProduct::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderProductQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderProductTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderProductTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aOrder !== null) { + if ($this->aOrder->isModified() || $this->aOrder->isNew()) { + $affectedRows += $this->aOrder->save($con); + } + $this->setOrder($this->aOrder); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->orderAttributeCombinationsScheduledForDeletion !== null) { + if (!$this->orderAttributeCombinationsScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderAttributeCombinationQuery::create() + ->filterByPrimaryKeys($this->orderAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->orderAttributeCombinationsScheduledForDeletion = null; + } + } + + if ($this->collOrderAttributeCombinations !== null) { + foreach ($this->collOrderAttributeCombinations as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderProductTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderProductTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_ID'; + } + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_REF'; + } + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_SALE_ELEMENTS_REF'; + } + if ($this->isColumnModified(OrderProductTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) { + $modifiedColumns[':p' . $index++] = 'QUANTITY'; + } + if ($this->isColumnModified(OrderProductTableMap::PRICE)) { + $modifiedColumns[':p' . $index++] = 'PRICE'; + } + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) { + $modifiedColumns[':p' . $index++] = 'PROMO_PRICE'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) { + $modifiedColumns[':p' . $index++] = 'WAS_NEW'; + } + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) { + $modifiedColumns[':p' . $index++] = 'WAS_IN_PROMO'; + } + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'WEIGHT'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX)) { + $modifiedColumns[':p' . $index++] = 'TAX'; + } + if ($this->isColumnModified(OrderProductTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; + } + if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO order_product (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'ORDER_ID': + $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); + break; + case 'PRODUCT_REF': + $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); + break; + case 'PRODUCT_SALE_ELEMENTS_REF': + $stmt->bindValue($identifier, $this->product_sale_elements_ref, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + case 'QUANTITY': + $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); + 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 'WAS_NEW': + $stmt->bindValue($identifier, $this->was_new, PDO::PARAM_INT); + break; + case 'WAS_IN_PROMO': + $stmt->bindValue($identifier, $this->was_in_promo, PDO::PARAM_INT); + break; + case 'WEIGHT': + $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); + break; + case 'TAX': + $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); + break; + case 'PARENT': + $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getOrderId(); + break; + case 2: + return $this->getProductRef(); + break; + case 3: + return $this->getProductSaleElementsRef(); + break; + case 4: + return $this->getTitle(); + break; + case 5: + return $this->getChapo(); + break; + case 6: + return $this->getDescription(); + break; + case 7: + return $this->getPostscriptum(); + break; + case 8: + return $this->getQuantity(); + break; + case 9: + return $this->getPrice(); + break; + case 10: + return $this->getPromoPrice(); + break; + case 11: + return $this->getWasNew(); + break; + case 12: + return $this->getWasInPromo(); + break; + case 13: + return $this->getWeight(); + break; + case 14: + return $this->getTax(); + break; + case 15: + return $this->getParent(); + break; + case 16: + return $this->getCreatedAt(); + break; + case 17: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()] = true; + $keys = OrderProductTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getOrderId(), + $keys[2] => $this->getProductRef(), + $keys[3] => $this->getProductSaleElementsRef(), + $keys[4] => $this->getTitle(), + $keys[5] => $this->getChapo(), + $keys[6] => $this->getDescription(), + $keys[7] => $this->getPostscriptum(), + $keys[8] => $this->getQuantity(), + $keys[9] => $this->getPrice(), + $keys[10] => $this->getPromoPrice(), + $keys[11] => $this->getWasNew(), + $keys[12] => $this->getWasInPromo(), + $keys[13] => $this->getWeight(), + $keys[14] => $this->getTax(), + $keys[15] => $this->getParent(), + $keys[16] => $this->getCreatedAt(), + $keys[17] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aOrder) { + $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->collOrderAttributeCombinations) { + $result['OrderAttributeCombinations'] = $this->collOrderAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setOrderId($value); + break; + case 2: + $this->setProductRef($value); + break; + case 3: + $this->setProductSaleElementsRef($value); + break; + case 4: + $this->setTitle($value); + break; + case 5: + $this->setChapo($value); + break; + case 6: + $this->setDescription($value); + break; + case 7: + $this->setPostscriptum($value); + break; + case 8: + $this->setQuantity($value); + break; + case 9: + $this->setPrice($value); + break; + case 10: + $this->setPromoPrice($value); + break; + case 11: + $this->setWasNew($value); + break; + case 12: + $this->setWasInPromo($value); + break; + case 13: + $this->setWeight($value); + break; + case 14: + $this->setTax($value); + break; + case 15: + $this->setParent($value); + break; + case 16: + $this->setCreatedAt($value); + break; + case 17: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = OrderProductTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setProductSaleElementsRef($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setTitle($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDescription($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setPostscriptum($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setPrice($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setPromoPrice($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setWasNew($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setWasInPromo($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setWeight($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setTax($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setParent($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id); + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref); + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF)) $criteria->add(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $this->product_sale_elements_ref); + if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title); + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTableMap::POSTSCRIPTUM)) $criteria->add(OrderProductTableMap::POSTSCRIPTUM, $this->postscriptum); + if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity); + if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price); + if ($this->isColumnModified(OrderProductTableMap::PROMO_PRICE)) $criteria->add(OrderProductTableMap::PROMO_PRICE, $this->promo_price); + if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) $criteria->add(OrderProductTableMap::WAS_NEW, $this->was_new); + if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) $criteria->add(OrderProductTableMap::WAS_IN_PROMO, $this->was_in_promo); + if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) $criteria->add(OrderProductTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); + if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); + if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + $criteria->add(OrderProductTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\OrderProduct (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setOrderId($this->getOrderId()); + $copyObj->setProductRef($this->getProductRef()); + $copyObj->setProductSaleElementsRef($this->getProductSaleElementsRef()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setPostscriptum($this->getPostscriptum()); + $copyObj->setQuantity($this->getQuantity()); + $copyObj->setPrice($this->getPrice()); + $copyObj->setPromoPrice($this->getPromoPrice()); + $copyObj->setWasNew($this->getWasNew()); + $copyObj->setWasInPromo($this->getWasInPromo()); + $copyObj->setWeight($this->getWeight()); + $copyObj->setTax($this->getTax()); + $copyObj->setParent($this->getParent()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getOrderAttributeCombinations() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderAttributeCombination($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProduct Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildOrder object. + * + * @param ChildOrder $v + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + * @throws PropelException + */ + public function setOrder(ChildOrder $v = null) + { + if ($v === null) { + $this->setOrderId(NULL); + } else { + $this->setOrderId($v->getId()); + } + + $this->aOrder = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildOrder object, it will not be re-added. + if ($v !== null) { + $v->addOrderProduct($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrder The associated ChildOrder object. + * @throws PropelException + */ + public function getOrder(ConnectionInterface $con = null) + { + if ($this->aOrder === null && ($this->order_id !== null)) { + $this->aOrder = ChildOrderQuery::create()->findPk($this->order_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aOrder->addOrderProducts($this); + */ + } + + return $this->aOrder; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('OrderAttributeCombination' == $relationName) { + return $this->initOrderAttributeCombinations(); + } + } + + /** + * Clears out the collOrderAttributeCombinations collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrderAttributeCombinations() + */ + public function clearOrderAttributeCombinations() + { + $this->collOrderAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrderAttributeCombinations collection loaded partially. + */ + public function resetPartialOrderAttributeCombinations($v = true) + { + $this->collOrderAttributeCombinationsPartial = $v; + } + + /** + * Initializes the collOrderAttributeCombinations collection. + * + * By default this just sets the collOrderAttributeCombinations collection to an empty array (like clearcollOrderAttributeCombinations()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrderAttributeCombinations($overrideExisting = true) + { + if (null !== $this->collOrderAttributeCombinations && !$overrideExisting) { + return; + } + $this->collOrderAttributeCombinations = new ObjectCollection(); + $this->collOrderAttributeCombinations->setModel('\Thelia\Model\OrderAttributeCombination'); + } + + /** + * Gets an array of ChildOrderAttributeCombination objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildOrderProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderAttributeCombination[] List of ChildOrderAttributeCombination objects + * @throws PropelException + */ + public function getOrderAttributeCombinations($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrderAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderAttributeCombinations) { + // return empty collection + $this->initOrderAttributeCombinations(); + } else { + $collOrderAttributeCombinations = ChildOrderAttributeCombinationQuery::create(null, $criteria) + ->filterByOrderProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrderAttributeCombinationsPartial && count($collOrderAttributeCombinations)) { + $this->initOrderAttributeCombinations(false); + + foreach ($collOrderAttributeCombinations as $obj) { + if (false == $this->collOrderAttributeCombinations->contains($obj)) { + $this->collOrderAttributeCombinations->append($obj); + } + } + + $this->collOrderAttributeCombinationsPartial = true; + } + + $collOrderAttributeCombinations->getInternalIterator()->rewind(); + + return $collOrderAttributeCombinations; + } + + if ($partial && $this->collOrderAttributeCombinations) { + foreach ($this->collOrderAttributeCombinations as $obj) { + if ($obj->isNew()) { + $collOrderAttributeCombinations[] = $obj; + } + } + } + + $this->collOrderAttributeCombinations = $collOrderAttributeCombinations; + $this->collOrderAttributeCombinationsPartial = false; + } + } + + return $this->collOrderAttributeCombinations; + } + + /** + * Sets a collection of OrderAttributeCombination objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $orderAttributeCombinations A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function setOrderAttributeCombinations(Collection $orderAttributeCombinations, ConnectionInterface $con = null) + { + $orderAttributeCombinationsToDelete = $this->getOrderAttributeCombinations(new Criteria(), $con)->diff($orderAttributeCombinations); + + + $this->orderAttributeCombinationsScheduledForDeletion = $orderAttributeCombinationsToDelete; + + foreach ($orderAttributeCombinationsToDelete as $orderAttributeCombinationRemoved) { + $orderAttributeCombinationRemoved->setOrderProduct(null); + } + + $this->collOrderAttributeCombinations = null; + foreach ($orderAttributeCombinations as $orderAttributeCombination) { + $this->addOrderAttributeCombination($orderAttributeCombination); + } + + $this->collOrderAttributeCombinations = $orderAttributeCombinations; + $this->collOrderAttributeCombinationsPartial = false; + + return $this; + } + + /** + * Returns the number of related OrderAttributeCombination objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related OrderAttributeCombination objects. + * @throws PropelException + */ + public function countOrderAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrderAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderAttributeCombinations) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrderAttributeCombinations()); + } + + $query = ChildOrderAttributeCombinationQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderProduct($this) + ->count($con); + } + + return count($this->collOrderAttributeCombinations); + } + + /** + * Method called to associate a ChildOrderAttributeCombination object to this object + * through the ChildOrderAttributeCombination foreign key attribute. + * + * @param ChildOrderAttributeCombination $l ChildOrderAttributeCombination + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function addOrderAttributeCombination(ChildOrderAttributeCombination $l) + { + if ($this->collOrderAttributeCombinations === null) { + $this->initOrderAttributeCombinations(); + $this->collOrderAttributeCombinationsPartial = true; + } + + if (!in_array($l, $this->collOrderAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderAttributeCombination($l); + } + + return $this; + } + + /** + * @param OrderAttributeCombination $orderAttributeCombination The orderAttributeCombination object to add. + */ + protected function doAddOrderAttributeCombination($orderAttributeCombination) + { + $this->collOrderAttributeCombinations[]= $orderAttributeCombination; + $orderAttributeCombination->setOrderProduct($this); + } + + /** + * @param OrderAttributeCombination $orderAttributeCombination The orderAttributeCombination object to remove. + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function removeOrderAttributeCombination($orderAttributeCombination) + { + if ($this->getOrderAttributeCombinations()->contains($orderAttributeCombination)) { + $this->collOrderAttributeCombinations->remove($this->collOrderAttributeCombinations->search($orderAttributeCombination)); + if (null === $this->orderAttributeCombinationsScheduledForDeletion) { + $this->orderAttributeCombinationsScheduledForDeletion = clone $this->collOrderAttributeCombinations; + $this->orderAttributeCombinationsScheduledForDeletion->clear(); + } + $this->orderAttributeCombinationsScheduledForDeletion[]= clone $orderAttributeCombination; + $orderAttributeCombination->setOrderProduct(null); + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->order_id = null; + $this->product_ref = null; + $this->product_sale_elements_ref = null; + $this->title = null; + $this->chapo = null; + $this->description = null; + $this->postscriptum = null; + $this->quantity = null; + $this->price = null; + $this->promo_price = null; + $this->was_new = null; + $this->was_in_promo = null; + $this->weight = null; + $this->tax = null; + $this->parent = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collOrderAttributeCombinations) { + foreach ($this->collOrderAttributeCombinations as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + if ($this->collOrderAttributeCombinations instanceof Collection) { + $this->collOrderAttributeCombinations->clearIterator(); + } + $this->collOrderAttributeCombinations = null; + $this->aOrder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderProductTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php new file mode 100644 index 000000000..b471fc359 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -0,0 +1,1244 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProduct A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProduct(); + $obj->hydrate($row); + OrderProductTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(OrderProductTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(OrderProductTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(OrderProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_id column + * + * Example usage: + * + * $query->filterByOrderId(1234); // WHERE order_id = 1234 + * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 + * + * + * @see filterByOrder() + * + * @param mixed $orderId 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrderId($orderId = null, $comparison = null) + { + if (is_array($orderId)) { + $useMinMax = false; + if (isset($orderId['min'])) { + $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderId['max'])) { + $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId, $comparison); + } + + /** + * Filter the query on the product_ref column + * + * Example usage: + * + * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue' + * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%' + * + * + * @param string $productRef 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByProductRef($productRef = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($productRef)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $productRef)) { + $productRef = str_replace('*', '%', $productRef); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison); + } + + /** + * Filter the query on the product_sale_elements_ref column + * + * Example usage: + * + * $query->filterByProductSaleElementsRef('fooValue'); // WHERE product_sale_elements_ref = 'fooValue' + * $query->filterByProductSaleElementsRef('%fooValue%'); // WHERE product_sale_elements_ref LIKE '%fooValue%' + * + * + * @param string $productSaleElementsRef 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByProductSaleElementsRef($productSaleElementsRef = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($productSaleElementsRef)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $productSaleElementsRef)) { + $productSaleElementsRef = str_replace('*', '%', $productSaleElementsRef); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $productSaleElementsRef, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query on the quantity column + * + * Example usage: + * + * $query->filterByQuantity(1234); // WHERE quantity = 1234 + * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) + * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 + * + * + * @param mixed $quantity 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByQuantity($quantity = null, $comparison = null) + { + if (is_array($quantity)) { + $useMinMax = false; + if (isset($quantity['min'])) { + $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($quantity['max'])) { + $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity, $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 ChildOrderProductQuery 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(OrderProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($price['max'])) { + $this->addUsingAlias(OrderProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PRICE, $price, $comparison); + } + + /** + * Filter the query on the promo_price column + * + * Example usage: + * + * $query->filterByPromoPrice('fooValue'); // WHERE promo_price = 'fooValue' + * $query->filterByPromoPrice('%fooValue%'); // WHERE promo_price LIKE '%fooValue%' + * + * + * @param string $promoPrice 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByPromoPrice($promoPrice = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($promoPrice)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $promoPrice)) { + $promoPrice = str_replace('*', '%', $promoPrice); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PROMO_PRICE, $promoPrice, $comparison); + } + + /** + * Filter the query on the was_new column + * + * Example usage: + * + * $query->filterByWasNew(1234); // WHERE was_new = 1234 + * $query->filterByWasNew(array(12, 34)); // WHERE was_new IN (12, 34) + * $query->filterByWasNew(array('min' => 12)); // WHERE was_new > 12 + * + * + * @param mixed $wasNew 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWasNew($wasNew = null, $comparison = null) + { + if (is_array($wasNew)) { + $useMinMax = false; + if (isset($wasNew['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($wasNew['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew, $comparison); + } + + /** + * Filter the query on the was_in_promo column + * + * Example usage: + * + * $query->filterByWasInPromo(1234); // WHERE was_in_promo = 1234 + * $query->filterByWasInPromo(array(12, 34)); // WHERE was_in_promo IN (12, 34) + * $query->filterByWasInPromo(array('min' => 12)); // WHERE was_in_promo > 12 + * + * + * @param mixed $wasInPromo 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWasInPromo($wasInPromo = null, $comparison = null) + { + if (is_array($wasInPromo)) { + $useMinMax = false; + if (isset($wasInPromo['min'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($wasInPromo['max'])) { + $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo, $comparison); + } + + /** + * Filter the query on the weight column + * + * Example usage: + * + * $query->filterByWeight('fooValue'); // WHERE weight = 'fooValue' + * $query->filterByWeight('%fooValue%'); // WHERE weight LIKE '%fooValue%' + * + * + * @param string $weight 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByWeight($weight = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($weight)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $weight)) { + $weight = str_replace('*', '%', $weight); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison); + } + + /** + * Filter the query on the tax column + * + * Example usage: + * + * $query->filterByTax(1234); // WHERE tax = 1234 + * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) + * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 + * + * + * @param mixed $tax 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTax($tax = null, $comparison = null) + { + if (is_array($tax)) { + $useMinMax = false; + if (isset($tax['min'])) { + $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($tax['max'])) { + $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); + } + + /** + * Filter the query on the parent column + * + * Example usage: + * + * $query->filterByParent(1234); // WHERE parent = 1234 + * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 + * + * + * @param mixed $parent 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByParent($parent = null, $comparison = null) + { + if (is_array($parent)) { + $useMinMax = false; + if (isset($parent['min'])) { + $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($parent['max'])) { + $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::PARENT, $parent, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrder($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->getId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Order relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Order'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Order'); + } + + return $this; + } + + /** + * Use the Order relation Order object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\OrderAttributeCombination object + * + * @param \Thelia\Model\OrderAttributeCombination|ObjectCollection $orderAttributeCombination the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrderAttributeCombination($orderAttributeCombination, $comparison = null) + { + if ($orderAttributeCombination instanceof \Thelia\Model\OrderAttributeCombination) { + return $this + ->addUsingAlias(OrderProductTableMap::ID, $orderAttributeCombination->getOrderProductId(), $comparison); + } elseif ($orderAttributeCombination instanceof ObjectCollection) { + return $this + ->useOrderAttributeCombinationQuery() + ->filterByPrimaryKeys($orderAttributeCombination->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderAttributeCombination() only accepts arguments of type \Thelia\Model\OrderAttributeCombination or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderAttributeCombination relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function joinOrderAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderAttributeCombination'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderAttributeCombination'); + } + + return $this; + } + + /** + * Use the OrderAttributeCombination relation OrderAttributeCombination object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderAttributeCombinationQuery A secondary query class using the current class as primary query + */ + public function useOrderAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderAttributeCombination($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderAttributeCombination', '\Thelia\Model\OrderAttributeCombinationQuery'); + } + + /** + * Exclude object from result + * + * @param ChildOrderProduct $orderProduct Object to remove from the list of results + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function prune($orderProduct = null) + { + if ($orderProduct) { + $this->addUsingAlias(OrderProductTableMap::ID, $orderProduct->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the order_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductTableMap::clearInstancePool(); + OrderProductTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + OrderProductTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTableMap::CREATED_AT); + } + +} // OrderProductQuery diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php new file mode 100644 index 000000000..3820ad081 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -0,0 +1,561 @@ + array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'tax', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax', 'parent', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'Tax' => 14, 'Parent' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'tax' => 14, 'parent' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX => 14, OrderProductTableMap::PARENT => 15, OrderProductTableMap::CREATED_AT => 16, OrderProductTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX' => 14, 'PARENT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax' => 14, 'parent' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('order_product'); + $this->setPhpName('OrderProduct'); + $this->setClassName('\\Thelia\\Model\\OrderProduct'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); + $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', true, 255, null); + $this->addColumn('PRODUCT_SALE_ELEMENTS_REF', 'ProductSaleElementsRef', 'VARCHAR', true, 255, null); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); + $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null); + $this->addColumn('PROMO_PRICE', 'PromoPrice', 'VARCHAR', false, 45, null); + $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null); + $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null); + $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null); + $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); + $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('OrderAttributeCombination', '\\Thelia\\Model\\OrderAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderAttributeCombinations'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to order_product * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderAttributeCombinationTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + 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) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductTableMap::CLASS_DEFAULT : OrderProductTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (OrderProduct object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + OrderProductTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(OrderProductTableMap::ID); + $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID); + $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF); + $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF); + $criteria->addSelectColumn(OrderProductTableMap::TITLE); + $criteria->addSelectColumn(OrderProductTableMap::CHAPO); + $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTableMap::POSTSCRIPTUM); + $criteria->addSelectColumn(OrderProductTableMap::QUANTITY); + $criteria->addSelectColumn(OrderProductTableMap::PRICE); + $criteria->addSelectColumn(OrderProductTableMap::PROMO_PRICE); + $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW); + $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO); + $criteria->addSelectColumn(OrderProductTableMap::WEIGHT); + $criteria->addSelectColumn(OrderProductTableMap::TAX); + $criteria->addSelectColumn(OrderProductTableMap::PARENT); + $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.ORDER_ID'); + $criteria->addSelectColumn($alias . '.PRODUCT_REF'); + $criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_REF'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + $criteria->addSelectColumn($alias . '.QUANTITY'); + $criteria->addSelectColumn($alias . '.PRICE'); + $criteria->addSelectColumn($alias . '.PROMO_PRICE'); + $criteria->addSelectColumn($alias . '.WAS_NEW'); + $criteria->addSelectColumn($alias . '.WAS_IN_PROMO'); + $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.TAX'); + $criteria->addSelectColumn($alias . '.PARENT'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME)->getTable(OrderProductTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a OrderProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or OrderProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProduct) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + $criteria->add(OrderProductTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProduct or Criteria object. + * + * @param mixed $criteria Criteria or OrderProduct object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProduct object + } + + if ($criteria->containsKey(OrderProductTableMap::ID) && $criteria->keyContainsValue(OrderProductTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index c5d03b7e7..f730c8853 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -3,9 +3,12 @@ namespace Thelia\Model; use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Propel; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Order as BaseOrder; +use Thelia\Model\Map\OrderTableMap; +use \PDO; class Order extends BaseOrder { @@ -19,11 +22,19 @@ class Order extends BaseOrder */ public function preInsert(ConnectionInterface $con = null) { - $this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this)); + $this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this)); return true; } + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this)); + } + /** * calculate the total amount * @@ -35,4 +46,171 @@ class Order extends BaseOrder { return 2; } + + /** + * PROPEL SHOULD FIX IT + * + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; + } + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; + } + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; + } + if ($this->isColumnModified(OrderTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; + } + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { + $modifiedColumns[':p' . $index++] = 'STATUS_ID'; + } + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; + } + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME); + + if ($db->useQuoteIdentifier()) { + $tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME); + } else { + $tableName = OrderTableMap::TABLE_NAME; + } + + $sql = sprintf( + 'INSERT INTO %s (%s) VALUES (%s)', + $tableName, + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'REF': + $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); + break; + case 'CUSTOMER_ID': + $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); + break; + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); + break; + case 'DELIVERY_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT); + break; + case 'INVOICE_DATE': + $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'CURRENCY_ID': + $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); + break; + case 'CURRENCY_RATE': + $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); + break; + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); + break; + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); + break; + case 'INVOICE_REF': + $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); + break; + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); + break; + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); + break; + case 'STATUS_ID': + $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); + break; + case 'LANG_ID': + $stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } } diff --git a/core/lib/Thelia/Model/OrderProduct.php b/core/lib/Thelia/Model/OrderProduct.php new file mode 100644 index 000000000..235eaf259 --- /dev/null +++ b/core/lib/Thelia/Model/OrderProduct.php @@ -0,0 +1,31 @@ +dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder())); + + return true; + } + + /** + * {@inheritDoc} + */ + public function postInsert(ConnectionInterface $con = null) + { + $this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder())); + } +} diff --git a/core/lib/Thelia/Model/OrderProductQuery.php b/core/lib/Thelia/Model/OrderProductQuery.php new file mode 100644 index 000000000..de2c22404 --- /dev/null +++ b/core/lib/Thelia/Model/OrderProductQuery.php @@ -0,0 +1,21 @@ + Date: Thu, 19 Sep 2013 20:07:00 +0200 Subject: [PATCH 3/6] order payment email --- core/lib/Thelia/Action/Order.php | 22 +++++++++++++++++---- core/lib/Thelia/Core/Event/TheliaEvents.php | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index fda052316..6cf9ff277 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -247,10 +247,15 @@ class Order extends BaseAction implements EventSubscriberInterface $con->commit(); - /* T1style : dispatch mail event ? */ + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); - /* clear session @todo : remove comment below + test */ - //$sessionOrder = new \Thelia\Model\Order(); + /* clear session */ + $sessionOrder = new \Thelia\Model\Order(); + $event->setOrder($sessionOrder); + $this->getSession()->setOrder($sessionOrder); + + /* empty cart */ + $this->getSession()->getCart()->clear(); /* call pay method */ $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); @@ -259,7 +264,15 @@ class Order extends BaseAction implements EventSubscriberInterface $paymentModuleInstance->setRequest($this->getRequest()); $paymentModuleInstance->setDispatcher($this->getDispatcher()); - $paymentModuleInstance->pay(); + $paymentModuleInstance->pay($placedOrder); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function sendOrderEmail(OrderEvent $event) + { + /* @todo */ } /** @@ -305,6 +318,7 @@ class Order extends BaseAction implements EventSubscriberInterface TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), TheliaEvents::ORDER_PAY => array("create", 128), TheliaEvents::ORDER_BEFORE_CREATE => array("setReference", 128), + TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128), ); } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 80d87cc8c..0c2bfcf72 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -222,6 +222,8 @@ final class TheliaEvents const ORDER_PAY = "action.order.pay"; const ORDER_BEFORE_CREATE = "action.order.beforeCreate"; const ORDER_AFTER_CREATE = "action.order.afterCreate"; + const ORDER_BEFORE_PAYMENT = "action.order.beforePayment"; + const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; From 17548e352695832a4b24f82378e6049387d90fe7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 20 Sep 2013 08:23:02 +0200 Subject: [PATCH 4/6] order tax tables --- core/lib/Thelia/Action/Order.php | 6 +- .../Model/Base/OrderAttributeCombination.php | 1824 ----------------- .../Base/OrderAttributeCombinationQuery.php | 897 -------- core/lib/Thelia/Model/Base/OrderProduct.php | 620 ++++-- .../Thelia/Model/Base/OrderProductQuery.php | 198 +- .../Map/OrderAttributeCombinationTableMap.php | 503 ----- .../Thelia/Model/Map/OrderProductTableMap.php | 52 +- core/lib/Thelia/Model/Map/TaxI18nTableMap.php | 2 +- .../Thelia/Model/Map/TaxRuleI18nTableMap.php | 2 +- .../Model/OrderAttributeCombination.php | 10 - .../Model/OrderAttributeCombinationQuery.php | 21 - install/thelia.sql | 41 +- local/config/schema.xml | 27 +- 13 files changed, 712 insertions(+), 3491 deletions(-) delete mode 100644 core/lib/Thelia/Model/Base/OrderAttributeCombination.php delete mode 100644 core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php delete mode 100644 core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php delete mode 100644 core/lib/Thelia/Model/OrderAttributeCombination.php delete mode 100644 core/lib/Thelia/Model/OrderAttributeCombinationQuery.php diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 6cf9ff277..17d8327c0 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -25,7 +25,6 @@ namespace Thelia\Action; use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveRecord\ActiveRecordInterface; -use Propel\Runtime\Exception\PropelException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\OrderEvent; @@ -35,9 +34,8 @@ use Thelia\Model\AttributeAvI18n; use Thelia\Model\AttributeAvI18nQuery; use Thelia\Model\AttributeI18n; use Thelia\Model\AttributeI18nQuery; -use Thelia\Model\AttributeQuery; use Thelia\Model\AddressQuery; -use Thelia\Model\OrderAttributeCombination; +use Thelia\Model\OrderProductAttributeCombination; use Thelia\Model\ProductI18nQuery; use Thelia\Model\Lang; use Thelia\Model\ModuleQuery; @@ -226,7 +224,7 @@ class Order extends BaseAction implements EventSubscriberInterface $attribute = $this->getI18n(AttributeI18nQuery::create(), new AttributeI18n(), $attributeCombination->getAttributeId()); $attributeAv = $this->getI18n(AttributeAvI18nQuery::create(), new AttributeAvI18n(), $attributeCombination->getAttributeAvId()); - $orderAttributeCombination = new OrderAttributeCombination(); + $orderAttributeCombination = new OrderProductAttributeCombination(); $orderAttributeCombination ->setOrderProductId($orderProduct->getId()) ->setAttributeTitle($attribute->getTitle()) diff --git a/core/lib/Thelia/Model/Base/OrderAttributeCombination.php b/core/lib/Thelia/Model/Base/OrderAttributeCombination.php deleted file mode 100644 index 09bd77c28..000000000 --- a/core/lib/Thelia/Model/Base/OrderAttributeCombination.php +++ /dev/null @@ -1,1824 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another OrderAttributeCombination instance. If - * obj is an instance of OrderAttributeCombination, delegates to - * equals(OrderAttributeCombination). Otherwise, returns false. - * - * @param obj The object to compare to. - * @return Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @param string $name The virtual column name - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @return mixed - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return OrderAttributeCombination The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return OrderAttributeCombination The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [order_product_id] column value. - * - * @return int - */ - public function getOrderProductId() - { - - return $this->order_product_id; - } - - /** - * Get the [attribute_title] column value. - * - * @return string - */ - public function getAttributeTitle() - { - - return $this->attribute_title; - } - - /** - * Get the [attribute_chapo] column value. - * - * @return string - */ - public function getAttributeChapo() - { - - return $this->attribute_chapo; - } - - /** - * Get the [attribute_description] column value. - * - * @return string - */ - public function getAttributeDescription() - { - - return $this->attribute_description; - } - - /** - * Get the [attribute_postscriptumn] column value. - * - * @return string - */ - public function getAttributePostscriptumn() - { - - return $this->attribute_postscriptumn; - } - - /** - * Get the [attribute_av_title] column value. - * - * @return string - */ - public function getAttributeAvTitle() - { - - return $this->attribute_av_title; - } - - /** - * Get the [attribute_av_chapo] column value. - * - * @return string - */ - public function getAttributeAvChapo() - { - - return $this->attribute_av_chapo; - } - - /** - * Get the [attribute_av_description] column value. - * - * @return string - */ - public function getAttributeAvDescription() - { - - return $this->attribute_av_description; - } - - /** - * Get the [attribute_av_postscriptum] column value. - * - * @return string - */ - public function getAttributeAvPostscriptum() - { - - return $this->attribute_av_postscriptum; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at !== null ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at !== null ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [order_product_id] column. - * - * @param int $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setOrderProductId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->order_product_id !== $v) { - $this->order_product_id = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID; - } - - if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { - $this->aOrderProduct = null; - } - - - return $this; - } // setOrderProductId() - - /** - * Set the value of [attribute_title] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_title !== $v) { - $this->attribute_title = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE; - } - - - return $this; - } // setAttributeTitle() - - /** - * Set the value of [attribute_chapo] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeChapo($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_chapo !== $v) { - $this->attribute_chapo = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO; - } - - - return $this; - } // setAttributeChapo() - - /** - * Set the value of [attribute_description] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeDescription($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_description !== $v) { - $this->attribute_description = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION; - } - - - return $this; - } // setAttributeDescription() - - /** - * Set the value of [attribute_postscriptumn] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributePostscriptumn($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_postscriptumn !== $v) { - $this->attribute_postscriptumn = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN; - } - - - return $this; - } // setAttributePostscriptumn() - - /** - * Set the value of [attribute_av_title] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeAvTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_av_title !== $v) { - $this->attribute_av_title = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE; - } - - - return $this; - } // setAttributeAvTitle() - - /** - * Set the value of [attribute_av_chapo] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeAvChapo($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_av_chapo !== $v) { - $this->attribute_av_chapo = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO; - } - - - return $this; - } // setAttributeAvChapo() - - /** - * Set the value of [attribute_av_description] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeAvDescription($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_av_description !== $v) { - $this->attribute_av_description = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION; - } - - - return $this; - } // setAttributeAvDescription() - - /** - * Set the value of [attribute_av_postscriptum] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setAttributeAvPostscriptum($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->attribute_av_postscriptum !== $v) { - $this->attribute_av_postscriptum = $v; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM; - } - - - return $this; - } // setAttributeAvPostscriptum() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->order_product_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeTitle', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_title = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeChapo', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_chapo = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeDescription', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_description = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributePostscriptumn', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_postscriptumn = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvTitle', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_av_title = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvChapo', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_av_chapo = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvDescription', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_av_description = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('AttributeAvPostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_av_postscriptum = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderAttributeCombinationTableMap::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 ? 11 + $startcol : OrderAttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 12; // 12 = OrderAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\OrderAttributeCombination object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { - $this->aOrderProduct = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildOrderAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aOrderProduct = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see OrderAttributeCombination::setDeleted() - * @see OrderAttributeCombination::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildOrderAttributeCombinationQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderAttributeCombinationTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrderProduct !== null) { - if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { - $affectedRows += $this->aOrderProduct->save($con); - } - $this->setOrderProduct($this->aOrderProduct); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAttributeCombinationTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_TITLE'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_CHAPO'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_DESCRIPTION'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUMN'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_TITLE'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_CHAPO'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_DESCRIPTION'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_POSTSCRIPTUM'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO order_attribute_combination (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'ORDER_PRODUCT_ID': - $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); - break; - case 'ATTRIBUTE_TITLE': - $stmt->bindValue($identifier, $this->attribute_title, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_CHAPO': - $stmt->bindValue($identifier, $this->attribute_chapo, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_DESCRIPTION': - $stmt->bindValue($identifier, $this->attribute_description, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_POSTSCRIPTUMN': - $stmt->bindValue($identifier, $this->attribute_postscriptumn, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_AV_TITLE': - $stmt->bindValue($identifier, $this->attribute_av_title, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_AV_CHAPO': - $stmt->bindValue($identifier, $this->attribute_av_chapo, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_AV_DESCRIPTION': - $stmt->bindValue($identifier, $this->attribute_av_description, PDO::PARAM_STR); - break; - case 'ATTRIBUTE_AV_POSTSCRIPTUM': - $stmt->bindValue($identifier, $this->attribute_av_postscriptum, PDO::PARAM_STR); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = OrderAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getOrderProductId(); - break; - case 2: - return $this->getAttributeTitle(); - break; - case 3: - return $this->getAttributeChapo(); - break; - case 4: - return $this->getAttributeDescription(); - break; - case 5: - return $this->getAttributePostscriptumn(); - break; - case 6: - return $this->getAttributeAvTitle(); - break; - case 7: - return $this->getAttributeAvChapo(); - break; - case 8: - return $this->getAttributeAvDescription(); - break; - case 9: - return $this->getAttributeAvPostscriptum(); - break; - case 10: - return $this->getCreatedAt(); - break; - case 11: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['OrderAttributeCombination'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderAttributeCombination'][$this->getPrimaryKey()] = true; - $keys = OrderAttributeCombinationTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getOrderProductId(), - $keys[2] => $this->getAttributeTitle(), - $keys[3] => $this->getAttributeChapo(), - $keys[4] => $this->getAttributeDescription(), - $keys[5] => $this->getAttributePostscriptumn(), - $keys[6] => $this->getAttributeAvTitle(), - $keys[7] => $this->getAttributeAvChapo(), - $keys[8] => $this->getAttributeAvDescription(), - $keys[9] => $this->getAttributeAvPostscriptum(), - $keys[10] => $this->getCreatedAt(), - $keys[11] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach($virtualColumns as $key => $virtualColumn) - { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aOrderProduct) { - $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = OrderAttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setOrderProductId($value); - break; - case 2: - $this->setAttributeTitle($value); - break; - case 3: - $this->setAttributeChapo($value); - break; - case 4: - $this->setAttributeDescription($value); - break; - case 5: - $this->setAttributePostscriptumn($value); - break; - case 6: - $this->setAttributeAvTitle($value); - break; - case 7: - $this->setAttributeAvChapo($value); - break; - case 8: - $this->setAttributeAvDescription($value); - break; - case 9: - $this->setAttributeAvPostscriptum($value); - break; - case 10: - $this->setCreatedAt($value); - break; - case 11: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = OrderAttributeCombinationTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAttributeTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAttributeChapo($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAttributeDescription($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptumn($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAttributeAvTitle($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setAttributeAvChapo($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setAttributeAvDescription($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setAttributeAvPostscriptum($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); - - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ID)) $criteria->add(OrderAttributeCombinationTableMap::ID, $this->id); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $this->order_product_id); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, $this->attribute_title); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $this->attribute_chapo); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $this->attribute_description); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $this->attribute_postscriptumn); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $this->attribute_av_title); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $this->attribute_av_chapo); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $this->attribute_av_description); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM)) $criteria->add(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $this->attribute_av_postscriptum); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::CREATED_AT)) $criteria->add(OrderAttributeCombinationTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderAttributeCombinationTableMap::UPDATED_AT)) $criteria->add(OrderAttributeCombinationTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); - $criteria->add(OrderAttributeCombinationTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\OrderAttributeCombination (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setOrderProductId($this->getOrderProductId()); - $copyObj->setAttributeTitle($this->getAttributeTitle()); - $copyObj->setAttributeChapo($this->getAttributeChapo()); - $copyObj->setAttributeDescription($this->getAttributeDescription()); - $copyObj->setAttributePostscriptumn($this->getAttributePostscriptumn()); - $copyObj->setAttributeAvTitle($this->getAttributeAvTitle()); - $copyObj->setAttributeAvChapo($this->getAttributeAvChapo()); - $copyObj->setAttributeAvDescription($this->getAttributeAvDescription()); - $copyObj->setAttributeAvPostscriptum($this->getAttributeAvPostscriptum()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\OrderAttributeCombination Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildOrderProduct object. - * - * @param ChildOrderProduct $v - * @return \Thelia\Model\OrderAttributeCombination The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderProduct(ChildOrderProduct $v = null) - { - if ($v === null) { - $this->setOrderProductId(NULL); - } else { - $this->setOrderProductId($v->getId()); - } - - $this->aOrderProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildOrderProduct object, it will not be re-added. - if ($v !== null) { - $v->addOrderAttributeCombination($this); - } - - - return $this; - } - - - /** - * Get the associated ChildOrderProduct object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildOrderProduct The associated ChildOrderProduct object. - * @throws PropelException - */ - public function getOrderProduct(ConnectionInterface $con = null) - { - if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { - $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderProduct->addOrderAttributeCombinations($this); - */ - } - - return $this->aOrderProduct; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->order_product_id = null; - $this->attribute_title = null; - $this->attribute_chapo = null; - $this->attribute_description = null; - $this->attribute_postscriptumn = null; - $this->attribute_av_title = null; - $this->attribute_av_chapo = null; - $this->attribute_av_description = null; - $this->attribute_av_postscriptum = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aOrderProduct = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderAttributeCombinationTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildOrderAttributeCombination The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderAttributeCombinationTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php deleted file mode 100644 index 0c7e7bfd8..000000000 --- a/core/lib/Thelia/Model/Base/OrderAttributeCombinationQuery.php +++ /dev/null @@ -1,897 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildOrderAttributeCombination|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildOrderAttributeCombination A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUMN, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_attribute_combination WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildOrderAttributeCombination(); - $obj->hydrate($row); - OrderAttributeCombinationTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildOrderAttributeCombination|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the order_product_id column - * - * Example usage: - * - * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 - * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) - * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 - * - * - * @see filterByOrderProduct() - * - * @param mixed $orderProductId 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByOrderProductId($orderProductId = null, $comparison = null) - { - if (is_array($orderProductId)) { - $useMinMax = false; - if (isset($orderProductId['min'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($orderProductId['max'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); - } - - /** - * Filter the query on the attribute_title column - * - * Example usage: - * - * $query->filterByAttributeTitle('fooValue'); // WHERE attribute_title = 'fooValue' - * $query->filterByAttributeTitle('%fooValue%'); // WHERE attribute_title LIKE '%fooValue%' - * - * - * @param string $attributeTitle 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeTitle($attributeTitle = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeTitle)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeTitle)) { - $attributeTitle = str_replace('*', '%', $attributeTitle); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, $attributeTitle, $comparison); - } - - /** - * Filter the query on the attribute_chapo column - * - * Example usage: - * - * $query->filterByAttributeChapo('fooValue'); // WHERE attribute_chapo = 'fooValue' - * $query->filterByAttributeChapo('%fooValue%'); // WHERE attribute_chapo LIKE '%fooValue%' - * - * - * @param string $attributeChapo 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeChapo($attributeChapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeChapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeChapo)) { - $attributeChapo = str_replace('*', '%', $attributeChapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $attributeChapo, $comparison); - } - - /** - * Filter the query on the attribute_description column - * - * Example usage: - * - * $query->filterByAttributeDescription('fooValue'); // WHERE attribute_description = 'fooValue' - * $query->filterByAttributeDescription('%fooValue%'); // WHERE attribute_description LIKE '%fooValue%' - * - * - * @param string $attributeDescription 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeDescription($attributeDescription = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeDescription)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeDescription)) { - $attributeDescription = str_replace('*', '%', $attributeDescription); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $attributeDescription, $comparison); - } - - /** - * Filter the query on the attribute_postscriptumn column - * - * Example usage: - * - * $query->filterByAttributePostscriptumn('fooValue'); // WHERE attribute_postscriptumn = 'fooValue' - * $query->filterByAttributePostscriptumn('%fooValue%'); // WHERE attribute_postscriptumn LIKE '%fooValue%' - * - * - * @param string $attributePostscriptumn 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributePostscriptumn($attributePostscriptumn = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributePostscriptumn)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributePostscriptumn)) { - $attributePostscriptumn = str_replace('*', '%', $attributePostscriptumn); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $attributePostscriptumn, $comparison); - } - - /** - * Filter the query on the attribute_av_title column - * - * Example usage: - * - * $query->filterByAttributeAvTitle('fooValue'); // WHERE attribute_av_title = 'fooValue' - * $query->filterByAttributeAvTitle('%fooValue%'); // WHERE attribute_av_title LIKE '%fooValue%' - * - * - * @param string $attributeAvTitle 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeAvTitle($attributeAvTitle = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeAvTitle)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeAvTitle)) { - $attributeAvTitle = str_replace('*', '%', $attributeAvTitle); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $attributeAvTitle, $comparison); - } - - /** - * Filter the query on the attribute_av_chapo column - * - * Example usage: - * - * $query->filterByAttributeAvChapo('fooValue'); // WHERE attribute_av_chapo = 'fooValue' - * $query->filterByAttributeAvChapo('%fooValue%'); // WHERE attribute_av_chapo LIKE '%fooValue%' - * - * - * @param string $attributeAvChapo 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeAvChapo($attributeAvChapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeAvChapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeAvChapo)) { - $attributeAvChapo = str_replace('*', '%', $attributeAvChapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $attributeAvChapo, $comparison); - } - - /** - * Filter the query on the attribute_av_description column - * - * Example usage: - * - * $query->filterByAttributeAvDescription('fooValue'); // WHERE attribute_av_description = 'fooValue' - * $query->filterByAttributeAvDescription('%fooValue%'); // WHERE attribute_av_description LIKE '%fooValue%' - * - * - * @param string $attributeAvDescription 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeAvDescription($attributeAvDescription = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeAvDescription)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeAvDescription)) { - $attributeAvDescription = str_replace('*', '%', $attributeAvDescription); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $attributeAvDescription, $comparison); - } - - /** - * Filter the query on the attribute_av_postscriptum column - * - * Example usage: - * - * $query->filterByAttributeAvPostscriptum('fooValue'); // WHERE attribute_av_postscriptum = 'fooValue' - * $query->filterByAttributeAvPostscriptum('%fooValue%'); // WHERE attribute_av_postscriptum LIKE '%fooValue%' - * - * - * @param string $attributeAvPostscriptum 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 ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeAvPostscriptum($attributeAvPostscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($attributeAvPostscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributeAvPostscriptum)) { - $attributeAvPostscriptum = str_replace('*', '%', $attributeAvPostscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, $attributeAvPostscriptum, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\OrderProduct object - * - * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function filterByOrderProduct($orderProduct, $comparison = null) - { - if ($orderProduct instanceof \Thelia\Model\OrderProduct) { - return $this - ->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); - } elseif ($orderProduct instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderProduct relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderProduct'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderProduct'); - } - - return $this; - } - - /** - * Use the OrderProduct relation OrderProduct object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query - */ - public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrderProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); - } - - /** - * Exclude object from result - * - * @param ChildOrderAttributeCombination $orderAttributeCombination Object to remove from the list of results - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function prune($orderAttributeCombination = null) - { - if ($orderAttributeCombination) { - $this->addUsingAlias(OrderAttributeCombinationTableMap::ID, $orderAttributeCombination->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the order_attribute_combination table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderAttributeCombinationTableMap::clearInstancePool(); - OrderAttributeCombinationTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildOrderAttributeCombination or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildOrderAttributeCombination object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(OrderAttributeCombinationTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - OrderAttributeCombinationTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - OrderAttributeCombinationTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderAttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderAttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderAttributeCombinationTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderAttributeCombinationTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderAttributeCombinationTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildOrderAttributeCombinationQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderAttributeCombinationTableMap::CREATED_AT); - } - -} // OrderAttributeCombinationQuery diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index 3d72eee6e..6ff03d427 100644 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -18,10 +18,12 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Order as ChildOrder; -use Thelia\Model\OrderAttributeCombination as ChildOrderAttributeCombination; -use Thelia\Model\OrderAttributeCombinationQuery as ChildOrderAttributeCombinationQuery; use Thelia\Model\OrderProduct as ChildOrderProduct; +use Thelia\Model\OrderProductAttributeCombination as ChildOrderProductAttributeCombination; +use Thelia\Model\OrderProductAttributeCombinationQuery as ChildOrderProductAttributeCombinationQuery; use Thelia\Model\OrderProductQuery as ChildOrderProductQuery; +use Thelia\Model\OrderProductTax as ChildOrderProductTax; +use Thelia\Model\OrderProductTaxQuery as ChildOrderProductTaxQuery; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\OrderProductTableMap; @@ -144,10 +146,16 @@ abstract class OrderProduct implements ActiveRecordInterface protected $weight; /** - * The value for the tax field. - * @var double + * The value for the tax_rule_title field. + * @var string */ - protected $tax; + protected $tax_rule_title; + + /** + * The value for the tax_rule_description field. + * @var string + */ + protected $tax_rule_description; /** * The value for the parent field. @@ -173,10 +181,16 @@ abstract class OrderProduct implements ActiveRecordInterface protected $aOrder; /** - * @var ObjectCollection|ChildOrderAttributeCombination[] Collection to store aggregation of ChildOrderAttributeCombination objects. + * @var ObjectCollection|ChildOrderProductAttributeCombination[] Collection to store aggregation of ChildOrderProductAttributeCombination objects. */ - protected $collOrderAttributeCombinations; - protected $collOrderAttributeCombinationsPartial; + protected $collOrderProductAttributeCombinations; + protected $collOrderProductAttributeCombinationsPartial; + + /** + * @var ObjectCollection|ChildOrderProductTax[] Collection to store aggregation of ChildOrderProductTax objects. + */ + protected $collOrderProductTaxes; + protected $collOrderProductTaxesPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -190,7 +204,13 @@ abstract class OrderProduct implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $orderAttributeCombinationsScheduledForDeletion = null; + protected $orderProductAttributeCombinationsScheduledForDeletion = null; + + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $orderProductTaxesScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\OrderProduct object. @@ -601,14 +621,25 @@ abstract class OrderProduct implements ActiveRecordInterface } /** - * Get the [tax] column value. + * Get the [tax_rule_title] column value. * - * @return double + * @return string */ - public function getTax() + public function getTaxRuleTitle() { - return $this->tax; + return $this->tax_rule_title; + } + + /** + * Get the [tax_rule_description] column value. + * + * @return string + */ + public function getTaxRuleDescription() + { + + return $this->tax_rule_description; } /** @@ -961,25 +992,46 @@ abstract class OrderProduct implements ActiveRecordInterface } // setWeight() /** - * Set the value of [tax] column. + * Set the value of [tax_rule_title] column. * - * @param double $v new value + * @param string $v new value * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function setTax($v) + public function setTaxRuleTitle($v) { if ($v !== null) { - $v = (double) $v; + $v = (string) $v; } - if ($this->tax !== $v) { - $this->tax = $v; - $this->modifiedColumns[] = OrderProductTableMap::TAX; + if ($this->tax_rule_title !== $v) { + $this->tax_rule_title = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_TITLE; } return $this; - } // setTax() + } // setTaxRuleTitle() + + /** + * Set the value of [tax_rule_description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setTaxRuleDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->tax_rule_description !== $v) { + $this->tax_rule_description = $v; + $this->modifiedColumns[] = OrderProductTableMap::TAX_RULE_DESCRIPTION; + } + + + return $this; + } // setTaxRuleDescription() /** * Set the value of [parent] column. @@ -1123,19 +1175,22 @@ abstract class OrderProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; $this->weight = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; - $this->tax = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderProductTableMap::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 ? 17 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1148,7 +1203,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 18; // 18 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 19; // 19 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); @@ -1213,7 +1268,9 @@ abstract class OrderProduct implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aOrder = null; - $this->collOrderAttributeCombinations = null; + $this->collOrderProductAttributeCombinations = null; + + $this->collOrderProductTaxes = null; } // if (deep) } @@ -1360,17 +1417,34 @@ abstract class OrderProduct implements ActiveRecordInterface $this->resetModified(); } - if ($this->orderAttributeCombinationsScheduledForDeletion !== null) { - if (!$this->orderAttributeCombinationsScheduledForDeletion->isEmpty()) { - \Thelia\Model\OrderAttributeCombinationQuery::create() - ->filterByPrimaryKeys($this->orderAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->orderProductAttributeCombinationsScheduledForDeletion !== null) { + if (!$this->orderProductAttributeCombinationsScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductAttributeCombinationQuery::create() + ->filterByPrimaryKeys($this->orderProductAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->orderAttributeCombinationsScheduledForDeletion = null; + $this->orderProductAttributeCombinationsScheduledForDeletion = null; } } - if ($this->collOrderAttributeCombinations !== null) { - foreach ($this->collOrderAttributeCombinations as $referrerFK) { + if ($this->collOrderProductAttributeCombinations !== null) { + foreach ($this->collOrderProductAttributeCombinations as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->orderProductTaxesScheduledForDeletion !== null) { + if (!$this->orderProductTaxesScheduledForDeletion->isEmpty()) { + \Thelia\Model\OrderProductTaxQuery::create() + ->filterByPrimaryKeys($this->orderProductTaxesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->orderProductTaxesScheduledForDeletion = null; + } + } + + if ($this->collOrderProductTaxes !== null) { + foreach ($this->collOrderProductTaxes as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1445,8 +1519,11 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) { $modifiedColumns[':p' . $index++] = 'WEIGHT'; } - if ($this->isColumnModified(OrderProductTableMap::TAX)) { - $modifiedColumns[':p' . $index++] = 'TAX'; + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_TITLE'; + } + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_DESCRIPTION'; } if ($this->isColumnModified(OrderProductTableMap::PARENT)) { $modifiedColumns[':p' . $index++] = 'PARENT'; @@ -1510,8 +1587,11 @@ abstract class OrderProduct implements ActiveRecordInterface case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; - case 'TAX': - $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); + case 'TAX_RULE_TITLE': + $stmt->bindValue($identifier, $this->tax_rule_title, PDO::PARAM_STR); + break; + case 'TAX_RULE_DESCRIPTION': + $stmt->bindValue($identifier, $this->tax_rule_description, PDO::PARAM_STR); break; case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); @@ -1627,15 +1707,18 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->getWeight(); break; case 14: - return $this->getTax(); + return $this->getTaxRuleTitle(); break; case 15: - return $this->getParent(); + return $this->getTaxRuleDescription(); break; case 16: - return $this->getCreatedAt(); + return $this->getParent(); break; case 17: + return $this->getCreatedAt(); + break; + case 18: return $this->getUpdatedAt(); break; default: @@ -1681,10 +1764,11 @@ abstract class OrderProduct implements ActiveRecordInterface $keys[11] => $this->getWasNew(), $keys[12] => $this->getWasInPromo(), $keys[13] => $this->getWeight(), - $keys[14] => $this->getTax(), - $keys[15] => $this->getParent(), - $keys[16] => $this->getCreatedAt(), - $keys[17] => $this->getUpdatedAt(), + $keys[14] => $this->getTaxRuleTitle(), + $keys[15] => $this->getTaxRuleDescription(), + $keys[16] => $this->getParent(), + $keys[17] => $this->getCreatedAt(), + $keys[18] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1696,8 +1780,11 @@ abstract class OrderProduct implements ActiveRecordInterface if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } - if (null !== $this->collOrderAttributeCombinations) { - $result['OrderAttributeCombinations'] = $this->collOrderAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collOrderProductAttributeCombinations) { + $result['OrderProductAttributeCombinations'] = $this->collOrderProductAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collOrderProductTaxes) { + $result['OrderProductTaxes'] = $this->collOrderProductTaxes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1776,15 +1863,18 @@ abstract class OrderProduct implements ActiveRecordInterface $this->setWeight($value); break; case 14: - $this->setTax($value); + $this->setTaxRuleTitle($value); break; case 15: - $this->setParent($value); + $this->setTaxRuleDescription($value); break; case 16: - $this->setCreatedAt($value); + $this->setParent($value); break; case 17: + $this->setCreatedAt($value); + break; + case 18: $this->setUpdatedAt($value); break; } // switch() @@ -1825,10 +1915,11 @@ abstract class OrderProduct implements ActiveRecordInterface if (array_key_exists($keys[11], $arr)) $this->setWasNew($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setWasInPromo($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setWeight($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setTax($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setParent($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); + if (array_key_exists($keys[14], $arr)) $this->setTaxRuleTitle($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setTaxRuleDescription($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setParent($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]); } /** @@ -1854,7 +1945,8 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) $criteria->add(OrderProductTableMap::WAS_NEW, $this->was_new); if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) $criteria->add(OrderProductTableMap::WAS_IN_PROMO, $this->was_in_promo); if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) $criteria->add(OrderProductTableMap::WEIGHT, $this->weight); - if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) $criteria->add(OrderProductTableMap::TAX_RULE_TITLE, $this->tax_rule_title); + if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) $criteria->add(OrderProductTableMap::TAX_RULE_DESCRIPTION, $this->tax_rule_description); if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); @@ -1934,7 +2026,8 @@ abstract class OrderProduct implements ActiveRecordInterface $copyObj->setWasNew($this->getWasNew()); $copyObj->setWasInPromo($this->getWasInPromo()); $copyObj->setWeight($this->getWeight()); - $copyObj->setTax($this->getTax()); + $copyObj->setTaxRuleTitle($this->getTaxRuleTitle()); + $copyObj->setTaxRuleDescription($this->getTaxRuleDescription()); $copyObj->setParent($this->getParent()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1944,9 +2037,15 @@ abstract class OrderProduct implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getOrderAttributeCombinations() as $relObj) { + foreach ($this->getOrderProductAttributeCombinations() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderAttributeCombination($relObj->copy($deepCopy)); + $copyObj->addOrderProductAttributeCombination($relObj->copy($deepCopy)); + } + } + + foreach ($this->getOrderProductTaxes() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addOrderProductTax($relObj->copy($deepCopy)); } } @@ -2042,37 +2141,40 @@ abstract class OrderProduct implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('OrderAttributeCombination' == $relationName) { - return $this->initOrderAttributeCombinations(); + if ('OrderProductAttributeCombination' == $relationName) { + return $this->initOrderProductAttributeCombinations(); + } + if ('OrderProductTax' == $relationName) { + return $this->initOrderProductTaxes(); } } /** - * Clears out the collOrderAttributeCombinations collection + * Clears out the collOrderProductAttributeCombinations collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addOrderAttributeCombinations() + * @see addOrderProductAttributeCombinations() */ - public function clearOrderAttributeCombinations() + public function clearOrderProductAttributeCombinations() { - $this->collOrderAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized + $this->collOrderProductAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrderAttributeCombinations collection loaded partially. + * Reset is the collOrderProductAttributeCombinations collection loaded partially. */ - public function resetPartialOrderAttributeCombinations($v = true) + public function resetPartialOrderProductAttributeCombinations($v = true) { - $this->collOrderAttributeCombinationsPartial = $v; + $this->collOrderProductAttributeCombinationsPartial = $v; } /** - * Initializes the collOrderAttributeCombinations collection. + * Initializes the collOrderProductAttributeCombinations collection. * - * By default this just sets the collOrderAttributeCombinations collection to an empty array (like clearcollOrderAttributeCombinations()); + * By default this just sets the collOrderProductAttributeCombinations collection to an empty array (like clearcollOrderProductAttributeCombinations()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -2081,17 +2183,17 @@ abstract class OrderProduct implements ActiveRecordInterface * * @return void */ - public function initOrderAttributeCombinations($overrideExisting = true) + public function initOrderProductAttributeCombinations($overrideExisting = true) { - if (null !== $this->collOrderAttributeCombinations && !$overrideExisting) { + if (null !== $this->collOrderProductAttributeCombinations && !$overrideExisting) { return; } - $this->collOrderAttributeCombinations = new ObjectCollection(); - $this->collOrderAttributeCombinations->setModel('\Thelia\Model\OrderAttributeCombination'); + $this->collOrderProductAttributeCombinations = new ObjectCollection(); + $this->collOrderProductAttributeCombinations->setModel('\Thelia\Model\OrderProductAttributeCombination'); } /** - * Gets an array of ChildOrderAttributeCombination objects which contain a foreign key that references this object. + * Gets an array of ChildOrderProductAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -2101,109 +2203,109 @@ abstract class OrderProduct implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildOrderAttributeCombination[] List of ChildOrderAttributeCombination objects + * @return Collection|ChildOrderProductAttributeCombination[] List of ChildOrderProductAttributeCombination objects * @throws PropelException */ - public function getOrderAttributeCombinations($criteria = null, ConnectionInterface $con = null) + public function getOrderProductAttributeCombinations($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrderAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collOrderAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderAttributeCombinations) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { // return empty collection - $this->initOrderAttributeCombinations(); + $this->initOrderProductAttributeCombinations(); } else { - $collOrderAttributeCombinations = ChildOrderAttributeCombinationQuery::create(null, $criteria) + $collOrderProductAttributeCombinations = ChildOrderProductAttributeCombinationQuery::create(null, $criteria) ->filterByOrderProduct($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrderAttributeCombinationsPartial && count($collOrderAttributeCombinations)) { - $this->initOrderAttributeCombinations(false); + if (false !== $this->collOrderProductAttributeCombinationsPartial && count($collOrderProductAttributeCombinations)) { + $this->initOrderProductAttributeCombinations(false); - foreach ($collOrderAttributeCombinations as $obj) { - if (false == $this->collOrderAttributeCombinations->contains($obj)) { - $this->collOrderAttributeCombinations->append($obj); + foreach ($collOrderProductAttributeCombinations as $obj) { + if (false == $this->collOrderProductAttributeCombinations->contains($obj)) { + $this->collOrderProductAttributeCombinations->append($obj); } } - $this->collOrderAttributeCombinationsPartial = true; + $this->collOrderProductAttributeCombinationsPartial = true; } - $collOrderAttributeCombinations->getInternalIterator()->rewind(); + $collOrderProductAttributeCombinations->getInternalIterator()->rewind(); - return $collOrderAttributeCombinations; + return $collOrderProductAttributeCombinations; } - if ($partial && $this->collOrderAttributeCombinations) { - foreach ($this->collOrderAttributeCombinations as $obj) { + if ($partial && $this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $obj) { if ($obj->isNew()) { - $collOrderAttributeCombinations[] = $obj; + $collOrderProductAttributeCombinations[] = $obj; } } } - $this->collOrderAttributeCombinations = $collOrderAttributeCombinations; - $this->collOrderAttributeCombinationsPartial = false; + $this->collOrderProductAttributeCombinations = $collOrderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; } } - return $this->collOrderAttributeCombinations; + return $this->collOrderProductAttributeCombinations; } /** - * Sets a collection of OrderAttributeCombination objects related by a one-to-many relationship + * Sets a collection of OrderProductAttributeCombination objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $orderAttributeCombinations A Propel collection. + * @param Collection $orderProductAttributeCombinations A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrderProduct The current object (for fluent API support) */ - public function setOrderAttributeCombinations(Collection $orderAttributeCombinations, ConnectionInterface $con = null) + public function setOrderProductAttributeCombinations(Collection $orderProductAttributeCombinations, ConnectionInterface $con = null) { - $orderAttributeCombinationsToDelete = $this->getOrderAttributeCombinations(new Criteria(), $con)->diff($orderAttributeCombinations); + $orderProductAttributeCombinationsToDelete = $this->getOrderProductAttributeCombinations(new Criteria(), $con)->diff($orderProductAttributeCombinations); - $this->orderAttributeCombinationsScheduledForDeletion = $orderAttributeCombinationsToDelete; + $this->orderProductAttributeCombinationsScheduledForDeletion = $orderProductAttributeCombinationsToDelete; - foreach ($orderAttributeCombinationsToDelete as $orderAttributeCombinationRemoved) { - $orderAttributeCombinationRemoved->setOrderProduct(null); + foreach ($orderProductAttributeCombinationsToDelete as $orderProductAttributeCombinationRemoved) { + $orderProductAttributeCombinationRemoved->setOrderProduct(null); } - $this->collOrderAttributeCombinations = null; - foreach ($orderAttributeCombinations as $orderAttributeCombination) { - $this->addOrderAttributeCombination($orderAttributeCombination); + $this->collOrderProductAttributeCombinations = null; + foreach ($orderProductAttributeCombinations as $orderProductAttributeCombination) { + $this->addOrderProductAttributeCombination($orderProductAttributeCombination); } - $this->collOrderAttributeCombinations = $orderAttributeCombinations; - $this->collOrderAttributeCombinationsPartial = false; + $this->collOrderProductAttributeCombinations = $orderProductAttributeCombinations; + $this->collOrderProductAttributeCombinationsPartial = false; return $this; } /** - * Returns the number of related OrderAttributeCombination objects. + * Returns the number of related OrderProductAttributeCombination objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related OrderAttributeCombination objects. + * @return int Count of related OrderProductAttributeCombination objects. * @throws PropelException */ - public function countOrderAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countOrderProductAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrderAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collOrderAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderAttributeCombinations) { + $partial = $this->collOrderProductAttributeCombinationsPartial && !$this->isNew(); + if (null === $this->collOrderProductAttributeCombinations || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductAttributeCombinations) { return 0; } if ($partial && !$criteria) { - return count($this->getOrderAttributeCombinations()); + return count($this->getOrderProductAttributeCombinations()); } - $query = ChildOrderAttributeCombinationQuery::create(null, $criteria); + $query = ChildOrderProductAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2213,53 +2315,271 @@ abstract class OrderProduct implements ActiveRecordInterface ->count($con); } - return count($this->collOrderAttributeCombinations); + return count($this->collOrderProductAttributeCombinations); } /** - * Method called to associate a ChildOrderAttributeCombination object to this object - * through the ChildOrderAttributeCombination foreign key attribute. + * Method called to associate a ChildOrderProductAttributeCombination object to this object + * through the ChildOrderProductAttributeCombination foreign key attribute. * - * @param ChildOrderAttributeCombination $l ChildOrderAttributeCombination + * @param ChildOrderProductAttributeCombination $l ChildOrderProductAttributeCombination * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function addOrderAttributeCombination(ChildOrderAttributeCombination $l) + public function addOrderProductAttributeCombination(ChildOrderProductAttributeCombination $l) { - if ($this->collOrderAttributeCombinations === null) { - $this->initOrderAttributeCombinations(); - $this->collOrderAttributeCombinationsPartial = true; + if ($this->collOrderProductAttributeCombinations === null) { + $this->initOrderProductAttributeCombinations(); + $this->collOrderProductAttributeCombinationsPartial = true; } - if (!in_array($l, $this->collOrderAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderAttributeCombination($l); + if (!in_array($l, $this->collOrderProductAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductAttributeCombination($l); } return $this; } /** - * @param OrderAttributeCombination $orderAttributeCombination The orderAttributeCombination object to add. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to add. */ - protected function doAddOrderAttributeCombination($orderAttributeCombination) + protected function doAddOrderProductAttributeCombination($orderProductAttributeCombination) { - $this->collOrderAttributeCombinations[]= $orderAttributeCombination; - $orderAttributeCombination->setOrderProduct($this); + $this->collOrderProductAttributeCombinations[]= $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct($this); } /** - * @param OrderAttributeCombination $orderAttributeCombination The orderAttributeCombination object to remove. + * @param OrderProductAttributeCombination $orderProductAttributeCombination The orderProductAttributeCombination object to remove. * @return ChildOrderProduct The current object (for fluent API support) */ - public function removeOrderAttributeCombination($orderAttributeCombination) + public function removeOrderProductAttributeCombination($orderProductAttributeCombination) { - if ($this->getOrderAttributeCombinations()->contains($orderAttributeCombination)) { - $this->collOrderAttributeCombinations->remove($this->collOrderAttributeCombinations->search($orderAttributeCombination)); - if (null === $this->orderAttributeCombinationsScheduledForDeletion) { - $this->orderAttributeCombinationsScheduledForDeletion = clone $this->collOrderAttributeCombinations; - $this->orderAttributeCombinationsScheduledForDeletion->clear(); + if ($this->getOrderProductAttributeCombinations()->contains($orderProductAttributeCombination)) { + $this->collOrderProductAttributeCombinations->remove($this->collOrderProductAttributeCombinations->search($orderProductAttributeCombination)); + if (null === $this->orderProductAttributeCombinationsScheduledForDeletion) { + $this->orderProductAttributeCombinationsScheduledForDeletion = clone $this->collOrderProductAttributeCombinations; + $this->orderProductAttributeCombinationsScheduledForDeletion->clear(); } - $this->orderAttributeCombinationsScheduledForDeletion[]= clone $orderAttributeCombination; - $orderAttributeCombination->setOrderProduct(null); + $this->orderProductAttributeCombinationsScheduledForDeletion[]= clone $orderProductAttributeCombination; + $orderProductAttributeCombination->setOrderProduct(null); + } + + return $this; + } + + /** + * Clears out the collOrderProductTaxes collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addOrderProductTaxes() + */ + public function clearOrderProductTaxes() + { + $this->collOrderProductTaxes = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collOrderProductTaxes collection loaded partially. + */ + public function resetPartialOrderProductTaxes($v = true) + { + $this->collOrderProductTaxesPartial = $v; + } + + /** + * Initializes the collOrderProductTaxes collection. + * + * By default this just sets the collOrderProductTaxes collection to an empty array (like clearcollOrderProductTaxes()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initOrderProductTaxes($overrideExisting = true) + { + if (null !== $this->collOrderProductTaxes && !$overrideExisting) { + return; + } + $this->collOrderProductTaxes = new ObjectCollection(); + $this->collOrderProductTaxes->setModel('\Thelia\Model\OrderProductTax'); + } + + /** + * Gets an array of ChildOrderProductTax objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildOrderProduct is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderProductTax[] List of ChildOrderProductTax objects + * @throws PropelException + */ + public function getOrderProductTaxes($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + // return empty collection + $this->initOrderProductTaxes(); + } else { + $collOrderProductTaxes = ChildOrderProductTaxQuery::create(null, $criteria) + ->filterByOrderProduct($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collOrderProductTaxesPartial && count($collOrderProductTaxes)) { + $this->initOrderProductTaxes(false); + + foreach ($collOrderProductTaxes as $obj) { + if (false == $this->collOrderProductTaxes->contains($obj)) { + $this->collOrderProductTaxes->append($obj); + } + } + + $this->collOrderProductTaxesPartial = true; + } + + $collOrderProductTaxes->getInternalIterator()->rewind(); + + return $collOrderProductTaxes; + } + + if ($partial && $this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $obj) { + if ($obj->isNew()) { + $collOrderProductTaxes[] = $obj; + } + } + } + + $this->collOrderProductTaxes = $collOrderProductTaxes; + $this->collOrderProductTaxesPartial = false; + } + } + + return $this->collOrderProductTaxes; + } + + /** + * Sets a collection of OrderProductTax objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $orderProductTaxes A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function setOrderProductTaxes(Collection $orderProductTaxes, ConnectionInterface $con = null) + { + $orderProductTaxesToDelete = $this->getOrderProductTaxes(new Criteria(), $con)->diff($orderProductTaxes); + + + $this->orderProductTaxesScheduledForDeletion = $orderProductTaxesToDelete; + + foreach ($orderProductTaxesToDelete as $orderProductTaxRemoved) { + $orderProductTaxRemoved->setOrderProduct(null); + } + + $this->collOrderProductTaxes = null; + foreach ($orderProductTaxes as $orderProductTax) { + $this->addOrderProductTax($orderProductTax); + } + + $this->collOrderProductTaxes = $orderProductTaxes; + $this->collOrderProductTaxesPartial = false; + + return $this; + } + + /** + * Returns the number of related OrderProductTax objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related OrderProductTax objects. + * @throws PropelException + */ + public function countOrderProductTaxes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collOrderProductTaxesPartial && !$this->isNew(); + if (null === $this->collOrderProductTaxes || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collOrderProductTaxes) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getOrderProductTaxes()); + } + + $query = ChildOrderProductTaxQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByOrderProduct($this) + ->count($con); + } + + return count($this->collOrderProductTaxes); + } + + /** + * Method called to associate a ChildOrderProductTax object to this object + * through the ChildOrderProductTax foreign key attribute. + * + * @param ChildOrderProductTax $l ChildOrderProductTax + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function addOrderProductTax(ChildOrderProductTax $l) + { + if ($this->collOrderProductTaxes === null) { + $this->initOrderProductTaxes(); + $this->collOrderProductTaxesPartial = true; + } + + if (!in_array($l, $this->collOrderProductTaxes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddOrderProductTax($l); + } + + return $this; + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to add. + */ + protected function doAddOrderProductTax($orderProductTax) + { + $this->collOrderProductTaxes[]= $orderProductTax; + $orderProductTax->setOrderProduct($this); + } + + /** + * @param OrderProductTax $orderProductTax The orderProductTax object to remove. + * @return ChildOrderProduct The current object (for fluent API support) + */ + public function removeOrderProductTax($orderProductTax) + { + if ($this->getOrderProductTaxes()->contains($orderProductTax)) { + $this->collOrderProductTaxes->remove($this->collOrderProductTaxes->search($orderProductTax)); + if (null === $this->orderProductTaxesScheduledForDeletion) { + $this->orderProductTaxesScheduledForDeletion = clone $this->collOrderProductTaxes; + $this->orderProductTaxesScheduledForDeletion->clear(); + } + $this->orderProductTaxesScheduledForDeletion[]= clone $orderProductTax; + $orderProductTax->setOrderProduct(null); } return $this; @@ -2284,7 +2604,8 @@ abstract class OrderProduct implements ActiveRecordInterface $this->was_new = null; $this->was_in_promo = null; $this->weight = null; - $this->tax = null; + $this->tax_rule_title = null; + $this->tax_rule_description = null; $this->parent = null; $this->created_at = null; $this->updated_at = null; @@ -2307,17 +2628,26 @@ abstract class OrderProduct implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collOrderAttributeCombinations) { - foreach ($this->collOrderAttributeCombinations as $o) { + if ($this->collOrderProductAttributeCombinations) { + foreach ($this->collOrderProductAttributeCombinations as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collOrderProductTaxes) { + foreach ($this->collOrderProductTaxes as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collOrderAttributeCombinations instanceof Collection) { - $this->collOrderAttributeCombinations->clearIterator(); + if ($this->collOrderProductAttributeCombinations instanceof Collection) { + $this->collOrderProductAttributeCombinations->clearIterator(); } - $this->collOrderAttributeCombinations = null; + $this->collOrderProductAttributeCombinations = null; + if ($this->collOrderProductTaxes instanceof Collection) { + $this->collOrderProductTaxes->clearIterator(); + } + $this->collOrderProductTaxes = null; $this->aOrder = null; } diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php index b471fc359..f28102dfb 100644 --- a/core/lib/Thelia/Model/Base/OrderProductQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -35,7 +35,8 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery orderByWasNew($order = Criteria::ASC) Order by the was_new column * @method ChildOrderProductQuery orderByWasInPromo($order = Criteria::ASC) Order by the was_in_promo column * @method ChildOrderProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column - * @method ChildOrderProductQuery orderByTax($order = Criteria::ASC) Order by the tax column + * @method ChildOrderProductQuery orderByTaxRuleTitle($order = Criteria::ASC) Order by the tax_rule_title column + * @method ChildOrderProductQuery orderByTaxRuleDescription($order = Criteria::ASC) Order by the tax_rule_description column * @method ChildOrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column * @method ChildOrderProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -54,7 +55,8 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery groupByWasNew() Group by the was_new column * @method ChildOrderProductQuery groupByWasInPromo() Group by the was_in_promo column * @method ChildOrderProductQuery groupByWeight() Group by the weight column - * @method ChildOrderProductQuery groupByTax() Group by the tax column + * @method ChildOrderProductQuery groupByTaxRuleTitle() Group by the tax_rule_title column + * @method ChildOrderProductQuery groupByTaxRuleDescription() Group by the tax_rule_description column * @method ChildOrderProductQuery groupByParent() Group by the parent column * @method ChildOrderProductQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderProductQuery groupByUpdatedAt() Group by the updated_at column @@ -67,9 +69,13 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation * @method ChildOrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation * - * @method ChildOrderProductQuery leftJoinOrderAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderAttributeCombination relation - * @method ChildOrderProductQuery rightJoinOrderAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderAttributeCombination relation - * @method ChildOrderProductQuery innerJoinOrderAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderAttributeCombination relation + * @method ChildOrderProductQuery leftJoinOrderProductAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery rightJoinOrderProductAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductAttributeCombination relation + * @method ChildOrderProductQuery innerJoinOrderProductAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductAttributeCombination relation + * + * @method ChildOrderProductQuery leftJoinOrderProductTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery rightJoinOrderProductTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductTax relation + * @method ChildOrderProductQuery innerJoinOrderProductTax($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductTax relation * * @method ChildOrderProduct findOne(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query * @method ChildOrderProduct findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query, or a new ChildOrderProduct object populated from the query conditions when no match is found @@ -88,7 +94,8 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProduct findOneByWasNew(int $was_new) Return the first ChildOrderProduct filtered by the was_new column * @method ChildOrderProduct findOneByWasInPromo(int $was_in_promo) Return the first ChildOrderProduct filtered by the was_in_promo column * @method ChildOrderProduct findOneByWeight(string $weight) Return the first ChildOrderProduct filtered by the weight column - * @method ChildOrderProduct findOneByTax(double $tax) Return the first ChildOrderProduct filtered by the tax column + * @method ChildOrderProduct findOneByTaxRuleTitle(string $tax_rule_title) Return the first ChildOrderProduct filtered by the tax_rule_title column + * @method ChildOrderProduct findOneByTaxRuleDescription(string $tax_rule_description) Return the first ChildOrderProduct filtered by the tax_rule_description column * @method ChildOrderProduct findOneByParent(int $parent) Return the first ChildOrderProduct filtered by the parent column * @method ChildOrderProduct findOneByCreatedAt(string $created_at) Return the first ChildOrderProduct filtered by the created_at column * @method ChildOrderProduct findOneByUpdatedAt(string $updated_at) Return the first ChildOrderProduct filtered by the updated_at column @@ -107,7 +114,8 @@ use Thelia\Model\Map\OrderProductTableMap; * @method array findByWasNew(int $was_new) Return ChildOrderProduct objects filtered by the was_new column * @method array findByWasInPromo(int $was_in_promo) Return ChildOrderProduct objects filtered by the was_in_promo column * @method array findByWeight(string $weight) Return ChildOrderProduct objects filtered by the weight column - * @method array findByTax(double $tax) Return ChildOrderProduct objects filtered by the tax column + * @method array findByTaxRuleTitle(string $tax_rule_title) Return ChildOrderProduct objects filtered by the tax_rule_title column + * @method array findByTaxRuleDescription(string $tax_rule_description) Return ChildOrderProduct objects filtered by the tax_rule_description column * @method array findByParent(int $parent) Return ChildOrderProduct objects filtered by the parent column * @method array findByCreatedAt(string $created_at) Return ChildOrderProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrderProduct objects filtered by the updated_at column @@ -199,7 +207,7 @@ abstract class OrderProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -769,44 +777,61 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query on the tax column + * Filter the query on the tax_rule_title column * * Example usage: * - * $query->filterByTax(1234); // WHERE tax = 1234 - * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 + * $query->filterByTaxRuleTitle('fooValue'); // WHERE tax_rule_title = 'fooValue' + * $query->filterByTaxRuleTitle('%fooValue%'); // WHERE tax_rule_title LIKE '%fooValue%' * * - * @param mixed $tax 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 $taxRuleTitle 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 ChildOrderProductQuery The current query, for fluid interface */ - public function filterByTax($tax = null, $comparison = null) + public function filterByTaxRuleTitle($taxRuleTitle = null, $comparison = null) { - if (is_array($tax)) { - $useMinMax = false; - if (isset($tax['min'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { + if (null === $comparison) { + if (is_array($taxRuleTitle)) { $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleTitle)) { + $taxRuleTitle = str_replace('*', '%', $taxRuleTitle); + $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_TITLE, $taxRuleTitle, $comparison); + } + + /** + * Filter the query on the tax_rule_description column + * + * Example usage: + * + * $query->filterByTaxRuleDescription('fooValue'); // WHERE tax_rule_description = 'fooValue' + * $query->filterByTaxRuleDescription('%fooValue%'); // WHERE tax_rule_description LIKE '%fooValue%' + * + * + * @param string $taxRuleDescription 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 ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByTaxRuleDescription($taxRuleDescription = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($taxRuleDescription)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $taxRuleDescription)) { + $taxRuleDescription = str_replace('*', '%', $taxRuleDescription); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_DESCRIPTION, $taxRuleDescription, $comparison); } /** @@ -1012,40 +1037,40 @@ abstract class OrderProductQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\OrderAttributeCombination object + * Filter the query by a related \Thelia\Model\OrderProductAttributeCombination object * - * @param \Thelia\Model\OrderAttributeCombination|ObjectCollection $orderAttributeCombination the related object to use as filter + * @param \Thelia\Model\OrderProductAttributeCombination|ObjectCollection $orderProductAttributeCombination the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function filterByOrderAttributeCombination($orderAttributeCombination, $comparison = null) + public function filterByOrderProductAttributeCombination($orderProductAttributeCombination, $comparison = null) { - if ($orderAttributeCombination instanceof \Thelia\Model\OrderAttributeCombination) { + if ($orderProductAttributeCombination instanceof \Thelia\Model\OrderProductAttributeCombination) { return $this - ->addUsingAlias(OrderProductTableMap::ID, $orderAttributeCombination->getOrderProductId(), $comparison); - } elseif ($orderAttributeCombination instanceof ObjectCollection) { + ->addUsingAlias(OrderProductTableMap::ID, $orderProductAttributeCombination->getOrderProductId(), $comparison); + } elseif ($orderProductAttributeCombination instanceof ObjectCollection) { return $this - ->useOrderAttributeCombinationQuery() - ->filterByPrimaryKeys($orderAttributeCombination->getPrimaryKeys()) + ->useOrderProductAttributeCombinationQuery() + ->filterByPrimaryKeys($orderProductAttributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderAttributeCombination() only accepts arguments of type \Thelia\Model\OrderAttributeCombination or Collection'); + throw new PropelException('filterByOrderProductAttributeCombination() only accepts arguments of type \Thelia\Model\OrderProductAttributeCombination or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderAttributeCombination relation + * Adds a JOIN clause to the query using the OrderProductAttributeCombination relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderProductQuery The current query, for fluid interface */ - public function joinOrderAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinOrderProductAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAttributeCombination'); + $relationMap = $tableMap->getRelation('OrderProductAttributeCombination'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1060,14 +1085,14 @@ abstract class OrderProductQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderAttributeCombination'); + $this->addJoinObject($join, 'OrderProductAttributeCombination'); } return $this; } /** - * Use the OrderAttributeCombination relation OrderAttributeCombination object + * Use the OrderProductAttributeCombination relation OrderProductAttributeCombination object * * @see useQuery() * @@ -1075,13 +1100,86 @@ abstract class OrderProductQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\OrderAttributeCombinationQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\OrderProductAttributeCombinationQuery A secondary query class using the current class as primary query */ - public function useOrderAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useOrderProductAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderAttributeCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAttributeCombination', '\Thelia\Model\OrderAttributeCombinationQuery'); + ->joinOrderProductAttributeCombination($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductAttributeCombination', '\Thelia\Model\OrderProductAttributeCombinationQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\OrderProductTax object + * + * @param \Thelia\Model\OrderProductTax|ObjectCollection $orderProductTax the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByOrderProductTax($orderProductTax, $comparison = null) + { + if ($orderProductTax instanceof \Thelia\Model\OrderProductTax) { + return $this + ->addUsingAlias(OrderProductTableMap::ID, $orderProductTax->getOrderProductId(), $comparison); + } elseif ($orderProductTax instanceof ObjectCollection) { + return $this + ->useOrderProductTaxQuery() + ->filterByPrimaryKeys($orderProductTax->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByOrderProductTax() only accepts arguments of type \Thelia\Model\OrderProductTax or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the OrderProductTax relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function joinOrderProductTax($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('OrderProductTax'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'OrderProductTax'); + } + + return $this; + } + + /** + * Use the OrderProductTax relation OrderProductTax object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\OrderProductTaxQuery A secondary query class using the current class as primary query + */ + public function useOrderProductTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrderProductTax($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'OrderProductTax', '\Thelia\Model\OrderProductTaxQuery'); } /** diff --git a/core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php deleted file mode 100644 index f87e8d59e..000000000 --- a/core/lib/Thelia/Model/Map/OrderAttributeCombinationTableMap.php +++ /dev/null @@ -1,503 +0,0 @@ - array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptumn', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptumn', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderAttributeCombinationTableMap::ID, OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderAttributeCombinationTableMap::CREATED_AT, OrderAttributeCombinationTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUMN', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptumn', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptumn' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptumn' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - self::TYPE_COLNAME => array(OrderAttributeCombinationTableMap::ID => 0, OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN => 5, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderAttributeCombinationTableMap::CREATED_AT => 10, OrderAttributeCombinationTableMap::UPDATED_AT => 11, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUMN' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptumn' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('order_attribute_combination'); - $this->setPhpName('OrderAttributeCombination'); - $this->setClassName('\\Thelia\\Model\\OrderAttributeCombination'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null); - $this->addColumn('ATTRIBUTE_TITLE', 'AttributeTitle', 'VARCHAR', true, 255, null); - $this->addColumn('ATTRIBUTE_CHAPO', 'AttributeChapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('ATTRIBUTE_DESCRIPTION', 'AttributeDescription', 'CLOB', false, null, null); - $this->addColumn('ATTRIBUTE_POSTSCRIPTUMN', 'AttributePostscriptumn', 'LONGVARCHAR', false, null, null); - $this->addColumn('ATTRIBUTE_AV_TITLE', 'AttributeAvTitle', 'VARCHAR', true, 255, null); - $this->addColumn('ATTRIBUTE_AV_CHAPO', 'AttributeAvChapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('ATTRIBUTE_AV_DESCRIPTION', 'AttributeAvDescription', 'CLOB', false, null, null); - $this->addColumn('ATTRIBUTE_AV_POSTSCRIPTUM', 'AttributeAvPostscriptum', 'LONGVARCHAR', false, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - 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) { - return null; - } - - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? OrderAttributeCombinationTableMap::CLASS_DEFAULT : OrderAttributeCombinationTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (OrderAttributeCombination object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = OrderAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + OrderAttributeCombinationTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderAttributeCombinationTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - OrderAttributeCombinationTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = OrderAttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = OrderAttributeCombinationTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderAttributeCombinationTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ID); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ORDER_PRODUCT_ID); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_TITLE); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_CHAPO); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::CREATED_AT); - $criteria->addSelectColumn(OrderAttributeCombinationTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_TITLE'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_CHAPO'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_DESCRIPTION'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUMN'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_TITLE'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_CHAPO'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_DESCRIPTION'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_POSTSCRIPTUM'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(OrderAttributeCombinationTableMap::DATABASE_NAME)->getTable(OrderAttributeCombinationTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderAttributeCombinationTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(OrderAttributeCombinationTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new OrderAttributeCombinationTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a OrderAttributeCombination or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderAttributeCombination object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\OrderAttributeCombination) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderAttributeCombinationTableMap::DATABASE_NAME); - $criteria->add(OrderAttributeCombinationTableMap::ID, (array) $values, Criteria::IN); - } - - $query = OrderAttributeCombinationQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { OrderAttributeCombinationTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { OrderAttributeCombinationTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the order_attribute_combination table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return OrderAttributeCombinationQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a OrderAttributeCombination or Criteria object. - * - * @param mixed $criteria Criteria or OrderAttributeCombination object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderAttributeCombinationTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from OrderAttributeCombination object - } - - if ($criteria->containsKey(OrderAttributeCombinationTableMap::ID) && $criteria->keyContainsValue(OrderAttributeCombinationTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAttributeCombinationTableMap::ID.')'); - } - - - // Set the correct dbName - $query = OrderAttributeCombinationQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // OrderAttributeCombinationTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -OrderAttributeCombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php index 3820ad081..8144f23a7 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 18; + const NUM_COLUMNS = 19; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 18; + const NUM_HYDRATE_COLUMNS = 19; /** * the column name for the ID field @@ -140,9 +140,14 @@ class OrderProductTableMap extends TableMap const WEIGHT = 'order_product.WEIGHT'; /** - * the column name for the TAX field + * the column name for the TAX_RULE_TITLE field */ - const TAX = 'order_product.TAX'; + const TAX_RULE_TITLE = 'order_product.TAX_RULE_TITLE'; + + /** + * the column name for the TAX_RULE_DESCRIPTION field + */ + const TAX_RULE_DESCRIPTION = 'order_product.TAX_RULE_DESCRIPTION'; /** * the column name for the PARENT field @@ -171,12 +176,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'tax', 'parent', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax', 'parent', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) + self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -186,12 +191,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'Tax' => 14, 'Parent' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'tax' => 14, 'parent' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX => 14, OrderProductTableMap::PARENT => 15, OrderProductTableMap::CREATED_AT => 16, OrderProductTableMap::UPDATED_AT => 17, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX' => 14, 'PARENT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax' => 14, 'parent' => 15, 'created_at' => 16, 'updated_at' => 17, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) ); /** @@ -224,7 +229,8 @@ class OrderProductTableMap extends TableMap $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null); $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null); $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null); - $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null); + $this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null); + $this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -236,7 +242,8 @@ class OrderProductTableMap extends TableMap public function buildRelations() { $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderAttributeCombination', '\\Thelia\\Model\\OrderAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderAttributeCombinations'); + $this->addRelation('OrderProductAttributeCombination', '\\Thelia\\Model\\OrderProductAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductAttributeCombinations'); + $this->addRelation('OrderProductTax', '\\Thelia\\Model\\OrderProductTax', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductTaxes'); } // buildRelations() /** @@ -258,7 +265,8 @@ class OrderProductTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderAttributeCombinationTableMap::clearInstancePool(); + OrderProductAttributeCombinationTableMap::clearInstancePool(); + OrderProductTaxTableMap::clearInstancePool(); } /** @@ -413,7 +421,8 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW); $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO); $criteria->addSelectColumn(OrderProductTableMap::WEIGHT); - $criteria->addSelectColumn(OrderProductTableMap::TAX); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE); + $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::PARENT); $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT); @@ -432,7 +441,8 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.WAS_NEW'); $criteria->addSelectColumn($alias . '.WAS_IN_PROMO'); $criteria->addSelectColumn($alias . '.WEIGHT'); - $criteria->addSelectColumn($alias . '.TAX'); + $criteria->addSelectColumn($alias . '.TAX_RULE_TITLE'); + $criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION'); $criteria->addSelectColumn($alias . '.PARENT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index a06230c37..c50a30c90 100644 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -143,7 +143,7 @@ class TaxI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 012ad2e72..24f8a41d7 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -143,7 +143,7 @@ class TaxRuleI18nTableMap extends TableMap $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); } // initialize() /** diff --git a/core/lib/Thelia/Model/OrderAttributeCombination.php b/core/lib/Thelia/Model/OrderAttributeCombination.php deleted file mode 100644 index 896cda895..000000000 --- a/core/lib/Thelia/Model/OrderAttributeCombination.php +++ /dev/null @@ -1,10 +0,0 @@ - - + @@ -110,7 +110,7 @@
- + @@ -607,7 +607,8 @@ - + + @@ -632,7 +633,7 @@
- +
@@ -643,10 +644,10 @@ - + - + @@ -1236,4 +1237,18 @@
+ + + + + + + + + + + + + +
From 854149930259ab6fcea3d253f03152233d8f5a33 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 20 Sep 2013 16:25:46 +0200 Subject: [PATCH 5/6] order process --- core/lib/Thelia/Action/Order.php | 89 ++++-------- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Config/Resources/routing/front.xml | 6 +- .../Controller/Front/OrderController.php | 33 +++++ core/lib/Thelia/Core/Event/OrderEvent.php | 17 +++ core/lib/Thelia/Core/Template/Loop/Cart.php | 10 +- core/lib/Thelia/Core/Template/Loop/Module.php | 137 ++++++++++++++++++ core/lib/Thelia/Core/Template/Loop/Order.php | 91 +++++++++++- core/lib/Thelia/Exception/OrderException.php | 3 - .../Thelia/Exception/TaxEngineException.php | 1 + .../Exception/TheliaProcessException.php | 54 +++++++ core/lib/Thelia/Model/Order.php | 26 +++- core/lib/Thelia/Model/OrderQuery.php | 39 ++++- core/lib/Thelia/Model/TaxRule.php | 20 ++- core/lib/Thelia/Model/TaxRuleQuery.php | 10 +- core/lib/Thelia/Module/BaseModule.php | 23 +++ core/lib/Thelia/TaxEngine/Calculator.php | 54 ++++++- .../TaxEngine/OrderProductTaxCollection.php | 126 ++++++++++++++++ .../Thelia/Tests/TaxEngine/CalculatorTest.php | 2 +- core/lib/Thelia/Tools/I18n.php | 37 +++++ install/insert.sql | 4 +- local/modules/Cheque/Cheque.php | 9 ++ local/modules/FakeCB/FakeCB.php | 9 ++ .../{order_payment.html => order_placed.html} | 12 +- 24 files changed, 718 insertions(+), 95 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Module.php create mode 100755 core/lib/Thelia/Exception/TheliaProcessException.php create mode 100755 core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php rename templates/default/{order_payment.html => order_placed.html} (85%) diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 17d8327c0..3b1ceb5da 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -24,20 +24,14 @@ namespace Thelia\Action; use Propel\Runtime\ActiveQuery\ModelCriteria; -use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Exception\OrderException; -use Thelia\Model\AttributeAvI18n; -use Thelia\Model\AttributeAvI18nQuery; -use Thelia\Model\AttributeI18n; -use Thelia\Model\AttributeI18nQuery; +use Thelia\Exception\TheliaProcessException; use Thelia\Model\AddressQuery; use Thelia\Model\OrderProductAttributeCombination; -use Thelia\Model\ProductI18nQuery; -use Thelia\Model\Lang; use Thelia\Model\ModuleQuery; use Thelia\Model\OrderProduct; use Thelia\Model\OrderStatus; @@ -45,7 +39,7 @@ use Thelia\Model\Map\OrderTableMap; use Thelia\Model\OrderAddress; use Thelia\Model\OrderStatusQuery; use Thelia\Model\ConfigQuery; -use Thelia\Model\ProductI18n; +use Thelia\Tools\I18n; /** * @@ -125,6 +119,7 @@ class Order extends BaseAction implements EventSubscriberInterface $currency = $this->getSession()->getCurrency(); $lang = $this->getSession()->getLang(); $deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress); + $taxCountry = $deliveryAddress->getCountry(); $invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress); $cart = $this->getSession()->getCart(); $cartItems = $cart->getCartItems(); @@ -182,23 +177,30 @@ class Order extends BaseAction implements EventSubscriberInterface foreach($cartItems as $cartItem) { $product = $cartItem->getProduct(); - /* get customer translation */ - $productI18n = $this->getI18n(ProductI18nQuery::create(), new ProductI18n(), $product->getId()); + /* get translation */ + $productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId()); $pse = $cartItem->getProductSaleElements(); /* check still in stock */ if($cartItem->getQuantity() > $pse->getQuantity()) { - $e = new OrderException("Not enough stock", OrderException::NOT_ENOUGH_STOCK); - $e->cartItem = $cartItem; - throw $e; + throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem); } /* decrease stock */ $pse->setQuantity( $pse->getQuantity() - $cartItem->getQuantity() ); - $pse->save(); + $pse->save($con); + + /* get tax */ + $taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId()); + + $taxDetail = $product->getTaxRule()->getTaxDetail( + $taxCountry, + $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(), + $this->getSession()->getLang()->getLocale() + ); $orderProduct = new OrderProduct(); $orderProduct @@ -215,14 +217,22 @@ class Order extends BaseAction implements EventSubscriberInterface ->setWasNew($pse->getNewness()) ->setWasInPromo($cartItem->getPromo()) ->setWeight($pse->getWeight()) + ->setTaxRuleTitle($taxRuleI18n->getTitle()) + ->setTaxRuleDescription($taxRuleI18n->getDescription()) ; $orderProduct->setDispatcher($this->getDispatcher()); - $orderProduct->save(); + $orderProduct->save($con); + + /* fulfill order_product_tax */ + foreach($taxDetail as $tax) { + $tax->setOrderProductId($orderProduct->getId()); + $tax->save($con); + } /* fulfill order_attribute_combination and decrease stock */ foreach($pse->getAttributeCombinations() as $attributeCombination) { - $attribute = $this->getI18n(AttributeI18nQuery::create(), new AttributeI18n(), $attributeCombination->getAttributeId()); - $attributeAv = $this->getI18n(AttributeAvI18nQuery::create(), new AttributeAvI18n(), $attributeCombination->getAttributeAvId()); + $attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId()); + $attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId()); $orderAttributeCombination = new OrderProductAttributeCombination(); $orderAttributeCombination @@ -237,7 +247,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setAttributeAvPostscriptum($attributeAv->getPostscriptum()) ; - $orderAttributeCombination->save(); + $orderAttributeCombination->save($con); } } @@ -248,12 +258,13 @@ class Order extends BaseAction implements EventSubscriberInterface $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); /* clear session */ + /* but memorize placed order */ $sessionOrder = new \Thelia\Model\Order(); $event->setOrder($sessionOrder); + $event->setPlacedOrder($placedOrder); $this->getSession()->setOrder($sessionOrder); - /* empty cart */ - $this->getSession()->getCart()->clear(); + /* empty cart @todo */ /* call pay method */ $paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace()); @@ -349,42 +360,4 @@ class Order extends BaseAction implements EventSubscriberInterface return $request->getSession(); } - - /** - * @param ModelCriteria $query - * @param ActiveRecordInterface $object - * @param $id - * @param array $needed = array('Title') - * - * @return ProductI18n - */ - protected function getI18n(ModelCriteria $query, ActiveRecordInterface $object, $id, $needed = array('Title')) - { - $i18n = $query - ->filterById($id) - ->filterByLocale( - $this->getSession()->getLang()->getLocale() - )->findOne(); - /* or default translation */ - if(null === $i18n) { - $i18n = $query - ->filterById($id) - ->filterByLocale( - Lang::getDefaultLanguage()->getLocale() - )->findOne(); - } - if(null === $i18n) { // @todo something else ? - $i18n = $object; - foreach($needed as $need) { - $method = sprintf('get%s', $need); - if(method_exists($i18n, $method)) { - $i18n->$method('DEFAULT ' . strtoupper($need)); - } else { - // @todo throw sg ? - } - } - } - - return $i18n; - } } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 43e48f6e4..329ed609d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -21,6 +21,7 @@ + diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index f254a817e..5b26a6ed6 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -137,7 +137,11 @@ Thelia\Controller\Front\OrderController::pay - order_payment + + + + Thelia\Controller\Front\OrderController::orderPlaced + order_placed diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php index 4dd678a82..1f2c716ae 100755 --- a/core/lib/Thelia/Controller/Front/OrderController.php +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Front; use Propel\Runtime\Exception\PropelException; +use Thelia\Exception\TheliaProcessException; use Thelia\Form\Exception\FormValidationException; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; @@ -32,9 +33,11 @@ use Thelia\Form\OrderPayment; use Thelia\Log\Tlog; use Thelia\Model\AddressQuery; use Thelia\Model\AreaDeliveryModuleQuery; +use Thelia\Model\Base\OrderQuery; use Thelia\Model\CountryQuery; use Thelia\Model\ModuleQuery; use Thelia\Model\Order; +use Thelia\Tools\URL; /** * Class OrderController @@ -187,6 +190,36 @@ class OrderController extends BaseFrontController $orderEvent = $this->getOrderEvent(); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent); + + $placedOrder = $orderEvent->getPlacedOrder(); + + if(null !== $placedOrder && null !== $placedOrder->getId()) { + /* order has been placed */ + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); + } else { + /* order has not been placed */ + $this->redirectToRoute("cart.view"); + } + } + + public function orderPlaced($order_id) + { + /* check if the placed order matched the customer */ + $placedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if(null === $placedOrder) { + throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); } protected function getOrderEvent() diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php index a156b753f..7089141bb 100755 --- a/core/lib/Thelia/Core/Event/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -28,6 +28,7 @@ use Thelia\Model\Order; class OrderEvent extends ActionEvent { protected $order = null; + protected $placedOrder = null; protected $invoiceAddress = null; protected $deliveryAddress = null; protected $deliveryModule = null; @@ -51,6 +52,14 @@ class OrderEvent extends ActionEvent $this->order = $order; } + /** + * @param Order $order + */ + public function setPlacedOrder(Order $order) + { + $this->placedOrder = $order; + } + /** * @param $address */ @@ -107,6 +116,14 @@ class OrderEvent extends ActionEvent return $this->order; } + /** + * @return null|Order + */ + public function getPlacedOrder() + { + return $this->placedOrder; + } + /** * @return null|int */ diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 16c108135..5c08b2896 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -81,6 +81,8 @@ class Cart extends BaseLoop return $result; } + $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic; + foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); $productSaleElement = $cartItem->getProductSaleElements(); @@ -97,12 +99,8 @@ class Cart extends BaseLoop ->set("STOCK", $productSaleElement->getQuantity()) ->set("PRICE", $cartItem->getPrice()) ->set("PROMO_PRICE", $cartItem->getPromoPrice()) - ->set("TAXED_PRICE", $cartItem->getTaxedPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) - ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice( - CountryQuery::create()->findOneById(64) // @TODO : make it magic - )) + ->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry)) + ->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry)) ->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $result->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php new file mode 100755 index 000000000..1c4f91b4d --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Module.php @@ -0,0 +1,137 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ModuleQuery; + +use Thelia\Module\BaseModule; +use Thelia\Type; + +/** + * + * Module loop + * + * + * Class Module + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Module extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'module_type', + new Type\TypeCollection( + new Type\EnumListType(array( + BaseModule::CLASSIC_MODULE_TYPE, + BaseModule::DELIVERY_MODULE_TYPE, + BaseModule::PAYMENT_MODULE_TYPE, + )) + ) + ), + Argument::createIntListTypeArgument('exclude'), + Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ModuleQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $moduleType = $this->getModule_type(); + + if (null !== $moduleType) { + $search->filterByType($moduleType, Criteria::IN); + } + + $exclude = $this->getExclude(); + + if (!is_null($exclude)) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $active = $this->getActive(); + + if($active !== Type\BooleanOrBothType::ANY) { + $search->filterByActivate($active ? 1 : 0, Criteria::EQUAL); + } + + $search->orderByPosition(); + + /* perform search */ + $modules = $this->search($search, $pagination); + + $loopResult = new LoopResult($modules); + + foreach ($modules as $module) { + $loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $module->getId()) + ->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("TITLE",$module->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("CODE", $module->getCode()) + ->set("TYPE", $module->getType()) + ->set("ACTIVE", $module->getActivate()) + ->set("CLASS", $module->getFullNamespace()) + ->set("POSITION", $module->getPosition()); + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index fd11d8d4c..41d49c4f8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -23,12 +23,16 @@ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Model\OrderQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; /** * * @package Thelia\Core\Template\Loop @@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument; */ class Order extends BaseLoop { + public $countable = true; + public $timestampable = true; + public $versionable = false; + public function getArgDefinitions() { - return new ArgumentCollection(); + return new ArgumentCollection( + Argument::createIntListTypeArgument('id'), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current')) + ), + 'current' + ), + Argument::createIntListTypeArgument('status') + ); } /** + * @param $pagination * - * - * @return \Thelia\Core\Template\Element\LoopResult + * @return LoopResult */ public function exec(&$pagination) { - // TODO : a coder ! - return new LoopResult(); + $search = OrderQuery::create(); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + if ($customer === 'current') { + $currentCustomer = $this->securityContext->getCustomerUser(); + if ($currentCustomer === null) { + return new LoopResult(); + } else { + $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); + } + } else { + $search->filterByCustomerId($customer, Criteria::EQUAL); + } + + $status = $this->getStatus(); + + if (null !== $status) { + $search->filterByStatusId($status, Criteria::IN); + } + + $orders = $this->search($search, $pagination); + + $loopResult = new LoopResult($orders); + + foreach ($orders as $order) { + $tax = 0; + $amount = $order->getTotalAmount($tax); + $loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $order->getId()) + ->set("REF", $order->getRef()) + ->set("CUSTOMER", $order->getCustomerId()) + ->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId()) + ->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId()) + ->set("INVOICE_DATE", $order->getInvoiceDate()) + ->set("CURRENCY", $order->getCurrencyId()) + ->set("CURRENCY_RATE", $order->getCurrencyRate()) + ->set("TRANSACTION_REF", $order->getTransactionRef()) + ->set("DELIVERY_REF", $order->getDeliveryRef()) + ->set("INVOICE_REF", $order->getInvoiceRef()) + ->set("POSTAGE", $order->getPostage()) + ->set("PAYMENT_MODULE", $order->getPaymentModuleId()) + ->set("DELIVERY_MODULE", $order->getDeliveryModuleId()) + ->set("STATUS", $order->getStatusId()) + ->set("LANG", $order->getLangId()) + ->set("POSTAGE", $order->getPostage()) + ->set("TOTAL_TAX", $tax) + ->set("TOTAL_AMOUNT", $amount - $tax) + ->set("TOTAL_TAXED_AMOUNT", $amount) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; } } diff --git a/core/lib/Thelia/Exception/OrderException.php b/core/lib/Thelia/Exception/OrderException.php index 68eb36474..70fd21c01 100755 --- a/core/lib/Thelia/Exception/OrderException.php +++ b/core/lib/Thelia/Exception/OrderException.php @@ -30,7 +30,6 @@ class OrderException extends \RuntimeException */ public $cartRoute = "cart.view"; public $orderDeliveryRoute = "order.delivery"; - public $cartItem = null; public $arguments = array(); @@ -40,8 +39,6 @@ class OrderException extends \RuntimeException const UNDEFINED_DELIVERY = 200; - const NOT_ENOUGH_STOCK = 300; - public function __construct($message, $code = null, $arguments = array(), $previous = null) { if(is_array($arguments)) { diff --git a/core/lib/Thelia/Exception/TaxEngineException.php b/core/lib/Thelia/Exception/TaxEngineException.php index 93f5b8237..86f8952b9 100755 --- a/core/lib/Thelia/Exception/TaxEngineException.php +++ b/core/lib/Thelia/Exception/TaxEngineException.php @@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException const UNDEFINED_TAX_RULES_COLLECTION = 503; const UNDEFINED_REQUIREMENTS = 504; const UNDEFINED_REQUIREMENT_VALUE = 505; + const UNDEFINED_TAX_RULE = 506; const BAD_AMOUNT_FORMAT = 601; diff --git a/core/lib/Thelia/Exception/TheliaProcessException.php b/core/lib/Thelia/Exception/TheliaProcessException.php new file mode 100755 index 000000000..f61224dea --- /dev/null +++ b/core/lib/Thelia/Exception/TheliaProcessException.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Exception; + +/** + * these exception are non fatal exception, due to thelia process exception + * or customer random navigation + * + * they redirect the customer who trig them to a specific error page // @todo + * + * Class TheliaProcessException + * @package Thelia\Exception + */ +class TheliaProcessException extends \RuntimeException +{ + public $data = null; + + const UNKNOWN_EXCEPTION = 0; + + const CART_ITEM_NOT_ENOUGH_STOCK = 100; + const NO_PLACED_ORDER = 101; + const PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER = 102; + + public function __construct($message, $code = null, $data = null, $previous = null) + { + $this->data = $data; + + if ($code === null) { + $code = self::UNKNOWN_EXCEPTION; + } + parent::__construct($message, $code, $previous); + } +} diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index f730c8853..5249a1366 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -2,11 +2,15 @@ namespace Thelia\Model; +use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Propel; use Thelia\Core\Event\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\Order as BaseOrder; +use Thelia\Model\Base\OrderProductTaxQuery; +use Thelia\Model\Map\OrderProductTaxTableMap; +use Thelia\Model\OrderProductQuery; use Thelia\Model\Map\OrderTableMap; use \PDO; @@ -38,13 +42,27 @@ class Order extends BaseOrder /** * calculate the total amount * - * @TODO create body method + * @param int $tax * - * @return int + * @return int|string|Base\double */ - public function getTotalAmount() + public function getTotalAmount(&$tax = 0) { - return 2; + $amount = 0; + $tax = 0; + + /* browse all products */ + $orderProductIds = array(); + foreach($this->getOrderProducts() as $orderProduct) { + $taxAmount = OrderProductTaxQuery::create() + ->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax') + ->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) + ->findOne(); + $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity(); + $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity(); + } + + return $amount + $tax + $this->getPostage(); // @todo : manage discount } /** diff --git a/core/lib/Thelia/Model/OrderQuery.php b/core/lib/Thelia/Model/OrderQuery.php index 13cb1cbf1..8d5e4c085 100755 --- a/core/lib/Thelia/Model/OrderQuery.php +++ b/core/lib/Thelia/Model/OrderQuery.php @@ -2,8 +2,11 @@ namespace Thelia\Model; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; use Thelia\Model\Base\OrderQuery as BaseOrderQuery; - +use \PDO; +use Thelia\Model\Map\OrderTableMap; /** * Skeleton subclass for performing query and update operations on the 'order' table. @@ -15,6 +18,38 @@ use Thelia\Model\Base\OrderQuery as BaseOrderQuery; * long as it does not already exist in the output directory. * */ -class OrderQuery extends BaseOrderQuery { +class OrderQuery extends BaseOrderQuery +{ + /** + * PROPEL SHOULD FIX IT + * + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return Order A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM `order` WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (\Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new Order(); + $obj->hydrate($row); + OrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + return $obj; + } } // OrderQuery diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php index 36f80a044..024fd8923 100755 --- a/core/lib/Thelia/Model/TaxRule.php +++ b/core/lib/Thelia/Model/TaxRule.php @@ -3,7 +3,25 @@ namespace Thelia\Model; use Thelia\Model\Base\TaxRule as BaseTaxRule; +use Thelia\TaxEngine\Calculator; +use Thelia\TaxEngine\OrderProductTaxCollection; -class TaxRule extends BaseTaxRule { +class TaxRule extends BaseTaxRule +{ + /** + * @param Country $country + * @param $untaxedAmount + * @param null $askedLocale + * + * @return OrderProductTaxCollection + */ + public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null) + { + $taxCalculator = new Calculator(); + $taxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale); + + return $taxCollection; + } } diff --git a/core/lib/Thelia/Model/TaxRuleQuery.php b/core/lib/Thelia/Model/TaxRuleQuery.php index d5ce47546..572500003 100755 --- a/core/lib/Thelia/Model/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/TaxRuleQuery.php @@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery { const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition'; - public function getTaxCalculatorCollection(Product $product, Country $country) + /** + * @param TaxRule $taxRule + * @param Country $country + * + * @return array|mixed|\Propel\Runtime\Collection\ObjectCollection + */ + public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country) { $search = TaxQuery::create() ->filterByTaxRuleCountry( TaxRuleCountryQuery::create() ->filterByCountry($country, Criteria::EQUAL) - ->filterByTaxRuleId($product->getTaxRuleId()) + ->filterByTaxRuleId($taxRule->getId()) ->orderByPosition() ->find() ) diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index f559c1fd5..8efc76e6e 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -25,7 +25,9 @@ namespace Thelia\Module; use Symfony\Component\DependencyInjection\ContainerAware; +use Thelia\Model\ModuleI18nQuery; use Thelia\Model\Map\ModuleImageTableMap; +use Thelia\Model\ModuleI18n; use Thelia\Tools\Image; use Thelia\Exception\ModuleException; use Thelia\Model\Module; @@ -76,6 +78,27 @@ abstract class BaseModule extends ContainerAware return $this->container; } + public function setTitle(Module $module, $titles) + { + if(is_array($titles)) { + foreach($titles as $locale => $title) { + $moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne(); + if(null === $moduleI18n) { + $moduleI18n = new ModuleI18n(); + $moduleI18n + ->setId($module->getId()) + ->setLocale($locale) + ->setTitle($title) + ; + $moduleI18n->save(); + } else { + $moduleI18n->setTitle($title); + $moduleI18n->save(); + } + } + } + } + public function deployImageFolder(Module $module, $folderPath) { try { diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php index b5a2f995e..8039dec39 100755 --- a/core/lib/Thelia/TaxEngine/Calculator.php +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -24,8 +24,11 @@ namespace Thelia\TaxEngine; use Thelia\Exception\TaxEngineException; use Thelia\Model\Country; +use Thelia\Model\OrderProductTax; use Thelia\Model\Product; +use Thelia\Model\TaxRule; use Thelia\Model\TaxRuleQuery; +use Thelia\Tools\I18n; /** * Class Calculator @@ -68,14 +71,34 @@ class Calculator $this->product = $product; $this->country = $country; - $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country); + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country); return $this; } - public function getTaxAmountFromUntaxedPrice($untaxedPrice) + public function loadTaxRule(TaxRule $taxRule, Country $country) { - return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice; + $this->product = null; + $this->country = null; + $this->taxRulesCollection = null; + + if($taxRule->getId() === null) { + throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); + } + if($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->country = $country; + + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); + + return $this; + } + + public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null) + { + return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice; } public function getTaxAmountFromTaxedPrice($taxedPrice) @@ -83,7 +106,15 @@ class Calculator return $taxedPrice - $this->getUntaxedPrice($taxedPrice); } - public function getTaxedPrice($untaxedPrice) + /** + * @param $untaxedPrice + * @param null $taxCollection returns OrderProductTaxCollection + * @param null $askedLocale + * + * @return int + * @throws \Thelia\Exception\TaxEngineException + */ + public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null) { if(null === $this->taxRulesCollection) { throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION); @@ -97,6 +128,9 @@ class Calculator $currentPosition = 1; $currentTax = 0; + if(null !== $taxCollection) { + $taxCollection = new OrderProductTaxCollection(); + } foreach($this->taxRulesCollection as $taxRule) { $position = (int)$taxRule->getTaxRuleCountryPosition(); @@ -109,7 +143,17 @@ class Calculator $currentPosition = $position; } - $currentTax += $taxType->calculate($taxedPrice); + $taxAmount = round($taxType->calculate($taxedPrice), 2); + $currentTax += $taxAmount; + + if(null !== $taxCollection) { + $taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId()); + $orderProductTax = new OrderProductTax(); + $orderProductTax->setTitle($taxI18n->getTitle()); + $orderProductTax->setDescription($taxI18n->getDescription()); + $orderProductTax->setAmount($taxAmount); + $taxCollection->addTax($orderProductTax); + } } $taxedPrice += $currentTax; diff --git a/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php new file mode 100755 index 000000000..5c4ac2022 --- /dev/null +++ b/core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +use Thelia\Model\OrderProductTax; + +/** + * + * @author Etienne Roudeix + * + */ +class OrderProductTaxCollection implements \Iterator +{ + private $position; + protected $taxes = array(); + + public function __construct() + { + foreach (func_get_args() as $tax) { + $this->addTax($tax); + } + } + + public function isEmpty() + { + return count($this->taxes) == 0; + } + + /** + * @param OrderProductTax $tax + * + * @return OrderProductTaxCollection + */ + public function addTax(OrderProductTax $tax) + { + $this->taxes[] = $tax; + + return $this; + } + + public function getCount() + { + return count($this->taxes); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return OrderProductTax + */ + public function current() + { + return $this->taxes[$this->position]; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + */ + public function next() + { + $this->position++; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + */ + public function key() + { + return $this->position; + } + + /** + * (PHP 5 >= 5.0.0)
+ * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + */ + public function valid() + { + return isset($this->taxes[$this->position]); + } + + /** + * (PHP 5 >= 5.0.0)
+ * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + */ + public function rewind() + { + $this->position = 0; + } + + public function getKey($key) + { + return isset($this->taxes[$key]) ? $this->taxes[$key] : null; + } +} diff --git a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php index 502b14c7e..f8c6ec6c0 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -86,7 +86,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection')); $taxRuleQuery->expects($this->once()) ->method('getTaxCalculatorCollection') - ->with($productQuery, $countryQuery) + ->with($productQuery->getTaxRule(), $countryQuery) ->will($this->returnValue('foo')); $rewritingUrlQuery = $this->getProperty('taxRuleQuery'); diff --git a/core/lib/Thelia/Tools/I18n.php b/core/lib/Thelia/Tools/I18n.php index 1f3ff57dd..aeb79ca84 100644 --- a/core/lib/Thelia/Tools/I18n.php +++ b/core/lib/Thelia/Tools/I18n.php @@ -23,6 +23,8 @@ namespace Thelia\Tools; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Propel\Runtime\ActiveRecord\ActiveRecordInterface; use Thelia\Model\Lang; /** @@ -54,4 +56,39 @@ class I18n return \DateTime::createFromFormat($currentDateFormat, $date); } + + public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title')) + { + $i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName); + $i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName); + + /* get customer language translation */ + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + $askedLocale + )->findOne(); + /* or default translation */ + if(null === $i18n) { + $i18n = $i18nQueryClass::create() + ->filterById($id) + ->filterByLocale( + Lang::getDefaultLanguage()->getLocale() + )->findOne(); + } + if(null === $i18n) { // @todo something else ? + $i18n = new $i18nClass();; + $i18n->setId($id); + foreach($needed as $need) { + $method = sprintf('set%s', $need); + if(method_exists($i18n, $method)) { + $i18n->$method('DEFAULT ' . strtoupper($need)); + } else { + // @todo throw sg ? + } + } + } + + return $i18n; + } } diff --git a/install/insert.sql b/install/insert.sql index aa7573d12..df252d366 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1153,7 +1153,7 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda INSERT INTO `tax_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES @@ -1162,7 +1162,7 @@ INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'french 19.6% tax'); INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`) VALUES diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index f4438db4e..4516c84f3 100755 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -71,6 +71,15 @@ class Cheque extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Cheque", + "fr_FR" => "Cheque", + ) + ); } public function destroy() diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index 7b304420c..329bbac41 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -71,6 +71,15 @@ class FakeCB extends BaseModule implements PaymentModuleInterface if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); } + + /* set module title */ + $this->setTitle( + $module, + array( + "en_US" => "Credit Card", + "fr_FR" => "Credit Card", + ) + ); } public function destroy() diff --git a/templates/default/order_payment.html b/templates/default/order_placed.html similarity index 85% rename from templates/default/order_payment.html rename to templates/default/order_placed.html index 884230258..c4a26af67 100644 --- a/templates/default/order_payment.html +++ b/templates/default/order_placed.html @@ -24,9 +24,11 @@ 4 Secure payment + {loop type="order" name="placed-order" id=$placed_order_id} +
-

You chose to pay by : Cheque

+

You chose to pay by : {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}

Thank you for the trust you place in us.

@@ -35,15 +37,17 @@
Order number :
-
PRO123456788978979
+
{$REF}
Date :
-
02/12/2013
+
{format_date date=$CREATE_DATE output="date"}
Total :
-
$216.25
+
{loop type="currency" name="order-currency" id=$CURRENCY}{$SYMBOL}{/loop} {$TOTAL_TAXED_AMOUNT}
+ {/loop} + Go home From 61191b9d326407f50a18b9152cd28608286df81c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Fri, 20 Sep 2013 16:31:19 +0200 Subject: [PATCH 6/6] fixes order integration --- local/modules/FakeCB/FakeCB.php | 2 +- templates/default/order_placed.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index 329bbac41..ca682fab3 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -77,7 +77,7 @@ class FakeCB extends BaseModule implements PaymentModuleInterface $module, array( "en_US" => "Credit Card", - "fr_FR" => "Credit Card", + "fr_FR" => "Carte de crédit", ) ); } diff --git a/templates/default/order_placed.html b/templates/default/order_placed.html index c4a26af67..281800bb5 100644 --- a/templates/default/order_placed.html +++ b/templates/default/order_placed.html @@ -32,7 +32,7 @@

Thank you for the trust you place in us.

-

A summary of your order email has been sent to the following address: email@toto.com

+

A summary of your order email has been sent to the following address: {customer attr="email"}

Your order will be confirmed by us upon receipt of your payment.