cart is persist now
This commit is contained in:
@@ -10,6 +10,7 @@ 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;
|
||||
@@ -18,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Address as ChildAddress;
|
||||
use Thelia\Model\AddressQuery as ChildAddressQuery;
|
||||
use Thelia\Model\Cart as ChildCart;
|
||||
use Thelia\Model\CartQuery as ChildCartQuery;
|
||||
use Thelia\Model\Customer as ChildCustomer;
|
||||
use Thelia\Model\CustomerQuery as ChildCustomerQuery;
|
||||
use Thelia\Model\CustomerTitle as ChildCustomerTitle;
|
||||
@@ -149,11 +152,11 @@ abstract class Address implements ActiveRecordInterface
|
||||
protected $cellphone;
|
||||
|
||||
/**
|
||||
* The value for the is_default field.
|
||||
* The value for the default field.
|
||||
* Note: this column has a database default value of: 0
|
||||
* @var int
|
||||
*/
|
||||
protected $is_default;
|
||||
protected $default;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
@@ -177,6 +180,18 @@ abstract class Address implements ActiveRecordInterface
|
||||
*/
|
||||
protected $aCustomerTitle;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects.
|
||||
*/
|
||||
protected $collCartsRelatedByAddressDeliveryId;
|
||||
protected $collCartsRelatedByAddressDeliveryIdPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects.
|
||||
*/
|
||||
protected $collCartsRelatedByAddressInvoiceId;
|
||||
protected $collCartsRelatedByAddressInvoiceIdPartial;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -185,6 +200,18 @@ abstract class Address implements ActiveRecordInterface
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartsRelatedByAddressDeliveryIdScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartsRelatedByAddressInvoiceIdScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
@@ -193,7 +220,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->is_default = 0;
|
||||
$this->default = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,14 +645,14 @@ abstract class Address implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_default] column value.
|
||||
* Get the [default] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIsDefault()
|
||||
public function getDefault()
|
||||
{
|
||||
|
||||
return $this->is_default;
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -992,25 +1019,25 @@ abstract class Address implements ActiveRecordInterface
|
||||
} // setCellphone()
|
||||
|
||||
/**
|
||||
* Set the value of [is_default] column.
|
||||
* Set the value of [default] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return \Thelia\Model\Address The current object (for fluent API support)
|
||||
*/
|
||||
public function setIsDefault($v)
|
||||
public function setDefault($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->is_default !== $v) {
|
||||
$this->is_default = $v;
|
||||
$this->modifiedColumns[] = AddressTableMap::IS_DEFAULT;
|
||||
if ($this->default !== $v) {
|
||||
$this->default = $v;
|
||||
$this->modifiedColumns[] = AddressTableMap::DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setIsDefault()
|
||||
} // setDefault()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
@@ -1064,7 +1091,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->is_default !== 0) {
|
||||
if ($this->default !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1140,8 +1167,8 @@ abstract class Address implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->cellphone = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->is_default = (null !== $col) ? (int) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('Default', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->default = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : AddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
@@ -1231,6 +1258,10 @@ abstract class Address implements ActiveRecordInterface
|
||||
|
||||
$this->aCustomer = null;
|
||||
$this->aCustomerTitle = null;
|
||||
$this->collCartsRelatedByAddressDeliveryId = null;
|
||||
|
||||
$this->collCartsRelatedByAddressInvoiceId = null;
|
||||
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1383,6 +1414,42 @@ abstract class Address implements ActiveRecordInterface
|
||||
$this->resetModified();
|
||||
}
|
||||
|
||||
if ($this->cartsRelatedByAddressDeliveryIdScheduledForDeletion !== null) {
|
||||
if (!$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsRelatedByAddressDeliveryIdScheduledForDeletion as $cartRelatedByAddressDeliveryId) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cartRelatedByAddressDeliveryId->save($con);
|
||||
}
|
||||
$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCartsRelatedByAddressDeliveryId !== null) {
|
||||
foreach ($this->collCartsRelatedByAddressDeliveryId as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->cartsRelatedByAddressInvoiceIdScheduledForDeletion !== null) {
|
||||
if (!$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsRelatedByAddressInvoiceIdScheduledForDeletion as $cartRelatedByAddressInvoiceId) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cartRelatedByAddressInvoiceId->save($con);
|
||||
}
|
||||
$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCartsRelatedByAddressInvoiceId !== null) {
|
||||
foreach ($this->collCartsRelatedByAddressInvoiceId as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
}
|
||||
@@ -1454,8 +1521,8 @@ abstract class Address implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(AddressTableMap::CELLPHONE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CELLPHONE';
|
||||
}
|
||||
if ($this->isColumnModified(AddressTableMap::IS_DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
|
||||
if ($this->isColumnModified(AddressTableMap::DEFAULT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'DEFAULT';
|
||||
}
|
||||
if ($this->isColumnModified(AddressTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
@@ -1519,8 +1586,8 @@ abstract class Address implements ActiveRecordInterface
|
||||
case 'CELLPHONE':
|
||||
$stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'IS_DEFAULT':
|
||||
$stmt->bindValue($identifier, $this->is_default, PDO::PARAM_INT);
|
||||
case 'DEFAULT':
|
||||
$stmt->bindValue($identifier, $this->default, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
@@ -1636,7 +1703,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
return $this->getCellphone();
|
||||
break;
|
||||
case 15:
|
||||
return $this->getIsDefault();
|
||||
return $this->getDefault();
|
||||
break;
|
||||
case 16:
|
||||
return $this->getCreatedAt();
|
||||
@@ -1688,7 +1755,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
$keys[12] => $this->getCountryId(),
|
||||
$keys[13] => $this->getPhone(),
|
||||
$keys[14] => $this->getCellphone(),
|
||||
$keys[15] => $this->getIsDefault(),
|
||||
$keys[15] => $this->getDefault(),
|
||||
$keys[16] => $this->getCreatedAt(),
|
||||
$keys[17] => $this->getUpdatedAt(),
|
||||
);
|
||||
@@ -1705,6 +1772,12 @@ abstract class Address implements ActiveRecordInterface
|
||||
if (null !== $this->aCustomerTitle) {
|
||||
$result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
|
||||
}
|
||||
if (null !== $this->collCartsRelatedByAddressDeliveryId) {
|
||||
$result['CartsRelatedByAddressDeliveryId'] = $this->collCartsRelatedByAddressDeliveryId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCartsRelatedByAddressInvoiceId) {
|
||||
$result['CartsRelatedByAddressInvoiceId'] = $this->collCartsRelatedByAddressInvoiceId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -1785,7 +1858,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
$this->setCellphone($value);
|
||||
break;
|
||||
case 15:
|
||||
$this->setIsDefault($value);
|
||||
$this->setDefault($value);
|
||||
break;
|
||||
case 16:
|
||||
$this->setCreatedAt($value);
|
||||
@@ -1832,7 +1905,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]);
|
||||
if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]);
|
||||
if (array_key_exists($keys[14], $arr)) $this->setCellphone($arr[$keys[14]]);
|
||||
if (array_key_exists($keys[15], $arr)) $this->setIsDefault($arr[$keys[15]]);
|
||||
if (array_key_exists($keys[15], $arr)) $this->setDefault($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]]);
|
||||
}
|
||||
@@ -1861,7 +1934,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) $criteria->add(AddressTableMap::COUNTRY_ID, $this->country_id);
|
||||
if ($this->isColumnModified(AddressTableMap::PHONE)) $criteria->add(AddressTableMap::PHONE, $this->phone);
|
||||
if ($this->isColumnModified(AddressTableMap::CELLPHONE)) $criteria->add(AddressTableMap::CELLPHONE, $this->cellphone);
|
||||
if ($this->isColumnModified(AddressTableMap::IS_DEFAULT)) $criteria->add(AddressTableMap::IS_DEFAULT, $this->is_default);
|
||||
if ($this->isColumnModified(AddressTableMap::DEFAULT)) $criteria->add(AddressTableMap::DEFAULT, $this->default);
|
||||
if ($this->isColumnModified(AddressTableMap::CREATED_AT)) $criteria->add(AddressTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) $criteria->add(AddressTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1941,9 +2014,29 @@ abstract class Address implements ActiveRecordInterface
|
||||
$copyObj->setCountryId($this->getCountryId());
|
||||
$copyObj->setPhone($this->getPhone());
|
||||
$copyObj->setCellphone($this->getCellphone());
|
||||
$copyObj->setIsDefault($this->getIsDefault());
|
||||
$copyObj->setDefault($this->getDefault());
|
||||
$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->getCartsRelatedByAddressDeliveryId() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCartRelatedByAddressDeliveryId($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCartsRelatedByAddressInvoiceId() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCartRelatedByAddressInvoiceId($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
} // if ($deepCopy)
|
||||
|
||||
if ($makeNew) {
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
@@ -2074,6 +2167,561 @@ abstract class Address implements ActiveRecordInterface
|
||||
return $this->aCustomerTitle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 ('CartRelatedByAddressDeliveryId' == $relationName) {
|
||||
return $this->initCartsRelatedByAddressDeliveryId();
|
||||
}
|
||||
if ('CartRelatedByAddressInvoiceId' == $relationName) {
|
||||
return $this->initCartsRelatedByAddressInvoiceId();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCartsRelatedByAddressDeliveryId 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 addCartsRelatedByAddressDeliveryId()
|
||||
*/
|
||||
public function clearCartsRelatedByAddressDeliveryId()
|
||||
{
|
||||
$this->collCartsRelatedByAddressDeliveryId = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCartsRelatedByAddressDeliveryId collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCartsRelatedByAddressDeliveryId($v = true)
|
||||
{
|
||||
$this->collCartsRelatedByAddressDeliveryIdPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCartsRelatedByAddressDeliveryId collection.
|
||||
*
|
||||
* By default this just sets the collCartsRelatedByAddressDeliveryId collection to an empty array (like clearcollCartsRelatedByAddressDeliveryId());
|
||||
* 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 initCartsRelatedByAddressDeliveryId($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCartsRelatedByAddressDeliveryId && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCartsRelatedByAddressDeliveryId = new ObjectCollection();
|
||||
$this->collCartsRelatedByAddressDeliveryId->setModel('\Thelia\Model\Cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCart 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 ChildAddress 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|ChildCart[] List of ChildCart objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCartsRelatedByAddressDeliveryId($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsRelatedByAddressDeliveryIdPartial && !$this->isNew();
|
||||
if (null === $this->collCartsRelatedByAddressDeliveryId || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartsRelatedByAddressDeliveryId) {
|
||||
// return empty collection
|
||||
$this->initCartsRelatedByAddressDeliveryId();
|
||||
} else {
|
||||
$collCartsRelatedByAddressDeliveryId = ChildCartQuery::create(null, $criteria)
|
||||
->filterByAddressRelatedByAddressDeliveryId($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartsRelatedByAddressDeliveryIdPartial && count($collCartsRelatedByAddressDeliveryId)) {
|
||||
$this->initCartsRelatedByAddressDeliveryId(false);
|
||||
|
||||
foreach ($collCartsRelatedByAddressDeliveryId as $obj) {
|
||||
if (false == $this->collCartsRelatedByAddressDeliveryId->contains($obj)) {
|
||||
$this->collCartsRelatedByAddressDeliveryId->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressDeliveryIdPartial = true;
|
||||
}
|
||||
|
||||
$collCartsRelatedByAddressDeliveryId->getInternalIterator()->rewind();
|
||||
|
||||
return $collCartsRelatedByAddressDeliveryId;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCartsRelatedByAddressDeliveryId) {
|
||||
foreach ($this->collCartsRelatedByAddressDeliveryId as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCartsRelatedByAddressDeliveryId[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressDeliveryId = $collCartsRelatedByAddressDeliveryId;
|
||||
$this->collCartsRelatedByAddressDeliveryIdPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCartsRelatedByAddressDeliveryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CartRelatedByAddressDeliveryId 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 $cartsRelatedByAddressDeliveryId A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildAddress The current object (for fluent API support)
|
||||
*/
|
||||
public function setCartsRelatedByAddressDeliveryId(Collection $cartsRelatedByAddressDeliveryId, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartsRelatedByAddressDeliveryIdToDelete = $this->getCartsRelatedByAddressDeliveryId(new Criteria(), $con)->diff($cartsRelatedByAddressDeliveryId);
|
||||
|
||||
|
||||
$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion = $cartsRelatedByAddressDeliveryIdToDelete;
|
||||
|
||||
foreach ($cartsRelatedByAddressDeliveryIdToDelete as $cartRelatedByAddressDeliveryIdRemoved) {
|
||||
$cartRelatedByAddressDeliveryIdRemoved->setAddressRelatedByAddressDeliveryId(null);
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressDeliveryId = null;
|
||||
foreach ($cartsRelatedByAddressDeliveryId as $cartRelatedByAddressDeliveryId) {
|
||||
$this->addCartRelatedByAddressDeliveryId($cartRelatedByAddressDeliveryId);
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressDeliveryId = $cartsRelatedByAddressDeliveryId;
|
||||
$this->collCartsRelatedByAddressDeliveryIdPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related Cart objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related Cart objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCartsRelatedByAddressDeliveryId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsRelatedByAddressDeliveryIdPartial && !$this->isNew();
|
||||
if (null === $this->collCartsRelatedByAddressDeliveryId || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartsRelatedByAddressDeliveryId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCartsRelatedByAddressDeliveryId());
|
||||
}
|
||||
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByAddressRelatedByAddressDeliveryId($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCartsRelatedByAddressDeliveryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCart object to this object
|
||||
* through the ChildCart foreign key attribute.
|
||||
*
|
||||
* @param ChildCart $l ChildCart
|
||||
* @return \Thelia\Model\Address The current object (for fluent API support)
|
||||
*/
|
||||
public function addCartRelatedByAddressDeliveryId(ChildCart $l)
|
||||
{
|
||||
if ($this->collCartsRelatedByAddressDeliveryId === null) {
|
||||
$this->initCartsRelatedByAddressDeliveryId();
|
||||
$this->collCartsRelatedByAddressDeliveryIdPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCartsRelatedByAddressDeliveryId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCartRelatedByAddressDeliveryId($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartRelatedByAddressDeliveryId $cartRelatedByAddressDeliveryId The cartRelatedByAddressDeliveryId object to add.
|
||||
*/
|
||||
protected function doAddCartRelatedByAddressDeliveryId($cartRelatedByAddressDeliveryId)
|
||||
{
|
||||
$this->collCartsRelatedByAddressDeliveryId[]= $cartRelatedByAddressDeliveryId;
|
||||
$cartRelatedByAddressDeliveryId->setAddressRelatedByAddressDeliveryId($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartRelatedByAddressDeliveryId $cartRelatedByAddressDeliveryId The cartRelatedByAddressDeliveryId object to remove.
|
||||
* @return ChildAddress The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCartRelatedByAddressDeliveryId($cartRelatedByAddressDeliveryId)
|
||||
{
|
||||
if ($this->getCartsRelatedByAddressDeliveryId()->contains($cartRelatedByAddressDeliveryId)) {
|
||||
$this->collCartsRelatedByAddressDeliveryId->remove($this->collCartsRelatedByAddressDeliveryId->search($cartRelatedByAddressDeliveryId));
|
||||
if (null === $this->cartsRelatedByAddressDeliveryIdScheduledForDeletion) {
|
||||
$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion = clone $this->collCartsRelatedByAddressDeliveryId;
|
||||
$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartsRelatedByAddressDeliveryIdScheduledForDeletion[]= $cartRelatedByAddressDeliveryId;
|
||||
$cartRelatedByAddressDeliveryId->setAddressRelatedByAddressDeliveryId(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Address is new, it will return
|
||||
* an empty collection; or if this Address has previously
|
||||
* been saved, it will retrieve related CartsRelatedByAddressDeliveryId from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Address.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsRelatedByAddressDeliveryIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Customer', $joinBehavior);
|
||||
|
||||
return $this->getCartsRelatedByAddressDeliveryId($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Address is new, it will return
|
||||
* an empty collection; or if this Address has previously
|
||||
* been saved, it will retrieve related CartsRelatedByAddressDeliveryId from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Address.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsRelatedByAddressDeliveryIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Currency', $joinBehavior);
|
||||
|
||||
return $this->getCartsRelatedByAddressDeliveryId($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCartsRelatedByAddressInvoiceId 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 addCartsRelatedByAddressInvoiceId()
|
||||
*/
|
||||
public function clearCartsRelatedByAddressInvoiceId()
|
||||
{
|
||||
$this->collCartsRelatedByAddressInvoiceId = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCartsRelatedByAddressInvoiceId collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCartsRelatedByAddressInvoiceId($v = true)
|
||||
{
|
||||
$this->collCartsRelatedByAddressInvoiceIdPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCartsRelatedByAddressInvoiceId collection.
|
||||
*
|
||||
* By default this just sets the collCartsRelatedByAddressInvoiceId collection to an empty array (like clearcollCartsRelatedByAddressInvoiceId());
|
||||
* 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 initCartsRelatedByAddressInvoiceId($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCartsRelatedByAddressInvoiceId && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCartsRelatedByAddressInvoiceId = new ObjectCollection();
|
||||
$this->collCartsRelatedByAddressInvoiceId->setModel('\Thelia\Model\Cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCart 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 ChildAddress 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|ChildCart[] List of ChildCart objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCartsRelatedByAddressInvoiceId($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsRelatedByAddressInvoiceIdPartial && !$this->isNew();
|
||||
if (null === $this->collCartsRelatedByAddressInvoiceId || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartsRelatedByAddressInvoiceId) {
|
||||
// return empty collection
|
||||
$this->initCartsRelatedByAddressInvoiceId();
|
||||
} else {
|
||||
$collCartsRelatedByAddressInvoiceId = ChildCartQuery::create(null, $criteria)
|
||||
->filterByAddressRelatedByAddressInvoiceId($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartsRelatedByAddressInvoiceIdPartial && count($collCartsRelatedByAddressInvoiceId)) {
|
||||
$this->initCartsRelatedByAddressInvoiceId(false);
|
||||
|
||||
foreach ($collCartsRelatedByAddressInvoiceId as $obj) {
|
||||
if (false == $this->collCartsRelatedByAddressInvoiceId->contains($obj)) {
|
||||
$this->collCartsRelatedByAddressInvoiceId->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressInvoiceIdPartial = true;
|
||||
}
|
||||
|
||||
$collCartsRelatedByAddressInvoiceId->getInternalIterator()->rewind();
|
||||
|
||||
return $collCartsRelatedByAddressInvoiceId;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCartsRelatedByAddressInvoiceId) {
|
||||
foreach ($this->collCartsRelatedByAddressInvoiceId as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCartsRelatedByAddressInvoiceId[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressInvoiceId = $collCartsRelatedByAddressInvoiceId;
|
||||
$this->collCartsRelatedByAddressInvoiceIdPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCartsRelatedByAddressInvoiceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CartRelatedByAddressInvoiceId 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 $cartsRelatedByAddressInvoiceId A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildAddress The current object (for fluent API support)
|
||||
*/
|
||||
public function setCartsRelatedByAddressInvoiceId(Collection $cartsRelatedByAddressInvoiceId, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartsRelatedByAddressInvoiceIdToDelete = $this->getCartsRelatedByAddressInvoiceId(new Criteria(), $con)->diff($cartsRelatedByAddressInvoiceId);
|
||||
|
||||
|
||||
$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion = $cartsRelatedByAddressInvoiceIdToDelete;
|
||||
|
||||
foreach ($cartsRelatedByAddressInvoiceIdToDelete as $cartRelatedByAddressInvoiceIdRemoved) {
|
||||
$cartRelatedByAddressInvoiceIdRemoved->setAddressRelatedByAddressInvoiceId(null);
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressInvoiceId = null;
|
||||
foreach ($cartsRelatedByAddressInvoiceId as $cartRelatedByAddressInvoiceId) {
|
||||
$this->addCartRelatedByAddressInvoiceId($cartRelatedByAddressInvoiceId);
|
||||
}
|
||||
|
||||
$this->collCartsRelatedByAddressInvoiceId = $cartsRelatedByAddressInvoiceId;
|
||||
$this->collCartsRelatedByAddressInvoiceIdPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related Cart objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related Cart objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCartsRelatedByAddressInvoiceId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsRelatedByAddressInvoiceIdPartial && !$this->isNew();
|
||||
if (null === $this->collCartsRelatedByAddressInvoiceId || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartsRelatedByAddressInvoiceId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCartsRelatedByAddressInvoiceId());
|
||||
}
|
||||
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByAddressRelatedByAddressInvoiceId($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCartsRelatedByAddressInvoiceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCart object to this object
|
||||
* through the ChildCart foreign key attribute.
|
||||
*
|
||||
* @param ChildCart $l ChildCart
|
||||
* @return \Thelia\Model\Address The current object (for fluent API support)
|
||||
*/
|
||||
public function addCartRelatedByAddressInvoiceId(ChildCart $l)
|
||||
{
|
||||
if ($this->collCartsRelatedByAddressInvoiceId === null) {
|
||||
$this->initCartsRelatedByAddressInvoiceId();
|
||||
$this->collCartsRelatedByAddressInvoiceIdPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCartsRelatedByAddressInvoiceId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCartRelatedByAddressInvoiceId($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartRelatedByAddressInvoiceId $cartRelatedByAddressInvoiceId The cartRelatedByAddressInvoiceId object to add.
|
||||
*/
|
||||
protected function doAddCartRelatedByAddressInvoiceId($cartRelatedByAddressInvoiceId)
|
||||
{
|
||||
$this->collCartsRelatedByAddressInvoiceId[]= $cartRelatedByAddressInvoiceId;
|
||||
$cartRelatedByAddressInvoiceId->setAddressRelatedByAddressInvoiceId($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartRelatedByAddressInvoiceId $cartRelatedByAddressInvoiceId The cartRelatedByAddressInvoiceId object to remove.
|
||||
* @return ChildAddress The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCartRelatedByAddressInvoiceId($cartRelatedByAddressInvoiceId)
|
||||
{
|
||||
if ($this->getCartsRelatedByAddressInvoiceId()->contains($cartRelatedByAddressInvoiceId)) {
|
||||
$this->collCartsRelatedByAddressInvoiceId->remove($this->collCartsRelatedByAddressInvoiceId->search($cartRelatedByAddressInvoiceId));
|
||||
if (null === $this->cartsRelatedByAddressInvoiceIdScheduledForDeletion) {
|
||||
$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion = clone $this->collCartsRelatedByAddressInvoiceId;
|
||||
$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartsRelatedByAddressInvoiceIdScheduledForDeletion[]= $cartRelatedByAddressInvoiceId;
|
||||
$cartRelatedByAddressInvoiceId->setAddressRelatedByAddressInvoiceId(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Address is new, it will return
|
||||
* an empty collection; or if this Address has previously
|
||||
* been saved, it will retrieve related CartsRelatedByAddressInvoiceId from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Address.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsRelatedByAddressInvoiceIdJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Customer', $joinBehavior);
|
||||
|
||||
return $this->getCartsRelatedByAddressInvoiceId($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Address is new, it will return
|
||||
* an empty collection; or if this Address has previously
|
||||
* been saved, it will retrieve related CartsRelatedByAddressInvoiceId from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Address.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsRelatedByAddressInvoiceIdJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Currency', $joinBehavior);
|
||||
|
||||
return $this->getCartsRelatedByAddressInvoiceId($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -2094,7 +2742,7 @@ abstract class Address implements ActiveRecordInterface
|
||||
$this->country_id = null;
|
||||
$this->phone = null;
|
||||
$this->cellphone = null;
|
||||
$this->is_default = null;
|
||||
$this->default = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
@@ -2117,8 +2765,26 @@ abstract class Address implements ActiveRecordInterface
|
||||
public function clearAllReferences($deep = false)
|
||||
{
|
||||
if ($deep) {
|
||||
if ($this->collCartsRelatedByAddressDeliveryId) {
|
||||
foreach ($this->collCartsRelatedByAddressDeliveryId as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCartsRelatedByAddressInvoiceId) {
|
||||
foreach ($this->collCartsRelatedByAddressInvoiceId as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
if ($this->collCartsRelatedByAddressDeliveryId instanceof Collection) {
|
||||
$this->collCartsRelatedByAddressDeliveryId->clearIterator();
|
||||
}
|
||||
$this->collCartsRelatedByAddressDeliveryId = null;
|
||||
if ($this->collCartsRelatedByAddressInvoiceId instanceof Collection) {
|
||||
$this->collCartsRelatedByAddressInvoiceId->clearIterator();
|
||||
}
|
||||
$this->collCartsRelatedByAddressInvoiceId = null;
|
||||
$this->aCustomer = null;
|
||||
$this->aCustomerTitle = null;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ use Thelia\Model\Map\AddressTableMap;
|
||||
* @method ChildAddressQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
|
||||
* @method ChildAddressQuery orderByPhone($order = Criteria::ASC) Order by the phone column
|
||||
* @method ChildAddressQuery orderByCellphone($order = Criteria::ASC) Order by the cellphone column
|
||||
* @method ChildAddressQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
|
||||
* @method ChildAddressQuery orderByDefault($order = Criteria::ASC) Order by the default column
|
||||
* @method ChildAddressQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildAddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -55,7 +55,7 @@ use Thelia\Model\Map\AddressTableMap;
|
||||
* @method ChildAddressQuery groupByCountryId() Group by the country_id column
|
||||
* @method ChildAddressQuery groupByPhone() Group by the phone column
|
||||
* @method ChildAddressQuery groupByCellphone() Group by the cellphone column
|
||||
* @method ChildAddressQuery groupByIsDefault() Group by the is_default column
|
||||
* @method ChildAddressQuery groupByDefault() Group by the default column
|
||||
* @method ChildAddressQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildAddressQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -71,6 +71,14 @@ use Thelia\Model\Map\AddressTableMap;
|
||||
* @method ChildAddressQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation
|
||||
* @method ChildAddressQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation
|
||||
*
|
||||
* @method ChildAddressQuery leftJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartRelatedByAddressDeliveryId relation
|
||||
* @method ChildAddressQuery rightJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartRelatedByAddressDeliveryId relation
|
||||
* @method ChildAddressQuery innerJoinCartRelatedByAddressDeliveryId($relationAlias = null) Adds a INNER JOIN clause to the query using the CartRelatedByAddressDeliveryId relation
|
||||
*
|
||||
* @method ChildAddressQuery leftJoinCartRelatedByAddressInvoiceId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartRelatedByAddressInvoiceId relation
|
||||
* @method ChildAddressQuery rightJoinCartRelatedByAddressInvoiceId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartRelatedByAddressInvoiceId relation
|
||||
* @method ChildAddressQuery innerJoinCartRelatedByAddressInvoiceId($relationAlias = null) Adds a INNER JOIN clause to the query using the CartRelatedByAddressInvoiceId relation
|
||||
*
|
||||
* @method ChildAddress findOne(ConnectionInterface $con = null) Return the first ChildAddress matching the query
|
||||
* @method ChildAddress findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAddress matching the query, or a new ChildAddress object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -89,7 +97,7 @@ use Thelia\Model\Map\AddressTableMap;
|
||||
* @method ChildAddress findOneByCountryId(int $country_id) Return the first ChildAddress filtered by the country_id column
|
||||
* @method ChildAddress findOneByPhone(string $phone) Return the first ChildAddress filtered by the phone column
|
||||
* @method ChildAddress findOneByCellphone(string $cellphone) Return the first ChildAddress filtered by the cellphone column
|
||||
* @method ChildAddress findOneByIsDefault(int $is_default) Return the first ChildAddress filtered by the is_default column
|
||||
* @method ChildAddress findOneByDefault(int $default) Return the first ChildAddress filtered by the default column
|
||||
* @method ChildAddress findOneByCreatedAt(string $created_at) Return the first ChildAddress filtered by the created_at column
|
||||
* @method ChildAddress findOneByUpdatedAt(string $updated_at) Return the first ChildAddress filtered by the updated_at column
|
||||
*
|
||||
@@ -108,7 +116,7 @@ use Thelia\Model\Map\AddressTableMap;
|
||||
* @method array findByCountryId(int $country_id) Return ChildAddress objects filtered by the country_id column
|
||||
* @method array findByPhone(string $phone) Return ChildAddress objects filtered by the phone column
|
||||
* @method array findByCellphone(string $cellphone) Return ChildAddress objects filtered by the cellphone column
|
||||
* @method array findByIsDefault(int $is_default) Return ChildAddress objects filtered by the is_default column
|
||||
* @method array findByDefault(int $default) Return ChildAddress objects filtered by the default column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildAddress objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildAddress objects filtered by the updated_at column
|
||||
*
|
||||
@@ -199,7 +207,7 @@ abstract class AddressQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, DEFAULT, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -776,16 +784,16 @@ abstract class AddressQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the is_default column
|
||||
* Filter the query on the default column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByIsDefault(1234); // WHERE is_default = 1234
|
||||
* $query->filterByIsDefault(array(12, 34)); // WHERE is_default IN (12, 34)
|
||||
* $query->filterByIsDefault(array('min' => 12)); // WHERE is_default > 12
|
||||
* $query->filterByDefault(1234); // WHERE default = 1234
|
||||
* $query->filterByDefault(array(12, 34)); // WHERE default IN (12, 34)
|
||||
* $query->filterByDefault(array('min' => 12)); // WHERE default > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $isDefault The value to use as filter.
|
||||
* @param mixed $default 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.
|
||||
@@ -793,16 +801,16 @@ abstract class AddressQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByIsDefault($isDefault = null, $comparison = null)
|
||||
public function filterByDefault($default = null, $comparison = null)
|
||||
{
|
||||
if (is_array($isDefault)) {
|
||||
if (is_array($default)) {
|
||||
$useMinMax = false;
|
||||
if (isset($isDefault['min'])) {
|
||||
$this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($default['min'])) {
|
||||
$this->addUsingAlias(AddressTableMap::DEFAULT, $default['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($isDefault['max'])) {
|
||||
$this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($default['max'])) {
|
||||
$this->addUsingAlias(AddressTableMap::DEFAULT, $default['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -813,7 +821,7 @@ abstract class AddressQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(AddressTableMap::IS_DEFAULT, $isDefault, $comparison);
|
||||
return $this->addUsingAlias(AddressTableMap::DEFAULT, $default, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1052,6 +1060,152 @@ abstract class AddressQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Cart object
|
||||
*
|
||||
* @param \Thelia\Model\Cart|ObjectCollection $cart the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCartRelatedByAddressDeliveryId($cart, $comparison = null)
|
||||
{
|
||||
if ($cart instanceof \Thelia\Model\Cart) {
|
||||
return $this
|
||||
->addUsingAlias(AddressTableMap::ID, $cart->getAddressDeliveryId(), $comparison);
|
||||
} elseif ($cart instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartRelatedByAddressDeliveryIdQuery()
|
||||
->filterByPrimaryKeys($cart->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCartRelatedByAddressDeliveryId() only accepts arguments of type \Thelia\Model\Cart or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CartRelatedByAddressDeliveryId relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCartRelatedByAddressDeliveryId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CartRelatedByAddressDeliveryId');
|
||||
|
||||
// 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, 'CartRelatedByAddressDeliveryId');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CartRelatedByAddressDeliveryId relation Cart 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\CartQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartRelatedByAddressDeliveryIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCartRelatedByAddressDeliveryId($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CartRelatedByAddressDeliveryId', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Cart object
|
||||
*
|
||||
* @param \Thelia\Model\Cart|ObjectCollection $cart the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCartRelatedByAddressInvoiceId($cart, $comparison = null)
|
||||
{
|
||||
if ($cart instanceof \Thelia\Model\Cart) {
|
||||
return $this
|
||||
->addUsingAlias(AddressTableMap::ID, $cart->getAddressInvoiceId(), $comparison);
|
||||
} elseif ($cart instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartRelatedByAddressInvoiceIdQuery()
|
||||
->filterByPrimaryKeys($cart->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCartRelatedByAddressInvoiceId() only accepts arguments of type \Thelia\Model\Cart or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CartRelatedByAddressInvoiceId relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildAddressQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCartRelatedByAddressInvoiceId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CartRelatedByAddressInvoiceId');
|
||||
|
||||
// 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, 'CartRelatedByAddressInvoiceId');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CartRelatedByAddressInvoiceId relation Cart 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\CartQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartRelatedByAddressInvoiceIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCartRelatedByAddressInvoiceId($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CartRelatedByAddressInvoiceId', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
2165
core/lib/Thelia/Model/Base/Cart.php
Normal file
2165
core/lib/Thelia/Model/Base/Cart.php
Normal file
File diff suppressed because it is too large
Load Diff
1707
core/lib/Thelia/Model/Base/CartItem.php
Normal file
1707
core/lib/Thelia/Model/Base/CartItem.php
Normal file
File diff suppressed because it is too large
Load Diff
930
core/lib/Thelia/Model/Base/CartItemQuery.php
Normal file
930
core/lib/Thelia/Model/Base/CartItemQuery.php
Normal file
@@ -0,0 +1,930 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\CartItem as ChildCartItem;
|
||||
use Thelia\Model\CartItemQuery as ChildCartItemQuery;
|
||||
use Thelia\Model\Map\CartItemTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'cart_item' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildCartItemQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildCartItemQuery orderByCartId($order = Criteria::ASC) Order by the cart_id column
|
||||
* @method ChildCartItemQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
|
||||
* @method ChildCartItemQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
|
||||
* @method ChildCartItemQuery orderByCombinationId($order = Criteria::ASC) Order by the combination_id column
|
||||
* @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildCartItemQuery groupById() Group by the id column
|
||||
* @method ChildCartItemQuery groupByCartId() Group by the cart_id column
|
||||
* @method ChildCartItemQuery groupByProductId() Group by the product_id column
|
||||
* @method ChildCartItemQuery groupByQuantity() Group by the quantity column
|
||||
* @method ChildCartItemQuery groupByCombinationId() Group by the combination_id column
|
||||
* @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
* @method ChildCartItemQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildCartItemQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildCartItemQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildCartItemQuery leftJoinCart($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCartItemQuery rightJoinCart($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCartItemQuery innerJoinCart($relationAlias = null) Adds a INNER JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @method ChildCartItemQuery leftJoinProduct($relationAlias = null) Adds a LEFT JOIN clause to the query using the Product relation
|
||||
* @method ChildCartItemQuery rightJoinProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Product relation
|
||||
* @method ChildCartItemQuery innerJoinProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the Product relation
|
||||
*
|
||||
* @method ChildCartItemQuery leftJoinCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the Combination relation
|
||||
* @method ChildCartItemQuery rightJoinCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Combination relation
|
||||
* @method ChildCartItemQuery innerJoinCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the Combination relation
|
||||
*
|
||||
* @method ChildCartItem findOne(ConnectionInterface $con = null) Return the first ChildCartItem matching the query
|
||||
* @method ChildCartItem findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCartItem matching the query, or a new ChildCartItem object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildCartItem findOneById(int $id) Return the first ChildCartItem filtered by the id column
|
||||
* @method ChildCartItem findOneByCartId(int $cart_id) Return the first ChildCartItem filtered by the cart_id column
|
||||
* @method ChildCartItem findOneByProductId(int $product_id) Return the first ChildCartItem filtered by the product_id column
|
||||
* @method ChildCartItem findOneByQuantity(double $quantity) Return the first ChildCartItem filtered by the quantity column
|
||||
* @method ChildCartItem findOneByCombinationId(int $combination_id) Return the first ChildCartItem filtered by the combination_id column
|
||||
* @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column
|
||||
* @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildCartItem objects filtered by the id column
|
||||
* @method array findByCartId(int $cart_id) Return ChildCartItem objects filtered by the cart_id column
|
||||
* @method array findByProductId(int $product_id) Return ChildCartItem objects filtered by the product_id column
|
||||
* @method array findByQuantity(double $quantity) Return ChildCartItem objects filtered by the quantity column
|
||||
* @method array findByCombinationId(int $combination_id) Return ChildCartItem objects filtered by the combination_id column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column
|
||||
*
|
||||
*/
|
||||
abstract class CartItemQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\CartItemQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\CartItem', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildCartItemQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildCartItemQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\CartItemQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\CartItemQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->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.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(12, $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildCartItem|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = CartItemTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(CartItemTableMap::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 ChildCartItem A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, COMBINATION_ID, CREATED_AT, UPDATED_AT FROM cart_item 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 ChildCartItem();
|
||||
$obj->hydrate($row);
|
||||
CartItemTableMap::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 ChildCartItem|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
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||
* </code>
|
||||
* @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 ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::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 ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @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 ChildCartItemQuery 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(CartItemTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the cart_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCartId(1234); // WHERE cart_id = 1234
|
||||
* $query->filterByCartId(array(12, 34)); // WHERE cart_id IN (12, 34)
|
||||
* $query->filterByCartId(array('min' => 12)); // WHERE cart_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCart()
|
||||
*
|
||||
* @param mixed $cartId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCartId($cartId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($cartId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($cartId['min'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::CART_ID, $cartId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($cartId['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::CART_ID, $cartId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::CART_ID, $cartId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the product_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByProductId(1234); // WHERE product_id = 1234
|
||||
* $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
|
||||
* $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByProduct()
|
||||
*
|
||||
* @param mixed $productId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByProductId($productId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($productId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($productId['min'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($productId['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::PRODUCT_ID, $productId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the quantity column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByQuantity(1234); // WHERE quantity = 1234
|
||||
* $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
|
||||
* $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
|
||||
* </code>
|
||||
*
|
||||
* @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 ChildCartItemQuery 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(CartItemTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($quantity['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::QUANTITY, $quantity, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the combination_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCombinationId(1234); // WHERE combination_id = 1234
|
||||
* $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34)
|
||||
* $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCombination()
|
||||
*
|
||||
* @param mixed $combinationId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCombinationId($combinationId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($combinationId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($combinationId['min'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($combinationId['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::COMBINATION_ID, $combinationId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the created_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $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'
|
||||
* </code>
|
||||
*
|
||||
* @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 ChildCartItemQuery 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(CartItemTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($createdAt['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::CREATED_AT, $createdAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the updated_at column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $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'
|
||||
* </code>
|
||||
*
|
||||
* @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 ChildCartItemQuery 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(CartItemTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($updatedAt['max'])) {
|
||||
$this->addUsingAlias(CartItemTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(CartItemTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Cart object
|
||||
*
|
||||
* @param \Thelia\Model\Cart|ObjectCollection $cart The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCart($cart, $comparison = null)
|
||||
{
|
||||
if ($cart instanceof \Thelia\Model\Cart) {
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::CART_ID, $cart->getId(), $comparison);
|
||||
} elseif ($cart instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::CART_ID, $cart->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCart() only accepts arguments of type \Thelia\Model\Cart or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCart($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Cart');
|
||||
|
||||
// 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, 'Cart');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Cart relation Cart 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\CartQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCart($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Product object
|
||||
*
|
||||
* @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByProduct($product, $comparison = null)
|
||||
{
|
||||
if ($product instanceof \Thelia\Model\Product) {
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::PRODUCT_ID, $product->getId(), $comparison);
|
||||
} elseif ($product instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Product relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Product');
|
||||
|
||||
// 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, 'Product');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Product relation Product 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\ProductQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinProduct($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Combination object
|
||||
*
|
||||
* @param \Thelia\Model\Combination|ObjectCollection $combination The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCombination($combination, $comparison = null)
|
||||
{
|
||||
if ($combination instanceof \Thelia\Model\Combination) {
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::COMBINATION_ID, $combination->getId(), $comparison);
|
||||
} elseif ($combination instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(CartItemTableMap::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCombination() only accepts arguments of type \Thelia\Model\Combination or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Combination relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Combination');
|
||||
|
||||
// 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, 'Combination');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Combination relation Combination 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\CombinationQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCombinationQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCombination($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildCartItem $cartItem Object to remove from the list of results
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($cartItem = null)
|
||||
{
|
||||
if ($cartItem) {
|
||||
$this->addUsingAlias(CartItemTableMap::ID, $cartItem->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the cart_item 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(CartItemTableMap::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).
|
||||
CartItemTableMap::clearInstancePool();
|
||||
CartItemTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildCartItem or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildCartItem 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(CartItemTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(CartItemTableMap::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();
|
||||
|
||||
|
||||
CartItemTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
CartItemTableMap::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 ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyUpdated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(CartItemTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by the latest created
|
||||
*
|
||||
* @param int $nbDays Maximum age of in days
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function recentlyCreated($nbDays = 7)
|
||||
{
|
||||
return $this->addUsingAlias(CartItemTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date desc
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastUpdatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(CartItemTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by update date asc
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstUpdatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(CartItemTableMap::UPDATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date desc
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function lastCreatedFirst()
|
||||
{
|
||||
return $this->addDescendingOrderByColumn(CartItemTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Order by create date asc
|
||||
*
|
||||
* @return ChildCartItemQuery The current query, for fluid interface
|
||||
*/
|
||||
public function firstCreatedFirst()
|
||||
{
|
||||
return $this->addAscendingOrderByColumn(CartItemTableMap::CREATED_AT);
|
||||
}
|
||||
|
||||
} // CartItemQuery
|
||||
1121
core/lib/Thelia/Model/Base/CartQuery.php
Normal file
1121
core/lib/Thelia/Model/Base/CartQuery.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\AttributeCombination as ChildAttributeCombination;
|
||||
use Thelia\Model\AttributeCombinationQuery as ChildAttributeCombinationQuery;
|
||||
use Thelia\Model\CartItem as ChildCartItem;
|
||||
use Thelia\Model\CartItemQuery as ChildCartItemQuery;
|
||||
use Thelia\Model\Combination as ChildCombination;
|
||||
use Thelia\Model\CombinationQuery as ChildCombinationQuery;
|
||||
use Thelia\Model\Stock as ChildStock;
|
||||
@@ -95,6 +97,12 @@ abstract class Combination implements ActiveRecordInterface
|
||||
protected $collStocks;
|
||||
protected $collStocksPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCartItem[] Collection to store aggregation of ChildCartItem objects.
|
||||
*/
|
||||
protected $collCartItems;
|
||||
protected $collCartItemsPartial;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -115,6 +123,12 @@ abstract class Combination implements ActiveRecordInterface
|
||||
*/
|
||||
protected $stocksScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartItemsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Combination object.
|
||||
*/
|
||||
@@ -642,6 +656,8 @@ abstract class Combination implements ActiveRecordInterface
|
||||
|
||||
$this->collStocks = null;
|
||||
|
||||
$this->collCartItems = null;
|
||||
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -810,6 +826,24 @@ abstract class Combination implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->cartItemsScheduledForDeletion !== null) {
|
||||
if (!$this->cartItemsScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartItemsScheduledForDeletion as $cartItem) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cartItem->save($con);
|
||||
}
|
||||
$this->cartItemsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCartItems !== null) {
|
||||
foreach ($this->collCartItems as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
}
|
||||
@@ -992,6 +1026,9 @@ abstract class Combination implements ActiveRecordInterface
|
||||
if (null !== $this->collStocks) {
|
||||
$result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCartItems) {
|
||||
$result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -1165,6 +1202,12 @@ abstract class Combination implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCartItems() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCartItem($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
} // if ($deepCopy)
|
||||
|
||||
if ($makeNew) {
|
||||
@@ -1212,6 +1255,9 @@ abstract class Combination implements ActiveRecordInterface
|
||||
if ('Stock' == $relationName) {
|
||||
return $this->initStocks();
|
||||
}
|
||||
if ('CartItem' == $relationName) {
|
||||
return $this->initCartItems();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1728,6 +1774,274 @@ abstract class Combination implements ActiveRecordInterface
|
||||
return $this->getStocks($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCartItems collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addCartItems()
|
||||
*/
|
||||
public function clearCartItems()
|
||||
{
|
||||
$this->collCartItems = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCartItems collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCartItems($v = true)
|
||||
{
|
||||
$this->collCartItemsPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCartItems collection.
|
||||
*
|
||||
* By default this just sets the collCartItems collection to an empty array (like clearcollCartItems());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initCartItems($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCartItems && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCartItems = new ObjectCollection();
|
||||
$this->collCartItems->setModel('\Thelia\Model\CartItem');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCartItem objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCombination is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCartItems($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartItemsPartial && !$this->isNew();
|
||||
if (null === $this->collCartItems || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartItems) {
|
||||
// return empty collection
|
||||
$this->initCartItems();
|
||||
} else {
|
||||
$collCartItems = ChildCartItemQuery::create(null, $criteria)
|
||||
->filterByCombination($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartItemsPartial && count($collCartItems)) {
|
||||
$this->initCartItems(false);
|
||||
|
||||
foreach ($collCartItems as $obj) {
|
||||
if (false == $this->collCartItems->contains($obj)) {
|
||||
$this->collCartItems->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartItemsPartial = true;
|
||||
}
|
||||
|
||||
$collCartItems->getInternalIterator()->rewind();
|
||||
|
||||
return $collCartItems;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCartItems) {
|
||||
foreach ($this->collCartItems as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCartItems[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartItems = $collCartItems;
|
||||
$this->collCartItemsPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCartItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CartItem objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $cartItems A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCombination The current object (for fluent API support)
|
||||
*/
|
||||
public function setCartItems(Collection $cartItems, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartItemsToDelete = $this->getCartItems(new Criteria(), $con)->diff($cartItems);
|
||||
|
||||
|
||||
$this->cartItemsScheduledForDeletion = $cartItemsToDelete;
|
||||
|
||||
foreach ($cartItemsToDelete as $cartItemRemoved) {
|
||||
$cartItemRemoved->setCombination(null);
|
||||
}
|
||||
|
||||
$this->collCartItems = null;
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$this->addCartItem($cartItem);
|
||||
}
|
||||
|
||||
$this->collCartItems = $cartItems;
|
||||
$this->collCartItemsPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related CartItem objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related CartItem objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCartItems(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartItemsPartial && !$this->isNew();
|
||||
if (null === $this->collCartItems || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartItems) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCartItems());
|
||||
}
|
||||
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCombination($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCartItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCartItem object to this object
|
||||
* through the ChildCartItem foreign key attribute.
|
||||
*
|
||||
* @param ChildCartItem $l ChildCartItem
|
||||
* @return \Thelia\Model\Combination The current object (for fluent API support)
|
||||
*/
|
||||
public function addCartItem(ChildCartItem $l)
|
||||
{
|
||||
if ($this->collCartItems === null) {
|
||||
$this->initCartItems();
|
||||
$this->collCartItemsPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCartItems->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCartItem($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem The cartItem object to add.
|
||||
*/
|
||||
protected function doAddCartItem($cartItem)
|
||||
{
|
||||
$this->collCartItems[]= $cartItem;
|
||||
$cartItem->setCombination($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem The cartItem object to remove.
|
||||
* @return ChildCombination The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCartItem($cartItem)
|
||||
{
|
||||
if ($this->getCartItems()->contains($cartItem)) {
|
||||
$this->collCartItems->remove($this->collCartItems->search($cartItem));
|
||||
if (null === $this->cartItemsScheduledForDeletion) {
|
||||
$this->cartItemsScheduledForDeletion = clone $this->collCartItems;
|
||||
$this->cartItemsScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartItemsScheduledForDeletion[]= $cartItem;
|
||||
$cartItem->setCombination(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Combination is new, it will return
|
||||
* an empty collection; or if this Combination has previously
|
||||
* been saved, it will retrieve related CartItems from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Combination.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
*/
|
||||
public function getCartItemsJoinCart($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
$query->joinWith('Cart', $joinBehavior);
|
||||
|
||||
return $this->getCartItems($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Combination is new, it will return
|
||||
* an empty collection; or if this Combination has previously
|
||||
* been saved, it will retrieve related CartItems from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Combination.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
*/
|
||||
public function getCartItemsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
$query->joinWith('Product', $joinBehavior);
|
||||
|
||||
return $this->getCartItems($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -1766,6 +2080,11 @@ abstract class Combination implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCartItems) {
|
||||
foreach ($this->collCartItems as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
if ($this->collAttributeCombinations instanceof Collection) {
|
||||
@@ -1776,6 +2095,10 @@ abstract class Combination implements ActiveRecordInterface
|
||||
$this->collStocks->clearIterator();
|
||||
}
|
||||
$this->collStocks = null;
|
||||
if ($this->collCartItems instanceof Collection) {
|
||||
$this->collCartItems->clearIterator();
|
||||
}
|
||||
$this->collCartItems = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,10 @@ use Thelia\Model\Map\CombinationTableMap;
|
||||
* @method ChildCombinationQuery rightJoinStock($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Stock relation
|
||||
* @method ChildCombinationQuery innerJoinStock($relationAlias = null) Adds a INNER JOIN clause to the query using the Stock relation
|
||||
*
|
||||
* @method ChildCombinationQuery leftJoinCartItem($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartItem relation
|
||||
* @method ChildCombinationQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation
|
||||
* @method ChildCombinationQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation
|
||||
*
|
||||
* @method ChildCombination findOne(ConnectionInterface $con = null) Return the first ChildCombination matching the query
|
||||
* @method ChildCombination findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCombination matching the query, or a new ChildCombination object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -534,6 +538,79 @@ abstract class CombinationQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CartItem object
|
||||
*
|
||||
* @param \Thelia\Model\CartItem|ObjectCollection $cartItem the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCombinationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCartItem($cartItem, $comparison = null)
|
||||
{
|
||||
if ($cartItem instanceof \Thelia\Model\CartItem) {
|
||||
return $this
|
||||
->addUsingAlias(CombinationTableMap::ID, $cartItem->getCombinationId(), $comparison);
|
||||
} elseif ($cartItem instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartItemQuery()
|
||||
->filterByPrimaryKeys($cartItem->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCartItem() only accepts arguments of type \Thelia\Model\CartItem or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CartItem relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCombinationQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCartItem($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CartItem');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CartItem');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CartItem relation CartItem object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CartItemQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartItemQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCartItem($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CartItem', '\Thelia\Model\CartItemQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -17,6 +17,8 @@ use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Cart as ChildCart;
|
||||
use Thelia\Model\CartQuery as ChildCartQuery;
|
||||
use Thelia\Model\Currency as ChildCurrency;
|
||||
use Thelia\Model\CurrencyQuery as ChildCurrencyQuery;
|
||||
use Thelia\Model\Order as ChildOrder;
|
||||
@@ -111,6 +113,12 @@ abstract class Currency implements ActiveRecordInterface
|
||||
protected $collOrders;
|
||||
protected $collOrdersPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects.
|
||||
*/
|
||||
protected $collCarts;
|
||||
protected $collCartsPartial;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -125,6 +133,12 @@ abstract class Currency implements ActiveRecordInterface
|
||||
*/
|
||||
protected $ordersScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Currency object.
|
||||
*/
|
||||
@@ -790,6 +804,8 @@ abstract class Currency implements ActiveRecordInterface
|
||||
|
||||
$this->collOrders = null;
|
||||
|
||||
$this->collCarts = null;
|
||||
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -941,6 +957,24 @@ abstract class Currency implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->cartsScheduledForDeletion !== null) {
|
||||
if (!$this->cartsScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsScheduledForDeletion as $cart) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cart->save($con);
|
||||
}
|
||||
$this->cartsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCarts !== null) {
|
||||
foreach ($this->collCarts as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
}
|
||||
@@ -1160,6 +1194,9 @@ abstract class Currency implements ActiveRecordInterface
|
||||
if (null !== $this->collOrders) {
|
||||
$result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCarts) {
|
||||
$result['Carts'] = $this->collCarts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -1351,6 +1388,12 @@ abstract class Currency implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCarts() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCart($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
} // if ($deepCopy)
|
||||
|
||||
if ($makeNew) {
|
||||
@@ -1395,6 +1438,9 @@ abstract class Currency implements ActiveRecordInterface
|
||||
if ('Order' == $relationName) {
|
||||
return $this->initOrders();
|
||||
}
|
||||
if ('Cart' == $relationName) {
|
||||
return $this->initCarts();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1715,6 +1761,299 @@ abstract class Currency implements ActiveRecordInterface
|
||||
return $this->getOrders($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCarts 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 addCarts()
|
||||
*/
|
||||
public function clearCarts()
|
||||
{
|
||||
$this->collCarts = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCarts collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCarts($v = true)
|
||||
{
|
||||
$this->collCartsPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCarts collection.
|
||||
*
|
||||
* By default this just sets the collCarts collection to an empty array (like clearcollCarts());
|
||||
* 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 initCarts($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCarts && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCarts = new ObjectCollection();
|
||||
$this->collCarts->setModel('\Thelia\Model\Cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCart objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCurrency is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCarts($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsPartial && !$this->isNew();
|
||||
if (null === $this->collCarts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCarts) {
|
||||
// return empty collection
|
||||
$this->initCarts();
|
||||
} else {
|
||||
$collCarts = ChildCartQuery::create(null, $criteria)
|
||||
->filterByCurrency($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartsPartial && count($collCarts)) {
|
||||
$this->initCarts(false);
|
||||
|
||||
foreach ($collCarts as $obj) {
|
||||
if (false == $this->collCarts->contains($obj)) {
|
||||
$this->collCarts->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsPartial = true;
|
||||
}
|
||||
|
||||
$collCarts->getInternalIterator()->rewind();
|
||||
|
||||
return $collCarts;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCarts) {
|
||||
foreach ($this->collCarts as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCarts[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCarts = $collCarts;
|
||||
$this->collCartsPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCarts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Cart 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 $carts A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCurrency The current object (for fluent API support)
|
||||
*/
|
||||
public function setCarts(Collection $carts, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartsToDelete = $this->getCarts(new Criteria(), $con)->diff($carts);
|
||||
|
||||
|
||||
$this->cartsScheduledForDeletion = $cartsToDelete;
|
||||
|
||||
foreach ($cartsToDelete as $cartRemoved) {
|
||||
$cartRemoved->setCurrency(null);
|
||||
}
|
||||
|
||||
$this->collCarts = null;
|
||||
foreach ($carts as $cart) {
|
||||
$this->addCart($cart);
|
||||
}
|
||||
|
||||
$this->collCarts = $carts;
|
||||
$this->collCartsPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related Cart objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related Cart objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCarts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsPartial && !$this->isNew();
|
||||
if (null === $this->collCarts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCarts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCarts());
|
||||
}
|
||||
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCurrency($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCarts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCart object to this object
|
||||
* through the ChildCart foreign key attribute.
|
||||
*
|
||||
* @param ChildCart $l ChildCart
|
||||
* @return \Thelia\Model\Currency The current object (for fluent API support)
|
||||
*/
|
||||
public function addCart(ChildCart $l)
|
||||
{
|
||||
if ($this->collCarts === null) {
|
||||
$this->initCarts();
|
||||
$this->collCartsPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCarts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCart($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart The cart object to add.
|
||||
*/
|
||||
protected function doAddCart($cart)
|
||||
{
|
||||
$this->collCarts[]= $cart;
|
||||
$cart->setCurrency($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart The cart object to remove.
|
||||
* @return ChildCurrency The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCart($cart)
|
||||
{
|
||||
if ($this->getCarts()->contains($cart)) {
|
||||
$this->collCarts->remove($this->collCarts->search($cart));
|
||||
if (null === $this->cartsScheduledForDeletion) {
|
||||
$this->cartsScheduledForDeletion = clone $this->collCarts;
|
||||
$this->cartsScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartsScheduledForDeletion[]= $cart;
|
||||
$cart->setCurrency(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Currency is new, it will return
|
||||
* an empty collection; or if this Currency has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Currency.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Customer', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Currency is new, it will return
|
||||
* an empty collection; or if this Currency has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Currency.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinAddressRelatedByAddressDeliveryId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('AddressRelatedByAddressDeliveryId', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Currency is new, it will return
|
||||
* an empty collection; or if this Currency has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Currency.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinAddressRelatedByAddressInvoiceId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('AddressRelatedByAddressInvoiceId', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -1752,12 +2091,21 @@ abstract class Currency implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCarts) {
|
||||
foreach ($this->collCarts as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
if ($this->collOrders instanceof Collection) {
|
||||
$this->collOrders->clearIterator();
|
||||
}
|
||||
$this->collOrders = null;
|
||||
if ($this->collCarts instanceof Collection) {
|
||||
$this->collCarts->clearIterator();
|
||||
}
|
||||
$this->collCarts = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,10 @@ use Thelia\Model\Map\CurrencyTableMap;
|
||||
* @method ChildCurrencyQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
|
||||
* @method ChildCurrencyQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @method ChildCurrencyQuery leftJoinCart($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCurrencyQuery rightJoinCart($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCurrencyQuery innerJoinCart($relationAlias = null) Adds a INNER JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @method ChildCurrency findOne(ConnectionInterface $con = null) Return the first ChildCurrency matching the query
|
||||
* @method ChildCurrency findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCurrency matching the query, or a new ChildCurrency object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -613,6 +617,79 @@ abstract class CurrencyQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Cart object
|
||||
*
|
||||
* @param \Thelia\Model\Cart|ObjectCollection $cart the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCurrencyQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCart($cart, $comparison = null)
|
||||
{
|
||||
if ($cart instanceof \Thelia\Model\Cart) {
|
||||
return $this
|
||||
->addUsingAlias(CurrencyTableMap::ID, $cart->getCurrencyId(), $comparison);
|
||||
} elseif ($cart instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartQuery()
|
||||
->filterByPrimaryKeys($cart->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCart() only accepts arguments of type \Thelia\Model\Cart or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCurrencyQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCart($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Cart');
|
||||
|
||||
// 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, 'Cart');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Cart relation Cart 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\CartQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCart($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Address as ChildAddress;
|
||||
use Thelia\Model\AddressQuery as ChildAddressQuery;
|
||||
use Thelia\Model\Cart as ChildCart;
|
||||
use Thelia\Model\CartQuery as ChildCartQuery;
|
||||
use Thelia\Model\Customer as ChildCustomer;
|
||||
use Thelia\Model\CustomerQuery as ChildCustomerQuery;
|
||||
use Thelia\Model\CustomerTitle as ChildCustomerTitle;
|
||||
@@ -162,6 +164,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
protected $collOrders;
|
||||
protected $collOrdersPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects.
|
||||
*/
|
||||
protected $collCarts;
|
||||
protected $collCartsPartial;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -182,6 +190,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
*/
|
||||
protected $ordersScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* Initializes internal state of Thelia\Model\Base\Customer object.
|
||||
*/
|
||||
@@ -1067,6 +1081,8 @@ abstract class Customer implements ActiveRecordInterface
|
||||
|
||||
$this->collOrders = null;
|
||||
|
||||
$this->collCarts = null;
|
||||
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1246,6 +1262,24 @@ abstract class Customer implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->cartsScheduledForDeletion !== null) {
|
||||
if (!$this->cartsScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->cartsScheduledForDeletion as $cart) {
|
||||
// need to save related object because we set the relation to null
|
||||
$cart->save($con);
|
||||
}
|
||||
$this->cartsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCarts !== null) {
|
||||
foreach ($this->collCarts as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
}
|
||||
@@ -1531,6 +1565,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
if (null !== $this->collOrders) {
|
||||
$result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCarts) {
|
||||
$result['Carts'] = $this->collCarts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -1764,6 +1801,12 @@ abstract class Customer implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCarts() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCart($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
} // if ($deepCopy)
|
||||
|
||||
if ($makeNew) {
|
||||
@@ -1862,6 +1905,9 @@ abstract class Customer implements ActiveRecordInterface
|
||||
if ('Order' == $relationName) {
|
||||
return $this->initOrders();
|
||||
}
|
||||
if ('Cart' == $relationName) {
|
||||
return $this->initCarts();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2425,6 +2471,299 @@ abstract class Customer implements ActiveRecordInterface
|
||||
return $this->getOrders($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCarts 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 addCarts()
|
||||
*/
|
||||
public function clearCarts()
|
||||
{
|
||||
$this->collCarts = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCarts collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCarts($v = true)
|
||||
{
|
||||
$this->collCartsPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCarts collection.
|
||||
*
|
||||
* By default this just sets the collCarts collection to an empty array (like clearcollCarts());
|
||||
* 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 initCarts($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCarts && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCarts = new ObjectCollection();
|
||||
$this->collCarts->setModel('\Thelia\Model\Cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCart 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 ChildCustomer 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|ChildCart[] List of ChildCart objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCarts($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsPartial && !$this->isNew();
|
||||
if (null === $this->collCarts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCarts) {
|
||||
// return empty collection
|
||||
$this->initCarts();
|
||||
} else {
|
||||
$collCarts = ChildCartQuery::create(null, $criteria)
|
||||
->filterByCustomer($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartsPartial && count($collCarts)) {
|
||||
$this->initCarts(false);
|
||||
|
||||
foreach ($collCarts as $obj) {
|
||||
if (false == $this->collCarts->contains($obj)) {
|
||||
$this->collCarts->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartsPartial = true;
|
||||
}
|
||||
|
||||
$collCarts->getInternalIterator()->rewind();
|
||||
|
||||
return $collCarts;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCarts) {
|
||||
foreach ($this->collCarts as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCarts[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCarts = $collCarts;
|
||||
$this->collCartsPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCarts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of Cart 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 $carts A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function setCarts(Collection $carts, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartsToDelete = $this->getCarts(new Criteria(), $con)->diff($carts);
|
||||
|
||||
|
||||
$this->cartsScheduledForDeletion = $cartsToDelete;
|
||||
|
||||
foreach ($cartsToDelete as $cartRemoved) {
|
||||
$cartRemoved->setCustomer(null);
|
||||
}
|
||||
|
||||
$this->collCarts = null;
|
||||
foreach ($carts as $cart) {
|
||||
$this->addCart($cart);
|
||||
}
|
||||
|
||||
$this->collCarts = $carts;
|
||||
$this->collCartsPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related Cart objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related Cart objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCarts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartsPartial && !$this->isNew();
|
||||
if (null === $this->collCarts || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCarts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCarts());
|
||||
}
|
||||
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCustomer($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCarts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCart object to this object
|
||||
* through the ChildCart foreign key attribute.
|
||||
*
|
||||
* @param ChildCart $l ChildCart
|
||||
* @return \Thelia\Model\Customer The current object (for fluent API support)
|
||||
*/
|
||||
public function addCart(ChildCart $l)
|
||||
{
|
||||
if ($this->collCarts === null) {
|
||||
$this->initCarts();
|
||||
$this->collCartsPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCarts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCart($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart The cart object to add.
|
||||
*/
|
||||
protected function doAddCart($cart)
|
||||
{
|
||||
$this->collCarts[]= $cart;
|
||||
$cart->setCustomer($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cart $cart The cart object to remove.
|
||||
* @return ChildCustomer The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCart($cart)
|
||||
{
|
||||
if ($this->getCarts()->contains($cart)) {
|
||||
$this->collCarts->remove($this->collCarts->search($cart));
|
||||
if (null === $this->cartsScheduledForDeletion) {
|
||||
$this->cartsScheduledForDeletion = clone $this->collCarts;
|
||||
$this->cartsScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartsScheduledForDeletion[]= $cart;
|
||||
$cart->setCustomer(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Customer is new, it will return
|
||||
* an empty collection; or if this Customer has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Customer.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinAddressRelatedByAddressDeliveryId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('AddressRelatedByAddressDeliveryId', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Customer is new, it will return
|
||||
* an empty collection; or if this Customer has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Customer.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinAddressRelatedByAddressInvoiceId($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('AddressRelatedByAddressInvoiceId', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Customer is new, it will return
|
||||
* an empty collection; or if this Customer has previously
|
||||
* been saved, it will retrieve related Carts from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Customer.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCart[] List of ChildCart objects
|
||||
*/
|
||||
public function getCartsJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartQuery::create(null, $criteria);
|
||||
$query->joinWith('Currency', $joinBehavior);
|
||||
|
||||
return $this->getCarts($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -2473,6 +2812,11 @@ abstract class Customer implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCarts) {
|
||||
foreach ($this->collCarts as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
if ($this->collAddresses instanceof Collection) {
|
||||
@@ -2483,6 +2827,10 @@ abstract class Customer implements ActiveRecordInterface
|
||||
$this->collOrders->clearIterator();
|
||||
}
|
||||
$this->collOrders = null;
|
||||
if ($this->collCarts instanceof Collection) {
|
||||
$this->collCarts->clearIterator();
|
||||
}
|
||||
$this->collCarts = null;
|
||||
$this->aCustomerTitle = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@ use Thelia\Model\Map\CustomerTableMap;
|
||||
* @method ChildCustomerQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
|
||||
* @method ChildCustomerQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @method ChildCustomerQuery leftJoinCart($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCustomerQuery rightJoinCart($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cart relation
|
||||
* @method ChildCustomerQuery innerJoinCart($relationAlias = null) Adds a INNER JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @method ChildCustomer findOne(ConnectionInterface $con = null) Return the first ChildCustomer matching the query
|
||||
* @method ChildCustomer findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCustomer matching the query, or a new ChildCustomer object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -793,7 +797,7 @@ abstract class CustomerQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CustomerTitle');
|
||||
@@ -828,7 +832,7 @@ abstract class CustomerQuery extends ModelCriteria
|
||||
*
|
||||
* @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCustomerTitle($relationAlias, $joinType)
|
||||
@@ -981,6 +985,79 @@ abstract class CustomerQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Cart object
|
||||
*
|
||||
* @param \Thelia\Model\Cart|ObjectCollection $cart the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCart($cart, $comparison = null)
|
||||
{
|
||||
if ($cart instanceof \Thelia\Model\Cart) {
|
||||
return $this
|
||||
->addUsingAlias(CustomerTableMap::ID, $cart->getCustomerId(), $comparison);
|
||||
} elseif ($cart instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartQuery()
|
||||
->filterByPrimaryKeys($cart->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCart() only accepts arguments of type \Thelia\Model\Cart or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Cart relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCustomerQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCart($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Cart');
|
||||
|
||||
// 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, 'Cart');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Cart relation Cart 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\CartQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCart($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -866,10 +866,9 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
|
||||
if ($this->customersScheduledForDeletion !== null) {
|
||||
if (!$this->customersScheduledForDeletion->isEmpty()) {
|
||||
foreach ($this->customersScheduledForDeletion as $customer) {
|
||||
// need to save related object because we set the relation to null
|
||||
$customer->save($con);
|
||||
}
|
||||
\Thelia\Model\CustomerQuery::create()
|
||||
->filterByPrimaryKeys($this->customersScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->customersScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
@@ -1560,7 +1559,7 @@ abstract class CustomerTitle implements ActiveRecordInterface
|
||||
$this->customersScheduledForDeletion = clone $this->collCustomers;
|
||||
$this->customersScheduledForDeletion->clear();
|
||||
}
|
||||
$this->customersScheduledForDeletion[]= $customer;
|
||||
$this->customersScheduledForDeletion[]= clone $customer;
|
||||
$customer->setCustomerTitle(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -469,7 +469,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildCustomerTitleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Customer');
|
||||
@@ -504,7 +504,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
|
||||
*
|
||||
* @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCustomer($relationAlias, $joinType)
|
||||
|
||||
@@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser;
|
||||
use Propel\Runtime\Util\PropelDateTime;
|
||||
use Thelia\Model\Accessory as ChildAccessory;
|
||||
use Thelia\Model\AccessoryQuery as ChildAccessoryQuery;
|
||||
use Thelia\Model\CartItem as ChildCartItem;
|
||||
use Thelia\Model\CartItemQuery as ChildCartItemQuery;
|
||||
use Thelia\Model\Category as ChildCategory;
|
||||
use Thelia\Model\CategoryQuery as ChildCategoryQuery;
|
||||
use Thelia\Model\ContentAssoc as ChildContentAssoc;
|
||||
@@ -246,6 +248,12 @@ abstract class Product implements ActiveRecordInterface
|
||||
protected $collRewritings;
|
||||
protected $collRewritingsPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCartItem[] Collection to store aggregation of ChildCartItem objects.
|
||||
*/
|
||||
protected $collCartItems;
|
||||
protected $collCartItemsPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildProductI18n[] Collection to store aggregation of ChildProductI18n objects.
|
||||
*/
|
||||
@@ -375,6 +383,12 @@ abstract class Product implements ActiveRecordInterface
|
||||
*/
|
||||
protected $rewritingsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $cartItemsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -1440,6 +1454,8 @@ abstract class Product implements ActiveRecordInterface
|
||||
|
||||
$this->collRewritings = null;
|
||||
|
||||
$this->collCartItems = null;
|
||||
|
||||
$this->collProductI18ns = null;
|
||||
|
||||
$this->collProductVersions = null;
|
||||
@@ -1838,6 +1854,23 @@ abstract class Product implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->cartItemsScheduledForDeletion !== null) {
|
||||
if (!$this->cartItemsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CartItemQuery::create()
|
||||
->filterByPrimaryKeys($this->cartItemsScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->cartItemsScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collCartItems !== null) {
|
||||
foreach ($this->collCartItems as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->productI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->productI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\ProductI18nQuery::create()
|
||||
@@ -2208,6 +2241,9 @@ abstract class Product implements ActiveRecordInterface
|
||||
if (null !== $this->collRewritings) {
|
||||
$result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCartItems) {
|
||||
$result['CartItems'] = $this->collCartItems->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collProductI18ns) {
|
||||
$result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -2507,6 +2543,12 @@ abstract class Product implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCartItems() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCartItem($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getProductI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addProductI18n($relObj->copy($deepCopy));
|
||||
@@ -2638,6 +2680,9 @@ abstract class Product implements ActiveRecordInterface
|
||||
if ('Rewriting' == $relationName) {
|
||||
return $this->initRewritings();
|
||||
}
|
||||
if ('CartItem' == $relationName) {
|
||||
return $this->initCartItems();
|
||||
}
|
||||
if ('ProductI18n' == $relationName) {
|
||||
return $this->initProductI18ns();
|
||||
}
|
||||
@@ -4986,6 +5031,274 @@ abstract class Product implements ActiveRecordInterface
|
||||
return $this->getRewritings($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCartItems collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addCartItems()
|
||||
*/
|
||||
public function clearCartItems()
|
||||
{
|
||||
$this->collCartItems = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collCartItems collection loaded partially.
|
||||
*/
|
||||
public function resetPartialCartItems($v = true)
|
||||
{
|
||||
$this->collCartItemsPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collCartItems collection.
|
||||
*
|
||||
* By default this just sets the collCartItems collection to an empty array (like clearcollCartItems());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initCartItems($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collCartItems && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collCartItems = new ObjectCollection();
|
||||
$this->collCartItems->setModel('\Thelia\Model\CartItem');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildCartItem objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildProduct is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCartItems($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartItemsPartial && !$this->isNew();
|
||||
if (null === $this->collCartItems || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartItems) {
|
||||
// return empty collection
|
||||
$this->initCartItems();
|
||||
} else {
|
||||
$collCartItems = ChildCartItemQuery::create(null, $criteria)
|
||||
->filterByProduct($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collCartItemsPartial && count($collCartItems)) {
|
||||
$this->initCartItems(false);
|
||||
|
||||
foreach ($collCartItems as $obj) {
|
||||
if (false == $this->collCartItems->contains($obj)) {
|
||||
$this->collCartItems->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartItemsPartial = true;
|
||||
}
|
||||
|
||||
$collCartItems->getInternalIterator()->rewind();
|
||||
|
||||
return $collCartItems;
|
||||
}
|
||||
|
||||
if ($partial && $this->collCartItems) {
|
||||
foreach ($this->collCartItems as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collCartItems[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collCartItems = $collCartItems;
|
||||
$this->collCartItemsPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collCartItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of CartItem objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $cartItems A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildProduct The current object (for fluent API support)
|
||||
*/
|
||||
public function setCartItems(Collection $cartItems, ConnectionInterface $con = null)
|
||||
{
|
||||
$cartItemsToDelete = $this->getCartItems(new Criteria(), $con)->diff($cartItems);
|
||||
|
||||
|
||||
$this->cartItemsScheduledForDeletion = $cartItemsToDelete;
|
||||
|
||||
foreach ($cartItemsToDelete as $cartItemRemoved) {
|
||||
$cartItemRemoved->setProduct(null);
|
||||
}
|
||||
|
||||
$this->collCartItems = null;
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$this->addCartItem($cartItem);
|
||||
}
|
||||
|
||||
$this->collCartItems = $cartItems;
|
||||
$this->collCartItemsPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related CartItem objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related CartItem objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countCartItems(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collCartItemsPartial && !$this->isNew();
|
||||
if (null === $this->collCartItems || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collCartItems) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getCartItems());
|
||||
}
|
||||
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByProduct($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collCartItems);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildCartItem object to this object
|
||||
* through the ChildCartItem foreign key attribute.
|
||||
*
|
||||
* @param ChildCartItem $l ChildCartItem
|
||||
* @return \Thelia\Model\Product The current object (for fluent API support)
|
||||
*/
|
||||
public function addCartItem(ChildCartItem $l)
|
||||
{
|
||||
if ($this->collCartItems === null) {
|
||||
$this->initCartItems();
|
||||
$this->collCartItemsPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collCartItems->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddCartItem($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem The cartItem object to add.
|
||||
*/
|
||||
protected function doAddCartItem($cartItem)
|
||||
{
|
||||
$this->collCartItems[]= $cartItem;
|
||||
$cartItem->setProduct($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CartItem $cartItem The cartItem object to remove.
|
||||
* @return ChildProduct The current object (for fluent API support)
|
||||
*/
|
||||
public function removeCartItem($cartItem)
|
||||
{
|
||||
if ($this->getCartItems()->contains($cartItem)) {
|
||||
$this->collCartItems->remove($this->collCartItems->search($cartItem));
|
||||
if (null === $this->cartItemsScheduledForDeletion) {
|
||||
$this->cartItemsScheduledForDeletion = clone $this->collCartItems;
|
||||
$this->cartItemsScheduledForDeletion->clear();
|
||||
}
|
||||
$this->cartItemsScheduledForDeletion[]= clone $cartItem;
|
||||
$cartItem->setProduct(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Product is new, it will return
|
||||
* an empty collection; or if this Product has previously
|
||||
* been saved, it will retrieve related CartItems from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Product.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
*/
|
||||
public function getCartItemsJoinCart($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
$query->joinWith('Cart', $joinBehavior);
|
||||
|
||||
return $this->getCartItems($query, $con);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Product is new, it will return
|
||||
* an empty collection; or if this Product has previously
|
||||
* been saved, it will retrieve related CartItems from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Product.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildCartItem[] List of ChildCartItem objects
|
||||
*/
|
||||
public function getCartItemsJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildCartItemQuery::create(null, $criteria);
|
||||
$query->joinWith('Combination', $joinBehavior);
|
||||
|
||||
return $this->getCartItems($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collProductI18ns collection
|
||||
*
|
||||
@@ -6068,6 +6381,11 @@ abstract class Product implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCartItems) {
|
||||
foreach ($this->collCartItems as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collProductI18ns) {
|
||||
foreach ($this->collProductI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
@@ -6135,6 +6453,10 @@ abstract class Product implements ActiveRecordInterface
|
||||
$this->collRewritings->clearIterator();
|
||||
}
|
||||
$this->collRewritings = null;
|
||||
if ($this->collCartItems instanceof Collection) {
|
||||
$this->collCartItems->clearIterator();
|
||||
}
|
||||
$this->collCartItems = null;
|
||||
if ($this->collProductI18ns instanceof Collection) {
|
||||
$this->collProductI18ns->clearIterator();
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@ use Thelia\Model\Map\ProductTableMap;
|
||||
* @method ChildProductQuery rightJoinRewriting($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Rewriting relation
|
||||
* @method ChildProductQuery innerJoinRewriting($relationAlias = null) Adds a INNER JOIN clause to the query using the Rewriting relation
|
||||
*
|
||||
* @method ChildProductQuery leftJoinCartItem($relationAlias = null) Adds a LEFT JOIN clause to the query using the CartItem relation
|
||||
* @method ChildProductQuery rightJoinCartItem($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CartItem relation
|
||||
* @method ChildProductQuery innerJoinCartItem($relationAlias = null) Adds a INNER JOIN clause to the query using the CartItem relation
|
||||
*
|
||||
* @method ChildProductQuery leftJoinProductI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProductI18n relation
|
||||
* @method ChildProductQuery rightJoinProductI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProductI18n relation
|
||||
* @method ChildProductQuery innerJoinProductI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ProductI18n relation
|
||||
@@ -1745,6 +1749,79 @@ abstract class ProductQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CartItem object
|
||||
*
|
||||
* @param \Thelia\Model\CartItem|ObjectCollection $cartItem the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCartItem($cartItem, $comparison = null)
|
||||
{
|
||||
if ($cartItem instanceof \Thelia\Model\CartItem) {
|
||||
return $this
|
||||
->addUsingAlias(ProductTableMap::ID, $cartItem->getProductId(), $comparison);
|
||||
} elseif ($cartItem instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useCartItemQuery()
|
||||
->filterByPrimaryKeys($cartItem->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByCartItem() only accepts arguments of type \Thelia\Model\CartItem or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the CartItem relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCartItem($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('CartItem');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'CartItem');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the CartItem relation CartItem object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CartItemQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCartItemQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCartItem($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'CartItem', '\Thelia\Model\CartItemQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\ProductI18n object
|
||||
*
|
||||
|
||||
@@ -83,10 +83,10 @@ abstract class Stock implements ActiveRecordInterface
|
||||
protected $increase;
|
||||
|
||||
/**
|
||||
* The value for the value field.
|
||||
* The value for the quantity field.
|
||||
* @var double
|
||||
*/
|
||||
protected $value;
|
||||
protected $quantity;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
@@ -417,14 +417,14 @@ abstract class Stock implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [value] column value.
|
||||
* Get the [quantity] column value.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getValue()
|
||||
public function getQuantity()
|
||||
{
|
||||
|
||||
return $this->value;
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,25 +560,25 @@ abstract class Stock implements ActiveRecordInterface
|
||||
} // setIncrease()
|
||||
|
||||
/**
|
||||
* Set the value of [value] column.
|
||||
* Set the value of [quantity] column.
|
||||
*
|
||||
* @param double $v new value
|
||||
* @return \Thelia\Model\Stock The current object (for fluent API support)
|
||||
*/
|
||||
public function setValue($v)
|
||||
public function setQuantity($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (double) $v;
|
||||
}
|
||||
|
||||
if ($this->value !== $v) {
|
||||
$this->value = $v;
|
||||
$this->modifiedColumns[] = StockTableMap::VALUE;
|
||||
if ($this->quantity !== $v) {
|
||||
$this->quantity = $v;
|
||||
$this->modifiedColumns[] = StockTableMap::QUANTITY;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setValue()
|
||||
} // setQuantity()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
@@ -671,8 +671,8 @@ abstract class Stock implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : StockTableMap::translateFieldName('Increase', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->increase = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : StockTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->value = (null !== $col) ? (double) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : StockTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->quantity = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : StockTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
@@ -952,8 +952,8 @@ abstract class Stock implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(StockTableMap::INCREASE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'INCREASE';
|
||||
}
|
||||
if ($this->isColumnModified(StockTableMap::VALUE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'VALUE';
|
||||
if ($this->isColumnModified(StockTableMap::QUANTITY)) {
|
||||
$modifiedColumns[':p' . $index++] = 'QUANTITY';
|
||||
}
|
||||
if ($this->isColumnModified(StockTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
@@ -984,8 +984,8 @@ abstract class Stock implements ActiveRecordInterface
|
||||
case 'INCREASE':
|
||||
$stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'VALUE':
|
||||
$stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
|
||||
case 'QUANTITY':
|
||||
$stmt->bindValue($identifier, $this->quantity, 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);
|
||||
@@ -1068,7 +1068,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
return $this->getIncrease();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getValue();
|
||||
return $this->getQuantity();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getCreatedAt();
|
||||
@@ -1109,7 +1109,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
$keys[1] => $this->getCombinationId(),
|
||||
$keys[2] => $this->getProductId(),
|
||||
$keys[3] => $this->getIncrease(),
|
||||
$keys[4] => $this->getValue(),
|
||||
$keys[4] => $this->getQuantity(),
|
||||
$keys[5] => $this->getCreatedAt(),
|
||||
$keys[6] => $this->getUpdatedAt(),
|
||||
);
|
||||
@@ -1173,7 +1173,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
$this->setIncrease($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setValue($value);
|
||||
$this->setQuantity($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setCreatedAt($value);
|
||||
@@ -1209,7 +1209,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCombinationId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setIncrease($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setQuantity($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||
}
|
||||
@@ -1227,7 +1227,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(StockTableMap::COMBINATION_ID)) $criteria->add(StockTableMap::COMBINATION_ID, $this->combination_id);
|
||||
if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) $criteria->add(StockTableMap::PRODUCT_ID, $this->product_id);
|
||||
if ($this->isColumnModified(StockTableMap::INCREASE)) $criteria->add(StockTableMap::INCREASE, $this->increase);
|
||||
if ($this->isColumnModified(StockTableMap::VALUE)) $criteria->add(StockTableMap::VALUE, $this->value);
|
||||
if ($this->isColumnModified(StockTableMap::QUANTITY)) $criteria->add(StockTableMap::QUANTITY, $this->quantity);
|
||||
if ($this->isColumnModified(StockTableMap::CREATED_AT)) $criteria->add(StockTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(StockTableMap::UPDATED_AT)) $criteria->add(StockTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1296,7 +1296,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
$copyObj->setCombinationId($this->getCombinationId());
|
||||
$copyObj->setProductId($this->getProductId());
|
||||
$copyObj->setIncrease($this->getIncrease());
|
||||
$copyObj->setValue($this->getValue());
|
||||
$copyObj->setQuantity($this->getQuantity());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
if ($makeNew) {
|
||||
@@ -1438,7 +1438,7 @@ abstract class Stock implements ActiveRecordInterface
|
||||
$this->combination_id = null;
|
||||
$this->product_id = null;
|
||||
$this->increase = null;
|
||||
$this->value = null;
|
||||
$this->quantity = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -25,7 +25,7 @@ use Thelia\Model\Map\StockTableMap;
|
||||
* @method ChildStockQuery orderByCombinationId($order = Criteria::ASC) Order by the combination_id column
|
||||
* @method ChildStockQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
|
||||
* @method ChildStockQuery orderByIncrease($order = Criteria::ASC) Order by the increase column
|
||||
* @method ChildStockQuery orderByValue($order = Criteria::ASC) Order by the value column
|
||||
* @method ChildStockQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
|
||||
* @method ChildStockQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildStockQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
@@ -33,7 +33,7 @@ use Thelia\Model\Map\StockTableMap;
|
||||
* @method ChildStockQuery groupByCombinationId() Group by the combination_id column
|
||||
* @method ChildStockQuery groupByProductId() Group by the product_id column
|
||||
* @method ChildStockQuery groupByIncrease() Group by the increase column
|
||||
* @method ChildStockQuery groupByValue() Group by the value column
|
||||
* @method ChildStockQuery groupByQuantity() Group by the quantity column
|
||||
* @method ChildStockQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildStockQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -56,7 +56,7 @@ use Thelia\Model\Map\StockTableMap;
|
||||
* @method ChildStock findOneByCombinationId(int $combination_id) Return the first ChildStock filtered by the combination_id column
|
||||
* @method ChildStock findOneByProductId(int $product_id) Return the first ChildStock filtered by the product_id column
|
||||
* @method ChildStock findOneByIncrease(double $increase) Return the first ChildStock filtered by the increase column
|
||||
* @method ChildStock findOneByValue(double $value) Return the first ChildStock filtered by the value column
|
||||
* @method ChildStock findOneByQuantity(double $quantity) Return the first ChildStock filtered by the quantity column
|
||||
* @method ChildStock findOneByCreatedAt(string $created_at) Return the first ChildStock filtered by the created_at column
|
||||
* @method ChildStock findOneByUpdatedAt(string $updated_at) Return the first ChildStock filtered by the updated_at column
|
||||
*
|
||||
@@ -64,7 +64,7 @@ use Thelia\Model\Map\StockTableMap;
|
||||
* @method array findByCombinationId(int $combination_id) Return ChildStock objects filtered by the combination_id column
|
||||
* @method array findByProductId(int $product_id) Return ChildStock objects filtered by the product_id column
|
||||
* @method array findByIncrease(double $increase) Return ChildStock objects filtered by the increase column
|
||||
* @method array findByValue(double $value) Return ChildStock objects filtered by the value column
|
||||
* @method array findByQuantity(double $quantity) Return ChildStock objects filtered by the quantity column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildStock objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildStock objects filtered by the updated_at column
|
||||
*
|
||||
@@ -155,7 +155,7 @@ abstract class StockQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, COMBINATION_ID, PRODUCT_ID, INCREASE, VALUE, CREATED_AT, UPDATED_AT FROM stock WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, COMBINATION_ID, PRODUCT_ID, INCREASE, QUANTITY, CREATED_AT, UPDATED_AT FROM stock WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -413,16 +413,16 @@ abstract class StockQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the value column
|
||||
* Filter the query on the quantity column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByValue(1234); // WHERE value = 1234
|
||||
* $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
|
||||
* $query->filterByValue(array('min' => 12)); // WHERE value > 12
|
||||
* $query->filterByQuantity(1234); // WHERE quantity = 1234
|
||||
* $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
|
||||
* $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $value The value to use as filter.
|
||||
* @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.
|
||||
@@ -430,16 +430,16 @@ abstract class StockQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildStockQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByValue($value = null, $comparison = null)
|
||||
public function filterByQuantity($quantity = null, $comparison = null)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
if (is_array($quantity)) {
|
||||
$useMinMax = false;
|
||||
if (isset($value['min'])) {
|
||||
$this->addUsingAlias(StockTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($quantity['min'])) {
|
||||
$this->addUsingAlias(StockTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($value['max'])) {
|
||||
$this->addUsingAlias(StockTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($quantity['max'])) {
|
||||
$this->addUsingAlias(StockTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -450,7 +450,7 @@ abstract class StockQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(StockTableMap::VALUE, $value, $comparison);
|
||||
return $this->addUsingAlias(StockTableMap::QUANTITY, $quantity, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
core/lib/Thelia/Model/Cart.php
Normal file
10
core/lib/Thelia/Model/Cart.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Cart as BaseCart;
|
||||
|
||||
class Cart extends BaseCart
|
||||
{
|
||||
|
||||
}
|
||||
10
core/lib/Thelia/Model/CartItem.php
Normal file
10
core/lib/Thelia/Model/CartItem.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CartItem as BaseCartItem;
|
||||
|
||||
class CartItem extends BaseCartItem
|
||||
{
|
||||
|
||||
}
|
||||
21
core/lib/Thelia/Model/CartItemQuery.php
Normal file
21
core/lib/Thelia/Model/CartItemQuery.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CartItemQuery as BaseCartItemQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'cart_item' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class CartItemQuery extends BaseCartItemQuery
|
||||
{
|
||||
|
||||
} // CartItemQuery
|
||||
21
core/lib/Thelia/Model/CartQuery.php
Normal file
21
core/lib/Thelia/Model/CartQuery.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\CartQuery as BaseCartQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'cart' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class CartQuery extends BaseCartQuery
|
||||
{
|
||||
|
||||
} // CartQuery
|
||||
@@ -145,9 +145,9 @@ class AddressTableMap extends TableMap
|
||||
const CELLPHONE = 'address.CELLPHONE';
|
||||
|
||||
/**
|
||||
* the column name for the IS_DEFAULT field
|
||||
* the column name for the DEFAULT field
|
||||
*/
|
||||
const IS_DEFAULT = 'address.IS_DEFAULT';
|
||||
const DEFAULT = 'address.DEFAULT';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
@@ -171,11 +171,11 @@ class AddressTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ),
|
||||
self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Default', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'default', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'default', '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, )
|
||||
);
|
||||
|
||||
@@ -186,11 +186,11 @@ class AddressTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
|
||||
self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ),
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'Default' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
|
||||
self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'default' => 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, )
|
||||
);
|
||||
|
||||
@@ -225,7 +225,7 @@ class AddressTableMap extends TableMap
|
||||
$this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
|
||||
$this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
|
||||
$this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
|
||||
$this->addColumn('IS_DEFAULT', 'IsDefault', 'TINYINT', false, null, 0);
|
||||
$this->addColumn('DEFAULT', 'Default', 'TINYINT', false, null, 0);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -237,6 +237,8 @@ class AddressTableMap extends TableMap
|
||||
{
|
||||
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
|
||||
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
|
||||
$this->addRelation('CartRelatedByAddressDeliveryId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery_id', ), null, null, 'CartsRelatedByAddressDeliveryId');
|
||||
$this->addRelation('CartRelatedByAddressInvoiceId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice_id', ), null, null, 'CartsRelatedByAddressInvoiceId');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
@@ -405,7 +407,7 @@ class AddressTableMap extends TableMap
|
||||
$criteria->addSelectColumn(AddressTableMap::COUNTRY_ID);
|
||||
$criteria->addSelectColumn(AddressTableMap::PHONE);
|
||||
$criteria->addSelectColumn(AddressTableMap::CELLPHONE);
|
||||
$criteria->addSelectColumn(AddressTableMap::IS_DEFAULT);
|
||||
$criteria->addSelectColumn(AddressTableMap::DEFAULT);
|
||||
$criteria->addSelectColumn(AddressTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(AddressTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -424,7 +426,7 @@ class AddressTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.COUNTRY_ID');
|
||||
$criteria->addSelectColumn($alias . '.PHONE');
|
||||
$criteria->addSelectColumn($alias . '.CELLPHONE');
|
||||
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
|
||||
$criteria->addSelectColumn($alias . '.DEFAULT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
465
core/lib/Thelia/Model/Map/CartItemTableMap.php
Normal file
465
core/lib/Thelia/Model/Map/CartItemTableMap.php
Normal file
@@ -0,0 +1,465 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Map;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\RelationMap;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Map\TableMapTrait;
|
||||
use Thelia\Model\CartItem;
|
||||
use Thelia\Model\CartItemQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'cart_item' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
*/
|
||||
class CartItemTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Thelia.Model.Map.CartItemTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'cart_item';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Thelia\\Model\\CartItem';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Thelia.Model.CartItem';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 7;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
*/
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 7;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'cart_item.ID';
|
||||
|
||||
/**
|
||||
* the column name for the CART_ID field
|
||||
*/
|
||||
const CART_ID = 'cart_item.CART_ID';
|
||||
|
||||
/**
|
||||
* the column name for the PRODUCT_ID field
|
||||
*/
|
||||
const PRODUCT_ID = 'cart_item.PRODUCT_ID';
|
||||
|
||||
/**
|
||||
* the column name for the QUANTITY field
|
||||
*/
|
||||
const QUANTITY = 'cart_item.QUANTITY';
|
||||
|
||||
/**
|
||||
* the column name for the COMBINATION_ID field
|
||||
*/
|
||||
const COMBINATION_ID = 'cart_item.COMBINATION_ID';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
const CREATED_AT = 'cart_item.CREATED_AT';
|
||||
|
||||
/**
|
||||
* the column name for the UPDATED_AT field
|
||||
*/
|
||||
const UPDATED_AT = 'cart_item.UPDATED_AT';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
const DEFAULT_STRING_FORMAT = 'YAML';
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'CombinationId', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'combinationId', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::COMBINATION_ID, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'COMBINATION_ID', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'combination_id', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'CombinationId' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'combinationId' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::COMBINATION_ID => 4, CartItemTableMap::CREATED_AT => 5, CartItemTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'COMBINATION_ID' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'combination_id' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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('cart_item');
|
||||
$this->setPhpName('CartItem');
|
||||
$this->setClassName('\\Thelia\\Model\\CartItem');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('CART_ID', 'CartId', 'INTEGER', 'cart', 'ID', true, null, null);
|
||||
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
|
||||
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', false, null, 1);
|
||||
$this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', 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('Cart', '\\Thelia\\Model\\Cart', RelationMap::MANY_TO_ONE, array('cart_id' => 'id', ), null, null);
|
||||
$this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), null, null);
|
||||
$this->addRelation('Combination', '\\Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), null, null);
|
||||
} // 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 ? CartItemTableMap::CLASS_DEFAULT : CartItemTableMap::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 (CartItem object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = CartItemTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = CartItemTableMap::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 + CartItemTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = CartItemTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
CartItemTableMap::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 = CartItemTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = CartItemTableMap::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;
|
||||
CartItemTableMap::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(CartItemTableMap::ID);
|
||||
$criteria->addSelectColumn(CartItemTableMap::CART_ID);
|
||||
$criteria->addSelectColumn(CartItemTableMap::PRODUCT_ID);
|
||||
$criteria->addSelectColumn(CartItemTableMap::QUANTITY);
|
||||
$criteria->addSelectColumn(CartItemTableMap::COMBINATION_ID);
|
||||
$criteria->addSelectColumn(CartItemTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CartItemTableMap::UPDATED_AT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.CART_ID');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_ID');
|
||||
$criteria->addSelectColumn($alias . '.QUANTITY');
|
||||
$criteria->addSelectColumn($alias . '.COMBINATION_ID');
|
||||
$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(CartItemTableMap::DATABASE_NAME)->getTable(CartItemTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CartItemTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(CartItemTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new CartItemTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a CartItem or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or CartItem 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(CartItemTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Thelia\Model\CartItem) { // 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(CartItemTableMap::DATABASE_NAME);
|
||||
$criteria->add(CartItemTableMap::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
$query = CartItemQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { CartItemTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { CartItemTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the cart_item 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 CartItemQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a CartItem or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or CartItem 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(CartItemTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from CartItem object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(CartItemTableMap::ID) && $criteria->keyContainsValue(CartItemTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CartItemTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = CartItemQuery::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;
|
||||
}
|
||||
|
||||
} // CartItemTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
CartItemTableMap::buildTableMap();
|
||||
475
core/lib/Thelia/Model/Map/CartTableMap.php
Normal file
475
core/lib/Thelia/Model/Map/CartTableMap.php
Normal file
@@ -0,0 +1,475 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Map;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\RelationMap;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Map\TableMapTrait;
|
||||
use Thelia\Model\Cart;
|
||||
use Thelia\Model\CartQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'cart' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
*/
|
||||
class CartTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Thelia.Model.Map.CartTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'cart';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Thelia\\Model\\Cart';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Thelia.Model.Cart';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
*/
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'cart.ID';
|
||||
|
||||
/**
|
||||
* the column name for the TOKEN field
|
||||
*/
|
||||
const TOKEN = 'cart.TOKEN';
|
||||
|
||||
/**
|
||||
* the column name for the CUSTOMER_ID field
|
||||
*/
|
||||
const CUSTOMER_ID = 'cart.CUSTOMER_ID';
|
||||
|
||||
/**
|
||||
* the column name for the ADDRESS_DELIVERY_ID field
|
||||
*/
|
||||
const ADDRESS_DELIVERY_ID = 'cart.ADDRESS_DELIVERY_ID';
|
||||
|
||||
/**
|
||||
* the column name for the ADDRESS_INVOICE_ID field
|
||||
*/
|
||||
const ADDRESS_INVOICE_ID = 'cart.ADDRESS_INVOICE_ID';
|
||||
|
||||
/**
|
||||
* the column name for the CURRENCY_ID field
|
||||
*/
|
||||
const CURRENCY_ID = 'cart.CURRENCY_ID';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
*/
|
||||
const CREATED_AT = 'cart.CREATED_AT';
|
||||
|
||||
/**
|
||||
* the column name for the UPDATED_AT field
|
||||
*/
|
||||
const UPDATED_AT = 'cart.UPDATED_AT';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
const DEFAULT_STRING_FORMAT = 'YAML';
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Token', 'CustomerId', 'AddressDeliveryId', 'AddressInvoiceId', 'CurrencyId', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'token', 'customerId', 'addressDeliveryId', 'addressInvoiceId', 'currencyId', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(CartTableMap::ID, CartTableMap::TOKEN, CartTableMap::CUSTOMER_ID, CartTableMap::ADDRESS_DELIVERY_ID, CartTableMap::ADDRESS_INVOICE_ID, CartTableMap::CURRENCY_ID, CartTableMap::CREATED_AT, CartTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'TOKEN', 'CUSTOMER_ID', 'ADDRESS_DELIVERY_ID', 'ADDRESS_INVOICE_ID', 'CURRENCY_ID', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'token', 'customer_id', 'address_delivery_id', 'address_invoice_id', 'currency_id', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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, 'Token' => 1, 'CustomerId' => 2, 'AddressDeliveryId' => 3, 'AddressInvoiceId' => 4, 'CurrencyId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'token' => 1, 'customerId' => 2, 'addressDeliveryId' => 3, 'addressInvoiceId' => 4, 'currencyId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
|
||||
self::TYPE_COLNAME => array(CartTableMap::ID => 0, CartTableMap::TOKEN => 1, CartTableMap::CUSTOMER_ID => 2, CartTableMap::ADDRESS_DELIVERY_ID => 3, CartTableMap::ADDRESS_INVOICE_ID => 4, CartTableMap::CURRENCY_ID => 5, CartTableMap::CREATED_AT => 6, CartTableMap::UPDATED_AT => 7, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TOKEN' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_DELIVERY_ID' => 3, 'ADDRESS_INVOICE_ID' => 4, 'CURRENCY_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'token' => 1, 'customer_id' => 2, 'address_delivery_id' => 3, 'address_invoice_id' => 4, 'currency_id' => 5, 'created_at' => 6, 'updated_at' => 7, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
* 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('cart');
|
||||
$this->setPhpName('Cart');
|
||||
$this->setClassName('\\Thelia\\Model\\Cart');
|
||||
$this->setPackage('Thelia.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('TOKEN', 'Token', 'VARCHAR', true, 255, null);
|
||||
$this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', false, null, null);
|
||||
$this->addForeignKey('ADDRESS_DELIVERY_ID', 'AddressDeliveryId', 'INTEGER', 'address', 'ID', false, null, null);
|
||||
$this->addForeignKey('ADDRESS_INVOICE_ID', 'AddressInvoiceId', 'INTEGER', 'address', 'ID', false, null, null);
|
||||
$this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', 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('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), null, null);
|
||||
$this->addRelation('AddressRelatedByAddressDeliveryId', '\\Thelia\\Model\\Address', RelationMap::MANY_TO_ONE, array('address_delivery_id' => 'id', ), null, null);
|
||||
$this->addRelation('AddressRelatedByAddressInvoiceId', '\\Thelia\\Model\\Address', RelationMap::MANY_TO_ONE, array('address_invoice_id' => 'id', ), null, null);
|
||||
$this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), null, null);
|
||||
$this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'cart_id', ), null, null, 'CartItems');
|
||||
} // 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 ? CartTableMap::CLASS_DEFAULT : CartTableMap::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 (Cart object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = CartTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = CartTableMap::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 + CartTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = CartTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
CartTableMap::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 = CartTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = CartTableMap::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;
|
||||
CartTableMap::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(CartTableMap::ID);
|
||||
$criteria->addSelectColumn(CartTableMap::TOKEN);
|
||||
$criteria->addSelectColumn(CartTableMap::CUSTOMER_ID);
|
||||
$criteria->addSelectColumn(CartTableMap::ADDRESS_DELIVERY_ID);
|
||||
$criteria->addSelectColumn(CartTableMap::ADDRESS_INVOICE_ID);
|
||||
$criteria->addSelectColumn(CartTableMap::CURRENCY_ID);
|
||||
$criteria->addSelectColumn(CartTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(CartTableMap::UPDATED_AT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.TOKEN');
|
||||
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
|
||||
$criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY_ID');
|
||||
$criteria->addSelectColumn($alias . '.ADDRESS_INVOICE_ID');
|
||||
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
|
||||
$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(CartTableMap::DATABASE_NAME)->getTable(CartTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CartTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(CartTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new CartTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a Cart or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or Cart 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(CartTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Thelia\Model\Cart) { // 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(CartTableMap::DATABASE_NAME);
|
||||
$criteria->add(CartTableMap::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
$query = CartQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { CartTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { CartTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the cart 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 CartQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a Cart or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or Cart 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(CartTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from Cart object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(CartTableMap::ID) && $criteria->keyContainsValue(CartTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CartTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = CartQuery::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;
|
||||
}
|
||||
|
||||
} // CartTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
CartTableMap::buildTableMap();
|
||||
@@ -153,6 +153,7 @@ class CombinationTableMap extends TableMap
|
||||
{
|
||||
$this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations');
|
||||
$this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT', 'Stocks');
|
||||
$this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), null, null, 'CartItems');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
|
||||
@@ -176,6 +176,7 @@ class CurrencyTableMap extends TableMap
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders');
|
||||
$this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), null, null, 'Carts');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
|
||||
@@ -192,7 +192,7 @@ class CustomerTableMap extends TableMap
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null);
|
||||
$this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
|
||||
$this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', true, null, null);
|
||||
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null);
|
||||
@@ -214,6 +214,7 @@ class CustomerTableMap extends TableMap
|
||||
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
|
||||
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses');
|
||||
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders');
|
||||
$this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), null, null, 'Carts');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,6 +248,7 @@ class ProductTableMap extends TableMap
|
||||
$this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId');
|
||||
$this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory');
|
||||
$this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
|
||||
$this->addRelation('CartItem', '\\Thelia\\Model\\CartItem', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), null, null, 'CartItems');
|
||||
$this->addRelation('ProductI18n', '\\Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns');
|
||||
$this->addRelation('ProductVersion', '\\Thelia\\Model\\ProductVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductVersions');
|
||||
$this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories');
|
||||
|
||||
@@ -90,9 +90,9 @@ class StockTableMap extends TableMap
|
||||
const INCREASE = 'stock.INCREASE';
|
||||
|
||||
/**
|
||||
* the column name for the VALUE field
|
||||
* the column name for the QUANTITY field
|
||||
*/
|
||||
const VALUE = 'stock.VALUE';
|
||||
const QUANTITY = 'stock.QUANTITY';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
@@ -116,11 +116,11 @@ class StockTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'CombinationId', 'ProductId', 'Increase', 'Value', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'combinationId', 'productId', 'increase', 'value', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(StockTableMap::ID, StockTableMap::COMBINATION_ID, StockTableMap::PRODUCT_ID, StockTableMap::INCREASE, StockTableMap::VALUE, StockTableMap::CREATED_AT, StockTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'combination_id', 'product_id', 'increase', 'value', 'created_at', 'updated_at', ),
|
||||
self::TYPE_PHPNAME => array('Id', 'CombinationId', 'ProductId', 'Increase', 'Quantity', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'combinationId', 'productId', 'increase', 'quantity', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(StockTableMap::ID, StockTableMap::COMBINATION_ID, StockTableMap::PRODUCT_ID, StockTableMap::INCREASE, StockTableMap::QUANTITY, StockTableMap::CREATED_AT, StockTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'QUANTITY', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'combination_id', 'product_id', 'increase', 'quantity', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
@@ -131,11 +131,11 @@ class StockTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(StockTableMap::ID => 0, StockTableMap::COMBINATION_ID => 1, StockTableMap::PRODUCT_ID => 2, StockTableMap::INCREASE => 3, StockTableMap::VALUE => 4, StockTableMap::CREATED_AT => 5, StockTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Quantity' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'quantity' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||
self::TYPE_COLNAME => array(StockTableMap::ID => 0, StockTableMap::COMBINATION_ID => 1, StockTableMap::PRODUCT_ID => 2, StockTableMap::INCREASE => 3, StockTableMap::QUANTITY => 4, StockTableMap::CREATED_AT => 5, StockTableMap::UPDATED_AT => 6, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'QUANTITY' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'quantity' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||
);
|
||||
|
||||
@@ -159,7 +159,7 @@ class StockTableMap extends TableMap
|
||||
$this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', false, null, null);
|
||||
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
|
||||
$this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, null);
|
||||
$this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
|
||||
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -328,7 +328,7 @@ class StockTableMap extends TableMap
|
||||
$criteria->addSelectColumn(StockTableMap::COMBINATION_ID);
|
||||
$criteria->addSelectColumn(StockTableMap::PRODUCT_ID);
|
||||
$criteria->addSelectColumn(StockTableMap::INCREASE);
|
||||
$criteria->addSelectColumn(StockTableMap::VALUE);
|
||||
$criteria->addSelectColumn(StockTableMap::QUANTITY);
|
||||
$criteria->addSelectColumn(StockTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(StockTableMap::UPDATED_AT);
|
||||
} else {
|
||||
@@ -336,7 +336,7 @@ class StockTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.COMBINATION_ID');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_ID');
|
||||
$criteria->addSelectColumn($alias . '.INCREASE');
|
||||
$criteria->addSelectColumn($alias . '.VALUE');
|
||||
$criteria->addSelectColumn($alias . '.QUANTITY');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user