From d9cdfced49e996c1ba4d7d4b6a43adb31add35e7 Mon Sep 17 00:00:00 2001 From: Kocmonavtik <61938582+Kocmonavtik@users.noreply.github.com> Date: Mon, 15 Jan 2024 12:27:40 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#92570=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D0=B2=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=BF=D1=80=D0=B8=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B5=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D1=83=D0=BB=D1=8F=20(#333)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/index.php | 32 +++++++++++++++++++-- intaro.retailcrm/install/version.php | 4 +-- intaro.retailcrm/lang/en/install/step1.php | 3 +- intaro.retailcrm/lang/en/install/step11.php | 1 + intaro.retailcrm/lang/ru/install/step1.php | 2 ++ intaro.retailcrm/lang/ru/install/step11.php | 1 + 8 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d12bad2f..610946ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-01-09 v.6.5.5 +- Исправлен вывод справочников при установке модуля + ## 2023-12-29 v.6.5.4 - Исправлена передача адреса доставки diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 9031eea9..2eda76f6 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена передача адреса доставки +- Исправлен вывод справочников при установке модуля diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index 2b5f2652..808b006a 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -89,6 +89,7 @@ class intaro_retailcrm extends CModule public $CLIENT_ID = 'client_id'; public $PROTOCOL = 'protocol'; public $INSTALL_PATH; + public $SITES_AVAILABLE = 'sites_available'; public function __construct() { @@ -376,15 +377,21 @@ class intaro_retailcrm extends CModule if (count($arResult['arSites']) > 1) { $api_host = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, 0); $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0); + $isEmptySites = true; foreach ($arResult['arSites'] as $site) { $siteCode[$site['LID']] = null; if ($_POST['sites-id-' . $site['LID']] && !empty($_POST['sites-id-' . $site['LID']])) { $siteCode[$site['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $site['LID']])); + $isEmptySites = false; } } + if ($isEmptySites) { + $arResult['errCode'] = 'ERR_EMPTY_SITES_LIST'; + } + $arResult['arCurrencySites'] = RCrmActions::getCurrencySites(); $result = $this->getReferenceShops($api_host, $api_key); @@ -397,9 +404,11 @@ class intaro_retailcrm extends CModule foreach ($arResult['arSites'] as $bitrixSite) { $LID = $bitrixSite['LID'] ?? null; $cmsCurrency = $arResult['arCurrencySites'][$LID] ?? null; - $crmCurrency = $arResult['sitesList'][$siteCode[$LID]]['currency'] ?? null; - $arResult['errCode'] = CurrencyService::validateCurrency($cmsCurrency, $crmCurrency); + if (isset($arResult['sitesList'][$siteCode[$LID]])) { + $crmCurrency = $arResult['sitesList'][$siteCode[$LID]]['currency'] ?? null; + $arResult['errCode'] = CurrencyService::validateCurrency($cmsCurrency, $crmCurrency); + } } if (count($arResult['arSites']) != count($siteCode)) { @@ -453,6 +462,25 @@ class intaro_retailcrm extends CModule COption::SetOptionString($this->MODULE_ID, $this->CRM_API_HOST_OPTION, $api_host); COption::SetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, $api_key); COption::SetOptionString($this->MODULE_ID, $this->CRM_SITES_LIST, serialize([])); + + try { + $credentials = $this->RETAIL_CRM_API->getCredentials(); + + COption::SetOptionString( + $this->MODULE_ID, + $this->SITES_AVAILABLE, + $credentials->sitesAvailable[0] ?? '' + ); + } catch (ArgumentOutOfRangeException | CurlException $exception) { + $arResult['errCode'] = 'ERR_GET_SITE_CRM'; + + $APPLICATION->IncludeAdminFile( + GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step1.php' + ); + + return false; + } + } try { diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 46d0e9a8..738c8b50 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.4', - 'VERSION_DATE' => '2023-12-29 15:00:00' + 'VERSION' => '6.5.5', + 'VERSION_DATE' => '2024-01-09 15:30:00' ]; diff --git a/intaro.retailcrm/lang/en/install/step1.php b/intaro.retailcrm/lang/en/install/step1.php index 296cbc53..7aaf9532 100644 --- a/intaro.retailcrm/lang/en/install/step1.php +++ b/intaro.retailcrm/lang/en/install/step1.php @@ -11,7 +11,8 @@ $MESS ['ERR_403'] = 'Wrong apiKey.'; $MESS ['ERR_0'] = 'Server connection timeout error.'; $MESS ['ERR_FIELDS_API_HOST'] = 'Fields are filled incorrectly.'; $MESS ['ERR_METHOD_NOT_FOUND'] = 'Check availability of API methods for current key.'; -//$MESS ['URL_NOT_FOUND'] = 'One or more sites have empty "server URL" field.'; +$MESS ['ERR_EMPTY_SITES_LIST'] = 'At least 1 store must be matched'; +$MESS ['ERR_GET_SITE_CRM'] = 'Failed to retrieve CRM store'; $MESS ['INFO_1'] = 'Enter the address of RetailCRM instance (for example, https://demo.retailcrm.ru) and API key.'; $MESS ['INFO_2'] = 'API key can be generated when the store is registered in RetailCRM (Administration > Integration).'; $MESS ['INFO_3'] = 'Store code in 1C-Bitrix must correspond with the store code in RetailCRM (Administration > Stores).'; diff --git a/intaro.retailcrm/lang/en/install/step11.php b/intaro.retailcrm/lang/en/install/step11.php index cdfaec77..03454375 100644 --- a/intaro.retailcrm/lang/en/install/step11.php +++ b/intaro.retailcrm/lang/en/install/step11.php @@ -8,6 +8,7 @@ $MESS ['ERR_6'] = 'CRM address may be incorrect.'; $MESS ['ERR_403'] = 'Wrong apiKey.'; $MESS ['ERR_0'] = 'Server connection timeout error.'; $MESS ['ERR_FIELDS_API_HOST'] = 'Fields are filled incorrectly.'; +$MESS ['ERR_EMPTY_SITES_LIST'] = 'At least 1 store must be matched'; $MESS ['INFO_1'] = 'Set the correspondence between 1C-Bitrix and RetailCRM stores.'; $MESS ['INFO_2'] = 'All your stores in RetailCRM must have a common API key!'; $MESS ['ERR_CURRENCY_SITES'] = 'The currency of the site differs from the currency of the store in CRM. diff --git a/intaro.retailcrm/lang/ru/install/step1.php b/intaro.retailcrm/lang/ru/install/step1.php index c7256822..d4a70c97 100644 --- a/intaro.retailcrm/lang/ru/install/step1.php +++ b/intaro.retailcrm/lang/ru/install/step1.php @@ -11,12 +11,14 @@ $MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; $MESS ['ERR_FIELDS_API_HOST'] = 'Неверно заполнены поля.'; $MESS ['ERR_METHOD_NOT_FOUND'] = 'Проверьте доступность методов API по текущему ключу.'; +$MESS ['ERR_EMPTY_SITES_LIST'] = 'Необходимо соотнести по крайней мере 1 магазин'; $MESS ['ERR_COUNT_SITES'] = 'Введенный вами API Ключ относится более чем к одному магазину. Измените настройки доступа для API ключа, он должен работать только с одним магазином в CRM'; $MESS ['ERR_CURRENCY_SITES'] = 'Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать'; $MESS ['ERR_CMS_CURRENCY'] = 'Не удалось получить валюту сайта Bitrix'; $MESS ['ERR_CRM_CURRENCY'] = 'Не удалось получить валюту магазина CRM'; +$MESS ['ERR_GET_SITE_CRM'] = 'Не удалось получить магазин CRM'; $MESS ['INFO_1'] = 'Введите адрес экземпляра RetailCRM (например, https://demo.retailcrm.ru) и API-ключ.'; $MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в RetailCRM (Администрирование > Интеграция).'; $MESS ['INFO_3'] = 'Код сайта в 1С-Битрикс должен совпадать с кодом сайта в RetailCRM (Администрирование > Магазины).'; diff --git a/intaro.retailcrm/lang/ru/install/step11.php b/intaro.retailcrm/lang/ru/install/step11.php index 67d296cf..00972df6 100644 --- a/intaro.retailcrm/lang/ru/install/step11.php +++ b/intaro.retailcrm/lang/ru/install/step11.php @@ -8,6 +8,7 @@ $MESS ['ERR_6'] = 'Возможно неверно введен адрес Retai $MESS ['ERR_403'] = 'Неверный apiKey.'; $MESS ['ERR_0'] = 'Превышено время ожидания ответа от сервера.'; $MESS ['ERR_FIELDS_API_HOST'] = 'Неверно заполнены поля.'; +$MESS ['ERR_EMPTY_SITES_LIST'] = 'Необходимо соотнести по крайней мере 1 магазин'; $MESS ['INFO_1'] = 'Задайте соответствия между Вашими магазинами в 1С-Битрикс и RetailCRM.'; $MESS ['INFO_2'] = 'У всех Ваших магазинов в RetailCRM должен быть общий API-ключ!'; $MESS ['ERR_CURRENCY_SITES'] = 'Валюта сайта отличается от валюты магазина в CRM.