allow to make an address as default on update action
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user