diff --git a/CHANGELOG.md b/CHANGELOG.md index e7bdb567..51c6d184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2017-10-26 v.2.2.7 +* Исправлен баг при работе с одним сайтом + ## 2017-10-25 v.2.2.6 * Доработана система синхронизации оплат * Исправлены ошибки в истории заказов diff --git a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php index 13ec839c..c7a81012 100644 --- a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php +++ b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php @@ -151,16 +151,16 @@ class RetailCrmEvent )); //many sites? - if(!empty($optionsSitesList) && array_key_exists($arOrder['LID'], $optionsSitesList)) { - $site = $optionsSitesList[$arOrder['LID']]; - } else { + if ($optionsSitesList) { + if (array_key_exists($arOrder['LID'], $optionsSitesList) && $optionsSitesList[$arOrder['LID']] !== null) { + $site = $optionsSitesList[$arOrder['LID']]; + } else { + return; + } + } elseif (!$optionsSitesList) { $site = null; } - if ($site == null) { - return; - } - //new order? $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site); if (isset($orderCrm['order'])) { @@ -230,20 +230,20 @@ class RetailCrmEvent $newOrder = Bitrix\Sale\Order::load($arPayment['ORDER_ID']); $arPayment['LID'] = $newOrder->getField('LID'); } catch (Bitrix\Main\ArgumentNullException $e) { - RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $arPayment['ORDER_ID']); + RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $arPayment['ORDER_ID']); return; } - if(!empty($optionsSitesList) && array_key_exists($arPayment['LID'], $optionsSitesList)) { - $site = $optionsSitesList[$arPayment['LID']]; - } else { + if ($optionsSitesList) { + if (array_key_exists($arOrder['LID'], $optionsSitesList) && $optionsSitesList[$arOrder['LID']] !== null) { + $site = $optionsSitesList[$arOrder['LID']]; + } else { + return; + } + } elseif (!$optionsSitesList) { $site = null; } - if ($site == null) { - return; - } - $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); $api = new RetailCrm\ApiClient($api_host, $api_key); @@ -299,7 +299,7 @@ class RetailCrmEvent $paymentToCrm['order']['externalId'] = $arPayment['ORDER_ID']; } } else { - RCrmActions::eventLog('RetailCrmOrder::orderSend', 'payments', 'OrderID = ' . $arFields['ID'] . '. Payment not found.'); + RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'payments', 'OrderID = ' . $arPayment['ID'] . '. Payment not found.'); } if (!array_key_exists($arPayment['ID'], $paymentsExternalIds)) { @@ -339,7 +339,7 @@ class RetailCrmEvent $newOrder = Bitrix\Sale\Order::load($arPayment['ORDER_ID']); $arPayment['LID'] = $newOrder->getField('LID'); } catch (Bitrix\Main\ArgumentNullException $e) { - RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $arPayment['ORDER_ID']); + RCrmActions::eventLog('RetailCrmEvent::paymentDelete', 'Bitrix\Sale\Order::load', $e->getMessage() . ': ' . $arPayment['ORDER_ID']); return; } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index f4a32122..2d807217 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1,2 +1 @@ -- Доработана система синхронизации оплат -- Исправлены ошибки в истории заказов \ No newline at end of file +- Исправлен баг при работе с одним сайтом \ No newline at end of file diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index db336d7b..2f86137f 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -335,6 +335,7 @@ class intaro_retailcrm extends CModule $this->RETAIL_CRM_API = new \RetailCrm\ApiClient($api_host, $api_key); 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(array())); } //prepare crm lists diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 3f805cfc..912acfec 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,5 +1,5 @@ "2.2.6", - "VERSION_DATE" => "2017-09-25 12:00:00" + "VERSION" => "2.2.7", + "VERSION_DATE" => "2017-09-25 14:50:00" ); diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index 70947978..12b0ee63 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -195,7 +195,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { //bitrix site list $siteListArr = array(); foreach ($arResult['arSites'] as $arSites) { - $siteListArr[$arSites['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $arSites['LID']])); + if (count($arResult['arSites']) > 1) { + if ($_POST['sites-id-' . $arSites['LID']]) { + $siteListArr[$arSites['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $arSites['LID']])); + } else { + $siteListArr[$arSites['LID']] = null; + } + } } if ($api_host && $api_key) { @@ -463,7 +469,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { } } - COption::SetOptionString($mid, $CRM_SITES_LIST, serialize(RCrmActions::clearArr($siteListArr))); + COption::SetOptionString($mid, $CRM_SITES_LIST, serialize($siteListArr)); COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize(RCrmActions::clearArr($orderTypesArr))); COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize(RCrmActions::clearArr($deliveryTypesArr))); COption::SetOptionString($mid, $CRM_PAYMENT_TYPES, serialize(RCrmActions::clearArr($paymentTypesArr)));