diff --git a/CHANGELOG.md b/CHANGELOG.md index a345c860..d58c0b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-09-02 v.6.5.27 +- Исправлена передача изменений по клиентам, отсутствующим в Bitrix + ## 2024-08-26 v.6.5.26 - Исправлено удаление модуля diff --git a/intaro.retailcrm/classes/general/CustomerBuilder.php b/intaro.retailcrm/classes/general/CustomerBuilder.php index e5a38f3b..cbc9ec47 100644 --- a/intaro.retailcrm/classes/general/CustomerBuilder.php +++ b/intaro.retailcrm/classes/general/CustomerBuilder.php @@ -221,6 +221,36 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa $this->customer->setSubscribe('N'); } } + + if (empty($this->dataCrm['externalId']) + && (empty($this->dataCrm['firstName']) + || empty($this->dataCrm['email'])) + ) { + $api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey()); + $customerResponse = RCrmActions::apiMethod($api, 'customersGetById', __METHOD__, $this->dataCrm['id']); + + if ($customerResponse instanceof RetailCrm\Response\ApiResponse + && $customerResponse->isSuccessful() + && !empty($customerResponse['customer']) + ) { + $crmCustomer = $customerResponse['customer']; + + if (empty($this->dataCrm['email']) + && !empty($crmCustomer['email']) + ) { + $email = $crmCustomer['email']; + + $this->customer->setEmail($this->fromJSON($email)); + $this->customer->setLogin($email); + } + + if (empty($this->dataCrm['firstName']) + && !empty($crmCustomer['firstName']) + ) { + $this->customer->setName($this->fromJSON($crmCustomer['firstName'])); + } + } + } } public function buildPassword() diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 959a8696..1c768582 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлено удаление модуля +- Исправлена передача изменений по клиентам, отсутствующим в Bitrix diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index e61759e1..fc91b9aa 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.26', - 'VERSION_DATE' => '2024-08-26 17:30:00' + 'VERSION' => '6.5.27', + 'VERSION_DATE' => '2024-09-02 10:00:00' ];