diff --git a/classes/Address.php b/classes/Address.php index c8051e0a5..3e1f6ed38 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -163,6 +163,9 @@ class AddressCore extends ObjectModel $this->country = Country::getNameById($id_lang ? $id_lang : Configuration::get('PS_LANG_DEFAULT'), $this->id_country); } + /** + * @see ObjectModel::add() + */ public function add($autodate = true, $null_values = false) { if (!parent::add($autodate, $null_values)) @@ -173,6 +176,9 @@ class AddressCore extends ObjectModel return true; } + /** + * @see ObjectModel::delete() + */ public function delete() { if (Validate::isUnsignedId($this->id_customer)) @@ -200,6 +206,9 @@ class AddressCore extends ObjectModel return $out; } + /** + * @see ObjectModel::validateController() + */ public function validateController($htmlentities = true) { $errors = parent::validateController($htmlentities); @@ -296,7 +305,7 @@ class AddressCore extends ObjectModel { if (!$id_customer) return false; - + return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_address` FROM `'._DB_PREFIX_.'address` diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php index 8ca974f31..5ca5475a1 100644 --- a/controllers/admin/AdminSuppliersController.php +++ b/controllers/admin/AdminSuppliersController.php @@ -407,10 +407,28 @@ class AdminSuppliersControllerCore extends AdminController $address = new Address($object->id_address); if (Validate::isLoadedObject($address)) { - $address->id_supplier = $object->id_address; + $address->id_supplier = $object->id; $address->save(); } return true; + + } + + /** + * @see AdminController::afterUpdate() + */ + public function afterUpdate($object) + { + $address = new Address($object->id_address); + if (Validate::isLoadedObject($address)) + { + if ($address->id_supplier != $object->id) + { + $address->id_supplier = $object->id; + $address->save(); + } + } + return true; } }