address loop

title loop
This commit is contained in:
Etienne Roudeix
2013-07-26 15:41:46 +02:00
parent 9e663145b0
commit caf3a91ac6
18 changed files with 1338 additions and 132 deletions

View File

@@ -6,11 +6,13 @@
<loops>
<loop class="Thelia\Core\Template\Loop\Accessory" name="accessory"/>
<loop class="Thelia\Core\Template\Loop\Address" name="address"/>
<loop class="Thelia\Core\Template\Loop\Auth" name="auth"/>
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
<loop class="Thelia\Core\Template\Loop\Customer" name="customer"/>
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
<loop class="Thelia\Core\Template\Loop\Auth" name="auth"/>
<loop class="Thelia\Core\Template\Loop\Title" name="title"/>
</loops>
<forms>

View File

@@ -0,0 +1,144 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/**
*
* Address loop
*
*
* Class Address
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Address extends BaseLoop
{
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
new Argument(
'customer',
new TypeCollection(
new Type\IntType(),
new Type\EnumType(array('current'))
),
'current'
),
Argument::createBooleanTypeArgument('default'),
Argument::createIntListTypeArgument('exclude')
);
}
/**
* @param $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$search = AddressQuery::create();
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
$customer = $this->getCustomer();
if ($customer === 'current') {
$currentCustomer = $this->request->getSession()->getCustomerUser();
if($currentCustomer === null) {
return new LoopResult();
} else {
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
}
} else {
$search->filterByCustomerId($customer, Criteria::EQUAL);
}
$default = $this->getDefault();
if ($default === true) {
$search->filterByIsDefault(1, Criteria::EQUAL);
} elseif($default === false) {
$search->filterByIsDefault(1, Criteria::NOT_EQUAL);
}
$exclude = $this->getExclude();
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
$addresses = $this->search($search, $pagination);
$loopResult = new LoopResult();
foreach ($addresses as $address) {
if ($this->not_empty && $address->countAllProducts() == 0) continue;
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ID", $address->getId());
$loopResultRow->set("NAME", $address->getName());
$loopResultRow->set("CUSTOMER", $address->getCustomerId());
$loopResultRow->set("TITLE", $address->getTitleId());
$loopResultRow->set("COMPANY", $address->getCompany());
$loopResultRow->set("FIRSTNAME", $address->getFirstname());
$loopResultRow->set("LASTNAME", $address->getLastname());
$loopResultRow->set("ADDRESS1", $address->getAddress1());
$loopResultRow->set("ADDRESS2", $address->getAddress2());
$loopResultRow->set("ADDRESS3", $address->getAddress3());
$loopResultRow->set("ZIPCODE", $address->getZipcode());
$loopResultRow->set("CITY", $address->getCity());
$loopResultRow->set("COUNTRY", $address->getCountryId());
$loopResultRow->set("PHONE", $address->getPhone());
$loopResultRow->set("CELLPHONE", $address->getCellphone());
$loopResultRow->set("DEFAULT", $address->getIsDefault());
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -124,7 +124,7 @@ class Customer extends BaseLoop
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ID", $customer->getId());
$loopResultRow->set("REF", $customer->getRef());
$loopResultRow->set("TITLE", $customer->getTitleid());
$loopResultRow->set("TITLE", $customer->getTitleId());
$loopResultRow->set("FIRSTNAME", $customer->getFirstname());
$loopResultRow->set("LASTNAME", $customer->getLastname());
$loopResultRow->set("EMAIL", $customer->getEmail());

View File

@@ -0,0 +1,108 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CustomerTitleQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/**
*
* Title loop
*
*
* Class Title
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Title extends BaseLoop
{
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id')
);
}
/**
* @param $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec(&$pagination)
{
$search = CustomerTitleQuery::create();
$id = $this->getId();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
/**
* Criteria::INNER_JOIN in second parameter for joinWithI18n exclude query without translation.
*
* @todo : verify here if we want results for row without translations.
*/
$search->joinWithI18n(
$this->request->getSession()->getLocale(),
(ConfigQuery::read("default_lang_without_translation", 1)) ? Criteria::LEFT_JOIN : Criteria::INNER_JOIN
);
$search->orderByPosition();
$titles = $this->search($search, $pagination);
$loopResult = new LoopResult();
foreach ($titles as $title) {
if ($this->not_empty && $title->countAllProducts() == 0) continue;
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ID", $title->getId());
$loopResultRow->set("DEFAULT", $title->getByDefault());
$loopResultRow->set("SHORT", $title->getShort());
$loopResultRow->set("LONG", $title->getLong());
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -21,6 +21,8 @@ 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\Country as ChildCountry;
use Thelia\Model\CountryQuery as ChildCountryQuery;
use Thelia\Model\Customer as ChildCustomer;
use Thelia\Model\CustomerQuery as ChildCustomerQuery;
use Thelia\Model\CustomerTitle as ChildCustomerTitle;
@@ -68,10 +70,10 @@ abstract class Address implements ActiveRecordInterface
protected $id;
/**
* The value for the title field.
* The value for the name field.
* @var string
*/
protected $title;
protected $name;
/**
* The value for the customer_id field.
@@ -80,10 +82,10 @@ abstract class Address implements ActiveRecordInterface
protected $customer_id;
/**
* The value for the customer_title_id field.
* The value for the title_id field.
* @var int
*/
protected $customer_title_id;
protected $title_id;
/**
* The value for the company field.
@@ -180,6 +182,11 @@ abstract class Address implements ActiveRecordInterface
*/
protected $aCustomerTitle;
/**
* @var Country
*/
protected $aCountry;
/**
* @var ObjectCollection|ChildCart[] Collection to store aggregation of ChildCart objects.
*/
@@ -491,14 +498,14 @@ abstract class Address implements ActiveRecordInterface
}
/**
* Get the [title] column value.
* Get the [name] column value.
*
* @return string
*/
public function getTitle()
public function getName()
{
return $this->title;
return $this->name;
}
/**
@@ -513,14 +520,14 @@ abstract class Address implements ActiveRecordInterface
}
/**
* Get the [customer_title_id] column value.
* Get the [title_id] column value.
*
* @return int
*/
public function getCustomerTitleId()
public function getTitleId()
{
return $this->customer_title_id;
return $this->title_id;
}
/**
@@ -717,25 +724,25 @@ abstract class Address implements ActiveRecordInterface
} // setId()
/**
* Set the value of [title] column.
* Set the value of [name] column.
*
* @param string $v new value
* @return \Thelia\Model\Address The current object (for fluent API support)
*/
public function setTitle($v)
public function setName($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->title !== $v) {
$this->title = $v;
$this->modifiedColumns[] = AddressTableMap::TITLE;
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = AddressTableMap::NAME;
}
return $this;
} // setTitle()
} // setName()
/**
* Set the value of [customer_id] column.
@@ -763,20 +770,20 @@ abstract class Address implements ActiveRecordInterface
} // setCustomerId()
/**
* Set the value of [customer_title_id] column.
* Set the value of [title_id] column.
*
* @param int $v new value
* @return \Thelia\Model\Address The current object (for fluent API support)
*/
public function setCustomerTitleId($v)
public function setTitleId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->customer_title_id !== $v) {
$this->customer_title_id = $v;
$this->modifiedColumns[] = AddressTableMap::CUSTOMER_TITLE_ID;
if ($this->title_id !== $v) {
$this->title_id = $v;
$this->modifiedColumns[] = AddressTableMap::TITLE_ID;
}
if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
@@ -785,7 +792,7 @@ abstract class Address implements ActiveRecordInterface
return $this;
} // setCustomerTitleId()
} // setTitleId()
/**
* Set the value of [company] column.
@@ -972,6 +979,10 @@ abstract class Address implements ActiveRecordInterface
$this->modifiedColumns[] = AddressTableMap::COUNTRY_ID;
}
if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
$this->aCountry = null;
}
return $this;
} // setCountryId()
@@ -1125,14 +1136,14 @@ abstract class Address implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
$this->id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
$this->title = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
$this->name = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AddressTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_title_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('TitleId', TableMap::TYPE_PHPNAME, $indexType)];
$this->title_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)];
$this->company = (null !== $col) ? (string) $col : null;
@@ -1214,9 +1225,12 @@ abstract class Address implements ActiveRecordInterface
if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
$this->aCustomer = null;
}
if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
if ($this->aCustomerTitle !== null && $this->title_id !== $this->aCustomerTitle->getId()) {
$this->aCustomerTitle = null;
}
if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
$this->aCountry = null;
}
} // ensureConsistency
/**
@@ -1258,6 +1272,7 @@ abstract class Address implements ActiveRecordInterface
$this->aCustomer = null;
$this->aCustomerTitle = null;
$this->aCountry = null;
$this->collCartsRelatedByAddressDeliveryId = null;
$this->collCartsRelatedByAddressInvoiceId = null;
@@ -1403,6 +1418,13 @@ abstract class Address implements ActiveRecordInterface
$this->setCustomerTitle($this->aCustomerTitle);
}
if ($this->aCountry !== null) {
if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
$affectedRows += $this->aCountry->save($con);
}
$this->setCountry($this->aCountry);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
@@ -1479,14 +1501,14 @@ abstract class Address implements ActiveRecordInterface
if ($this->isColumnModified(AddressTableMap::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(AddressTableMap::TITLE)) {
$modifiedColumns[':p' . $index++] = 'TITLE';
if ($this->isColumnModified(AddressTableMap::NAME)) {
$modifiedColumns[':p' . $index++] = 'NAME';
}
if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
}
if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID';
if ($this->isColumnModified(AddressTableMap::TITLE_ID)) {
$modifiedColumns[':p' . $index++] = 'TITLE_ID';
}
if ($this->isColumnModified(AddressTableMap::COMPANY)) {
$modifiedColumns[':p' . $index++] = 'COMPANY';
@@ -1544,14 +1566,14 @@ abstract class Address implements ActiveRecordInterface
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'TITLE':
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
case 'NAME':
$stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
break;
case 'CUSTOMER_ID':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
case 'CUSTOMER_TITLE_ID':
$stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
case 'TITLE_ID':
$stmt->bindValue($identifier, $this->title_id, PDO::PARAM_INT);
break;
case 'COMPANY':
$stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
@@ -1661,13 +1683,13 @@ abstract class Address implements ActiveRecordInterface
return $this->getId();
break;
case 1:
return $this->getTitle();
return $this->getName();
break;
case 2:
return $this->getCustomerId();
break;
case 3:
return $this->getCustomerTitleId();
return $this->getTitleId();
break;
case 4:
return $this->getCompany();
@@ -1741,9 +1763,9 @@ abstract class Address implements ActiveRecordInterface
$keys = AddressTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getTitle(),
$keys[1] => $this->getName(),
$keys[2] => $this->getCustomerId(),
$keys[3] => $this->getCustomerTitleId(),
$keys[3] => $this->getTitleId(),
$keys[4] => $this->getCompany(),
$keys[5] => $this->getFirstname(),
$keys[6] => $this->getLastname(),
@@ -1772,6 +1794,9 @@ abstract class Address implements ActiveRecordInterface
if (null !== $this->aCustomerTitle) {
$result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCountry) {
$result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collCartsRelatedByAddressDeliveryId) {
$result['CartsRelatedByAddressDeliveryId'] = $this->collCartsRelatedByAddressDeliveryId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
@@ -1816,13 +1841,13 @@ abstract class Address implements ActiveRecordInterface
$this->setId($value);
break;
case 1:
$this->setTitle($value);
$this->setName($value);
break;
case 2:
$this->setCustomerId($value);
break;
case 3:
$this->setCustomerTitleId($value);
$this->setTitleId($value);
break;
case 4:
$this->setCompany($value);
@@ -1891,9 +1916,9 @@ abstract class Address implements ActiveRecordInterface
$keys = AddressTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setCustomerTitleId($arr[$keys[3]]);
if (array_key_exists($keys[3], $arr)) $this->setTitleId($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setCompany($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setFirstname($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setLastname($arr[$keys[6]]);
@@ -1920,9 +1945,9 @@ abstract class Address implements ActiveRecordInterface
$criteria = new Criteria(AddressTableMap::DATABASE_NAME);
if ($this->isColumnModified(AddressTableMap::ID)) $criteria->add(AddressTableMap::ID, $this->id);
if ($this->isColumnModified(AddressTableMap::TITLE)) $criteria->add(AddressTableMap::TITLE, $this->title);
if ($this->isColumnModified(AddressTableMap::NAME)) $criteria->add(AddressTableMap::NAME, $this->name);
if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) $criteria->add(AddressTableMap::CUSTOMER_ID, $this->customer_id);
if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(AddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id);
if ($this->isColumnModified(AddressTableMap::TITLE_ID)) $criteria->add(AddressTableMap::TITLE_ID, $this->title_id);
if ($this->isColumnModified(AddressTableMap::COMPANY)) $criteria->add(AddressTableMap::COMPANY, $this->company);
if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) $criteria->add(AddressTableMap::FIRSTNAME, $this->firstname);
if ($this->isColumnModified(AddressTableMap::LASTNAME)) $criteria->add(AddressTableMap::LASTNAME, $this->lastname);
@@ -2000,9 +2025,9 @@ abstract class Address implements ActiveRecordInterface
*/
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setTitle($this->getTitle());
$copyObj->setName($this->getName());
$copyObj->setCustomerId($this->getCustomerId());
$copyObj->setCustomerTitleId($this->getCustomerTitleId());
$copyObj->setTitleId($this->getTitleId());
$copyObj->setCompany($this->getCompany());
$copyObj->setFirstname($this->getFirstname());
$copyObj->setLastname($this->getLastname());
@@ -2126,9 +2151,9 @@ abstract class Address implements ActiveRecordInterface
public function setCustomerTitle(ChildCustomerTitle $v = null)
{
if ($v === null) {
$this->setCustomerTitleId(NULL);
$this->setTitleId(NULL);
} else {
$this->setCustomerTitleId($v->getId());
$this->setTitleId($v->getId());
}
$this->aCustomerTitle = $v;
@@ -2153,8 +2178,8 @@ abstract class Address implements ActiveRecordInterface
*/
public function getCustomerTitle(ConnectionInterface $con = null)
{
if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
$this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con);
if ($this->aCustomerTitle === null && ($this->title_id !== null)) {
$this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->title_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
@@ -2167,6 +2192,57 @@ abstract class Address implements ActiveRecordInterface
return $this->aCustomerTitle;
}
/**
* Declares an association between this object and a ChildCountry object.
*
* @param ChildCountry $v
* @return \Thelia\Model\Address The current object (for fluent API support)
* @throws PropelException
*/
public function setCountry(ChildCountry $v = null)
{
if ($v === null) {
$this->setCountryId(NULL);
} else {
$this->setCountryId($v->getId());
}
$this->aCountry = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCountry object, it will not be re-added.
if ($v !== null) {
$v->addAddress($this);
}
return $this;
}
/**
* Get the associated ChildCountry object
*
* @param ConnectionInterface $con Optional Connection object.
* @return ChildCountry The associated ChildCountry object.
* @throws PropelException
*/
public function getCountry(ConnectionInterface $con = null)
{
if ($this->aCountry === null && ($this->country_id !== null)) {
$this->aCountry = ChildCountryQuery::create()->findPk($this->country_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCountry->addAddresses($this);
*/
}
return $this->aCountry;
}
/**
* Initializes a collection based on the name of a relation.
@@ -2728,9 +2804,9 @@ abstract class Address implements ActiveRecordInterface
public function clear()
{
$this->id = null;
$this->title = null;
$this->name = null;
$this->customer_id = null;
$this->customer_title_id = null;
$this->title_id = null;
$this->company = null;
$this->firstname = null;
$this->lastname = null;
@@ -2787,6 +2863,7 @@ abstract class Address implements ActiveRecordInterface
$this->collCartsRelatedByAddressInvoiceId = null;
$this->aCustomer = null;
$this->aCustomerTitle = null;
$this->aCountry = null;
}
/**

View File

@@ -22,9 +22,9 @@ use Thelia\Model\Map\AddressTableMap;
*
*
* @method ChildAddressQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildAddressQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildAddressQuery orderByName($order = Criteria::ASC) Order by the name column
* @method ChildAddressQuery orderByCustomerId($order = Criteria::ASC) Order by the customer_id column
* @method ChildAddressQuery orderByCustomerTitleId($order = Criteria::ASC) Order by the customer_title_id column
* @method ChildAddressQuery orderByTitleId($order = Criteria::ASC) Order by the title_id column
* @method ChildAddressQuery orderByCompany($order = Criteria::ASC) Order by the company column
* @method ChildAddressQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
* @method ChildAddressQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
@@ -41,9 +41,9 @@ use Thelia\Model\Map\AddressTableMap;
* @method ChildAddressQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildAddressQuery groupById() Group by the id column
* @method ChildAddressQuery groupByTitle() Group by the title column
* @method ChildAddressQuery groupByName() Group by the name column
* @method ChildAddressQuery groupByCustomerId() Group by the customer_id column
* @method ChildAddressQuery groupByCustomerTitleId() Group by the customer_title_id column
* @method ChildAddressQuery groupByTitleId() Group by the title_id column
* @method ChildAddressQuery groupByCompany() Group by the company column
* @method ChildAddressQuery groupByFirstname() Group by the firstname column
* @method ChildAddressQuery groupByLastname() Group by the lastname column
@@ -71,6 +71,10 @@ 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 leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
* @method ChildAddressQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
* @method ChildAddressQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country 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
@@ -83,9 +87,9 @@ use Thelia\Model\Map\AddressTableMap;
* @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
*
* @method ChildAddress findOneById(int $id) Return the first ChildAddress filtered by the id column
* @method ChildAddress findOneByTitle(string $title) Return the first ChildAddress filtered by the title column
* @method ChildAddress findOneByName(string $name) Return the first ChildAddress filtered by the name column
* @method ChildAddress findOneByCustomerId(int $customer_id) Return the first ChildAddress filtered by the customer_id column
* @method ChildAddress findOneByCustomerTitleId(int $customer_title_id) Return the first ChildAddress filtered by the customer_title_id column
* @method ChildAddress findOneByTitleId(int $title_id) Return the first ChildAddress filtered by the title_id column
* @method ChildAddress findOneByCompany(string $company) Return the first ChildAddress filtered by the company column
* @method ChildAddress findOneByFirstname(string $firstname) Return the first ChildAddress filtered by the firstname column
* @method ChildAddress findOneByLastname(string $lastname) Return the first ChildAddress filtered by the lastname column
@@ -102,9 +106,9 @@ use Thelia\Model\Map\AddressTableMap;
* @method ChildAddress findOneByUpdatedAt(string $updated_at) Return the first ChildAddress filtered by the updated_at column
*
* @method array findById(int $id) Return ChildAddress objects filtered by the id column
* @method array findByTitle(string $title) Return ChildAddress objects filtered by the title column
* @method array findByName(string $name) Return ChildAddress objects filtered by the name column
* @method array findByCustomerId(int $customer_id) Return ChildAddress objects filtered by the customer_id column
* @method array findByCustomerTitleId(int $customer_title_id) Return ChildAddress objects filtered by the customer_title_id column
* @method array findByTitleId(int $title_id) Return ChildAddress objects filtered by the title_id column
* @method array findByCompany(string $company) Return ChildAddress objects filtered by the company column
* @method array findByFirstname(string $firstname) Return ChildAddress objects filtered by the firstname column
* @method array findByLastname(string $lastname) Return ChildAddress objects filtered by the lastname column
@@ -207,7 +211,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, NAME, CUSTOMER_ID, 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';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -338,32 +342,32 @@ abstract class AddressQuery extends ModelCriteria
}
/**
* Filter the query on the title column
* Filter the query on the name column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* $query->filterByName('fooValue'); // WHERE name = 'fooValue'
* $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* @param string $name The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildAddressQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
public function filterByName($name = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
if (is_array($name)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
} elseif (preg_match('/[\%\*]/', $name)) {
$name = str_replace('*', '%', $name);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(AddressTableMap::TITLE, $title, $comparison);
return $this->addUsingAlias(AddressTableMap::NAME, $name, $comparison);
}
/**
@@ -410,18 +414,18 @@ abstract class AddressQuery extends ModelCriteria
}
/**
* Filter the query on the customer_title_id column
* Filter the query on the title_id column
*
* Example usage:
* <code>
* $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
* $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
* $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
* $query->filterByTitleId(1234); // WHERE title_id = 1234
* $query->filterByTitleId(array(12, 34)); // WHERE title_id IN (12, 34)
* $query->filterByTitleId(array('min' => 12)); // WHERE title_id > 12
* </code>
*
* @see filterByCustomerTitle()
*
* @param mixed $customerTitleId The value to use as filter.
* @param mixed $titleId 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.
@@ -429,16 +433,16 @@ abstract class AddressQuery extends ModelCriteria
*
* @return ChildAddressQuery The current query, for fluid interface
*/
public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
public function filterByTitleId($titleId = null, $comparison = null)
{
if (is_array($customerTitleId)) {
if (is_array($titleId)) {
$useMinMax = false;
if (isset($customerTitleId['min'])) {
$this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
if (isset($titleId['min'])) {
$this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($customerTitleId['max'])) {
$this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
if (isset($titleId['max'])) {
$this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@@ -449,7 +453,7 @@ abstract class AddressQuery extends ModelCriteria
}
}
return $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
return $this->addUsingAlias(AddressTableMap::TITLE_ID, $titleId, $comparison);
}
/**
@@ -694,6 +698,8 @@ abstract class AddressQuery extends ModelCriteria
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
* </code>
*
* @see filterByCountry()
*
* @param mixed $countryId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
@@ -997,14 +1003,14 @@ abstract class AddressQuery extends ModelCriteria
{
if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
return $this
->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
->addUsingAlias(AddressTableMap::TITLE_ID, $customerTitle->getId(), $comparison);
} elseif ($customerTitle instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
->addUsingAlias(AddressTableMap::TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
}
@@ -1018,7 +1024,7 @@ abstract class AddressQuery extends ModelCriteria
*
* @return ChildAddressQuery 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');
@@ -1053,13 +1059,88 @@ abstract class AddressQuery 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)
->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
}
/**
* Filter the query by a related \Thelia\Model\Country object
*
* @param \Thelia\Model\Country|ObjectCollection $country The related object(s) 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 filterByCountry($country, $comparison = null)
{
if ($country instanceof \Thelia\Model\Country) {
return $this
->addUsingAlias(AddressTableMap::COUNTRY_ID, $country->getId(), $comparison);
} elseif ($country instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(AddressTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Country 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 joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Country');
// 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, 'Country');
}
return $this;
}
/**
* Use the Country relation Country 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\CountryQuery A secondary query class using the current class as primary query
*/
public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCountry($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
}
/**
* Filter the query by a related \Thelia\Model\Cart object
*

View File

@@ -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\Address as ChildAddress;
use Thelia\Model\AddressQuery as ChildAddressQuery;
use Thelia\Model\Area as ChildArea;
use Thelia\Model\AreaQuery as ChildAreaQuery;
use Thelia\Model\Country as ChildCountry;
@@ -114,6 +116,12 @@ abstract class Country implements ActiveRecordInterface
protected $collTaxRuleCountries;
protected $collTaxRuleCountriesPartial;
/**
* @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects.
*/
protected $collAddresses;
protected $collAddressesPartial;
/**
* @var ObjectCollection|ChildCountryI18n[] Collection to store aggregation of ChildCountryI18n objects.
*/
@@ -148,6 +156,12 @@ abstract class Country implements ActiveRecordInterface
*/
protected $taxRuleCountriesScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
*/
protected $addressesScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -792,6 +806,8 @@ abstract class Country implements ActiveRecordInterface
$this->aArea = null;
$this->collTaxRuleCountries = null;
$this->collAddresses = null;
$this->collCountryI18ns = null;
} // if (deep)
@@ -956,6 +972,23 @@ abstract class Country implements ActiveRecordInterface
}
}
if ($this->addressesScheduledForDeletion !== null) {
if (!$this->addressesScheduledForDeletion->isEmpty()) {
\Thelia\Model\AddressQuery::create()
->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->addressesScheduledForDeletion = null;
}
}
if ($this->collAddresses !== null) {
foreach ($this->collAddresses as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->countryI18nsScheduledForDeletion !== null) {
if (!$this->countryI18nsScheduledForDeletion->isEmpty()) {
\Thelia\Model\CountryI18nQuery::create()
@@ -1174,6 +1207,9 @@ abstract class Country implements ActiveRecordInterface
if (null !== $this->collTaxRuleCountries) {
$result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collAddresses) {
$result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collCountryI18ns) {
$result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
@@ -1363,6 +1399,12 @@ abstract class Country implements ActiveRecordInterface
}
}
foreach ($this->getAddresses() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addAddress($relObj->copy($deepCopy));
}
}
foreach ($this->getCountryI18ns() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCountryI18n($relObj->copy($deepCopy));
@@ -1463,6 +1505,9 @@ abstract class Country implements ActiveRecordInterface
if ('TaxRuleCountry' == $relationName) {
return $this->initTaxRuleCountries();
}
if ('Address' == $relationName) {
return $this->initAddresses();
}
if ('CountryI18n' == $relationName) {
return $this->initCountryI18ns();
}
@@ -1736,6 +1781,274 @@ abstract class Country implements ActiveRecordInterface
return $this->getTaxRuleCountries($query, $con);
}
/**
* Clears out the collAddresses 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 addAddresses()
*/
public function clearAddresses()
{
$this->collAddresses = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Reset is the collAddresses collection loaded partially.
*/
public function resetPartialAddresses($v = true)
{
$this->collAddressesPartial = $v;
}
/**
* Initializes the collAddresses collection.
*
* By default this just sets the collAddresses collection to an empty array (like clearcollAddresses());
* 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 initAddresses($overrideExisting = true)
{
if (null !== $this->collAddresses && !$overrideExisting) {
return;
}
$this->collAddresses = new ObjectCollection();
$this->collAddresses->setModel('\Thelia\Model\Address');
}
/**
* Gets an array of ChildAddress 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 ChildCountry 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|ChildAddress[] List of ChildAddress objects
* @throws PropelException
*/
public function getAddresses($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collAddressesPartial && !$this->isNew();
if (null === $this->collAddresses || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAddresses) {
// return empty collection
$this->initAddresses();
} else {
$collAddresses = ChildAddressQuery::create(null, $criteria)
->filterByCountry($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collAddressesPartial && count($collAddresses)) {
$this->initAddresses(false);
foreach ($collAddresses as $obj) {
if (false == $this->collAddresses->contains($obj)) {
$this->collAddresses->append($obj);
}
}
$this->collAddressesPartial = true;
}
$collAddresses->getInternalIterator()->rewind();
return $collAddresses;
}
if ($partial && $this->collAddresses) {
foreach ($this->collAddresses as $obj) {
if ($obj->isNew()) {
$collAddresses[] = $obj;
}
}
}
$this->collAddresses = $collAddresses;
$this->collAddressesPartial = false;
}
}
return $this->collAddresses;
}
/**
* Sets a collection of Address 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 $addresses A Propel collection.
* @param ConnectionInterface $con Optional connection object
* @return ChildCountry The current object (for fluent API support)
*/
public function setAddresses(Collection $addresses, ConnectionInterface $con = null)
{
$addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses);
$this->addressesScheduledForDeletion = $addressesToDelete;
foreach ($addressesToDelete as $addressRemoved) {
$addressRemoved->setCountry(null);
}
$this->collAddresses = null;
foreach ($addresses as $address) {
$this->addAddress($address);
}
$this->collAddresses = $addresses;
$this->collAddressesPartial = false;
return $this;
}
/**
* Returns the number of related Address objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param ConnectionInterface $con
* @return int Count of related Address objects.
* @throws PropelException
*/
public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collAddressesPartial && !$this->isNew();
if (null === $this->collAddresses || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collAddresses) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getAddresses());
}
$query = ChildAddressQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCountry($this)
->count($con);
}
return count($this->collAddresses);
}
/**
* Method called to associate a ChildAddress object to this object
* through the ChildAddress foreign key attribute.
*
* @param ChildAddress $l ChildAddress
* @return \Thelia\Model\Country The current object (for fluent API support)
*/
public function addAddress(ChildAddress $l)
{
if ($this->collAddresses === null) {
$this->initAddresses();
$this->collAddressesPartial = true;
}
if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddAddress($l);
}
return $this;
}
/**
* @param Address $address The address object to add.
*/
protected function doAddAddress($address)
{
$this->collAddresses[]= $address;
$address->setCountry($this);
}
/**
* @param Address $address The address object to remove.
* @return ChildCountry The current object (for fluent API support)
*/
public function removeAddress($address)
{
if ($this->getAddresses()->contains($address)) {
$this->collAddresses->remove($this->collAddresses->search($address));
if (null === $this->addressesScheduledForDeletion) {
$this->addressesScheduledForDeletion = clone $this->collAddresses;
$this->addressesScheduledForDeletion->clear();
}
$this->addressesScheduledForDeletion[]= clone $address;
$address->setCountry(null);
}
return $this;
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this Country is new, it will return
* an empty collection; or if this Country has previously
* been saved, it will retrieve related Addresses 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 Country.
*
* @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|ChildAddress[] List of ChildAddress objects
*/
public function getAddressesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAddressQuery::create(null, $criteria);
$query->joinWith('Customer', $joinBehavior);
return $this->getAddresses($query, $con);
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this Country is new, it will return
* an empty collection; or if this Country has previously
* been saved, it will retrieve related Addresses 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 Country.
*
* @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|ChildAddress[] List of ChildAddress objects
*/
public function getAddressesJoinCustomerTitle($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAddressQuery::create(null, $criteria);
$query->joinWith('CustomerTitle', $joinBehavior);
return $this->getAddresses($query, $con);
}
/**
* Clears out the collCountryI18ns collection
*
@@ -1997,6 +2310,11 @@ abstract class Country implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
if ($this->collAddresses) {
foreach ($this->collAddresses as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCountryI18ns) {
foreach ($this->collCountryI18ns as $o) {
$o->clearAllReferences($deep);
@@ -2012,6 +2330,10 @@ abstract class Country implements ActiveRecordInterface
$this->collTaxRuleCountries->clearIterator();
}
$this->collTaxRuleCountries = null;
if ($this->collAddresses instanceof Collection) {
$this->collAddresses->clearIterator();
}
$this->collAddresses = null;
if ($this->collCountryI18ns instanceof Collection) {
$this->collCountryI18ns->clearIterator();
}

View File

@@ -50,6 +50,10 @@ use Thelia\Model\Map\CountryTableMap;
* @method ChildCountryQuery rightJoinTaxRuleCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaxRuleCountry relation
* @method ChildCountryQuery innerJoinTaxRuleCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the TaxRuleCountry relation
*
* @method ChildCountryQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation
* @method ChildCountryQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation
* @method ChildCountryQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation
*
* @method ChildCountryQuery leftJoinCountryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CountryI18n relation
* @method ChildCountryQuery rightJoinCountryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CountryI18n relation
* @method ChildCountryQuery innerJoinCountryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CountryI18n relation
@@ -654,6 +658,79 @@ abstract class CountryQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
}
/**
* Filter the query by a related \Thelia\Model\Address object
*
* @param \Thelia\Model\Address|ObjectCollection $address the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCountryQuery The current query, for fluid interface
*/
public function filterByAddress($address, $comparison = null)
{
if ($address instanceof \Thelia\Model\Address) {
return $this
->addUsingAlias(CountryTableMap::ID, $address->getCountryId(), $comparison);
} elseif ($address instanceof ObjectCollection) {
return $this
->useAddressQuery()
->filterByPrimaryKeys($address->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Address relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCountryQuery The current query, for fluid interface
*/
public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Address');
// 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, 'Address');
}
return $this;
}
/**
* Use the Address relation Address 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\AddressQuery A secondary query class using the current class as primary query
*/
public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAddress($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
}
/**
* Filter the query by a related \Thelia\Model\CountryI18n object
*

View File

@@ -2153,6 +2153,31 @@ abstract class Customer implements ActiveRecordInterface
return $this->getAddresses($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 Addresses 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|ChildAddress[] List of ChildAddress objects
*/
public function getAddressesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAddressQuery::create(null, $criteria);
$query->joinWith('Country', $joinBehavior);
return $this->getAddresses($query, $con);
}
/**
* Clears out the collOrders collection
*

View File

@@ -883,10 +883,9 @@ abstract class CustomerTitle implements ActiveRecordInterface
if ($this->addressesScheduledForDeletion !== null) {
if (!$this->addressesScheduledForDeletion->isEmpty()) {
foreach ($this->addressesScheduledForDeletion as $address) {
// need to save related object because we set the relation to null
$address->save($con);
}
\Thelia\Model\AddressQuery::create()
->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->addressesScheduledForDeletion = null;
}
}
@@ -1777,7 +1776,7 @@ abstract class CustomerTitle implements ActiveRecordInterface
$this->addressesScheduledForDeletion = clone $this->collAddresses;
$this->addressesScheduledForDeletion->clear();
}
$this->addressesScheduledForDeletion[]= $address;
$this->addressesScheduledForDeletion[]= clone $address;
$address->setCustomerTitle(null);
}
@@ -1809,6 +1808,31 @@ abstract class CustomerTitle implements ActiveRecordInterface
return $this->getAddresses($query, $con);
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this CustomerTitle is new, it will return
* an empty collection; or if this CustomerTitle has previously
* been saved, it will retrieve related Addresses 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 CustomerTitle.
*
* @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|ChildAddress[] List of ChildAddress objects
*/
public function getAddressesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildAddressQuery::create(null, $criteria);
$query->joinWith('Country', $joinBehavior);
return $this->getAddresses($query, $con);
}
/**
* Clears out the collCustomerTitleI18ns collection
*

View File

@@ -523,7 +523,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
{
if ($address instanceof \Thelia\Model\Address) {
return $this
->addUsingAlias(CustomerTitleTableMap::ID, $address->getCustomerTitleId(), $comparison);
->addUsingAlias(CustomerTitleTableMap::ID, $address->getTitleId(), $comparison);
} elseif ($address instanceof ObjectCollection) {
return $this
->useAddressQuery()
@@ -542,7 +542,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
*
* @return ChildCustomerTitleQuery The current query, for fluid interface
*/
public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Address');
@@ -577,7 +577,7 @@ abstract class CustomerTitleQuery extends ModelCriteria
*
* @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
*/
public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinAddress($relationAlias, $joinType)

