allow to make an address as default on update action

This commit is contained in:
Manuel Raynaud
2013-09-13 10:17:45 +02:00
parent ca7d1f7c85
commit 275b20ac77
9 changed files with 67 additions and 18 deletions

View File

@@ -7,10 +7,24 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\AddressEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Base\Address as BaseAddress;
use Thelia\Model\AddressQuery;
class Address extends BaseAddress {
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
/**
* put the the current address as default one
*/
public function makeItDefault()
{
AddressQuery::create()->filterByCustomerId($this->getCustomerId())
->update(array('isDefault' => '0'));
$this->setIsDefault(1);
$this->save();
}
/**
* Code to be run before inserting to database
* @param ConnectionInterface $con