diff --git a/src/upload/admin/model/extension/retailcrm/history.php b/src/upload/admin/model/extension/retailcrm/history.php index a6bb026..f1a3083 100644 --- a/src/upload/admin/model/extension/retailcrm/history.php +++ b/src/upload/admin/model/extension/retailcrm/history.php @@ -315,10 +315,17 @@ class ModelExtensionRetailcrmHistory extends Model { $this->customers_history->handleCustomer($customer_data, $customer); $this->customers_history->handleCustomFields($customer_data, $customer); - $updateAddress = $this->customers_history->handleAddress($customer, array(), $customer_data['address_id']); - $addresses = $this->model_customer_customer->getAddresses($customer_id); - $addresses[$customer_data['address_id']] = $updateAddress; - $customer_data['address'] = $addresses; + if (empty($customer_data['address_id'])) { + $address = $this->customers_history->handleAddress($customer, array()); + $addresses = $this->model_customer_customer->getAddresses($customer_id); + $addresses[] = $address; + $customer_data['address'] = $addresses; + } else { + $updateAddress = $this->customers_history->handleAddress($customer, array(), $customer_data['address_id']); + $addresses = $this->model_customer_customer->getAddresses($customer_id); + $addresses[$customer_data['address_id']] = $updateAddress; + $customer_data['address'] = $addresses; + } $this->model_customer_customer->editCustomer($customer_id, $customer_data); } diff --git a/src/upload/system/library/retailcrm/lib/history/Customer.php b/src/upload/system/library/retailcrm/lib/history/Customer.php index 676e0ec..c6c786f 100644 --- a/src/upload/system/library/retailcrm/lib/history/Customer.php +++ b/src/upload/system/library/retailcrm/lib/history/Customer.php @@ -53,7 +53,9 @@ class Customer { if ($address_id) { $customer_address = $this->customer_repository->getAddress($address_id); } else { - $customer_address = array(); + $customer_address = array( + 'address_id' => '' + ); } if (isset($customer['address']['countryIso'])) {