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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user