diff --git a/classes/Address.php b/classes/Address.php index eb1684b57be42..cafa2bcf8dc25 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -113,6 +113,9 @@ class AddressCore extends ObjectModel /** @var array Store if an adress ID exists */ protected static $addressExists = []; + /** @var int old address ID */ + public $id_old_address; + /** * @see ObjectModel::$definition */ @@ -129,6 +132,7 @@ class AddressCore extends ObjectModel 'id_warehouse' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false], 'id_country' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true], 'id_state' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'], + 'id_old_address' => ['type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false], 'alias' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32], 'company' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255], 'lastname' => ['type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255], diff --git a/classes/form/CustomerAddressPersister.php b/classes/form/CustomerAddressPersister.php index d9a908d140f09..abe52ce857175 100644 --- a/classes/form/CustomerAddressPersister.php +++ b/classes/form/CustomerAddressPersister.php @@ -109,6 +109,7 @@ private function updateUsedAddress(Address $address) { $old_address = new Address($address->id); $address->id = $address->id_address = null; + $address->id_old_address = $old_address->id; if ($address->save() && $old_address->delete()) { // a new address was created, we must update current cart diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql index 160e2f60c7ca6..482d19e0d9f09 100644 --- a/install-dev/data/db_structure.sql +++ b/install-dev/data/db_structure.sql @@ -18,6 +18,7 @@ CREATE TABLE `PREFIX_address` ( `id_manufacturer` int(10) unsigned NOT NULL DEFAULT '0', `id_supplier` int(10) unsigned NOT NULL DEFAULT '0', `id_warehouse` int(10) unsigned NOT NULL DEFAULT '0', + `id_old_address` int(10) unsigned NOT NULL DEFAULT '0', `alias` varchar(32) NOT NULL, `company` varchar(255) DEFAULT NULL, `lastname` varchar(255) NOT NULL,