View File

@@ -75,9 +75,9 @@ class AddressTableMap extends TableMap
const ID = 'address.ID';
/**
* the column name for the TITLE field
* the column name for the NAME field
*/
const TITLE = 'address.TITLE';
const NAME = 'address.NAME';
/**
* the column name for the CUSTOMER_ID field
@@ -85,9 +85,9 @@ class AddressTableMap extends TableMap
const CUSTOMER_ID = 'address.CUSTOMER_ID';
/**
* the column name for the CUSTOMER_TITLE_ID field
* the column name for the TITLE_ID field
*/
const CUSTOMER_TITLE_ID = 'address.CUSTOMER_TITLE_ID';
const TITLE_ID = 'address.TITLE_ID';
/**
* the column name for the COMPANY field
@@ -171,11 +171,11 @@ class AddressTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ),
self::TYPE_PHPNAME => array('Id', 'Name', 'CustomerId', 'TitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'name', 'customerId', 'titleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'isDefault', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::NAME, AddressTableMap::CUSTOMER_ID, AddressTableMap::TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CELLPHONE, AddressTableMap::IS_DEFAULT, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'CUSTOMER_ID', 'TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'name', 'customer_id', 'title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'is_default', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
);
@@ -186,11 +186,11 @@ class AddressTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ),
self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'CustomerId' => 2, 'TitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'Cellphone' => 14, 'IsDefault' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'customerId' => 2, 'titleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'cellphone' => 14, 'isDefault' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::NAME => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CELLPHONE => 14, AddressTableMap::IS_DEFAULT => 15, AddressTableMap::CREATED_AT => 16, AddressTableMap::UPDATED_AT => 17, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'CUSTOMER_ID' => 2, 'TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CELLPHONE' => 14, 'IS_DEFAULT' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'customer_id' => 2, 'title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'cellphone' => 14, 'is_default' => 15, 'created_at' => 16, 'updated_at' => 17, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
);
@@ -211,9 +211,9 @@ class AddressTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('NAME', 'Name', 'VARCHAR', false, 255, null);
$this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
$this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
$this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', true, null, null);
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
@@ -222,7 +222,7 @@ class AddressTableMap extends TableMap
$this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', true, 255, null);
$this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
$this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
$this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
$this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null);
$this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
$this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
$this->addColumn('IS_DEFAULT', 'IsDefault', 'TINYINT', false, null, 0);
@@ -236,7 +236,8 @@ class AddressTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CartRelatedByAddressDeliveryId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery_id', ), null, null, 'CartsRelatedByAddressDeliveryId');
$this->addRelation('CartRelatedByAddressInvoiceId', '\\Thelia\\Model\\Cart', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice_id', ), null, null, 'CartsRelatedByAddressInvoiceId');
} // buildRelations()
@@ -393,9 +394,9 @@ class AddressTableMap extends TableMap
{
if (null === $alias) {
$criteria->addSelectColumn(AddressTableMap::ID);
$criteria->addSelectColumn(AddressTableMap::TITLE);
$criteria->addSelectColumn(AddressTableMap::NAME);
$criteria->addSelectColumn(AddressTableMap::CUSTOMER_ID);
$criteria->addSelectColumn(AddressTableMap::CUSTOMER_TITLE_ID);
$criteria->addSelectColumn(AddressTableMap::TITLE_ID);
$criteria->addSelectColumn(AddressTableMap::COMPANY);
$criteria->addSelectColumn(AddressTableMap::FIRSTNAME);
$criteria->addSelectColumn(AddressTableMap::LASTNAME);
@@ -412,9 +413,9 @@ class AddressTableMap extends TableMap
$criteria->addSelectColumn(AddressTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.TITLE');
$criteria->addSelectColumn($alias . '.NAME');
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
$criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
$criteria->addSelectColumn($alias . '.TITLE_ID');
$criteria->addSelectColumn($alias . '.COMPANY');
$criteria->addSelectColumn($alias . '.FIRSTNAME');
$criteria->addSelectColumn($alias . '.LASTNAME');

View File

@@ -180,6 +180,7 @@ class CountryTableMap extends TableMap
{
$this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
$this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
$this->addRelation('CountryI18n', '\\Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns');
} // buildRelations()

View File

@@ -167,7 +167,7 @@ class CustomerTitleTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Customers');
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
$this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
$this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns');
} // buildRelations()