diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d226b1..52b9cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v.3.0.5 +* Исправлены ошибки в шаблоне twig +* Добавлена обработка истории изменений при сохранении настроек для установки текущего sinceId, если история в retailCRM пустая + ## v.3.0.4 * Добавлена проверка группы пользователя в заказе при редактировании * Добавлена передача скидки по бонусным баллам diff --git a/VERSION b/VERSION index b38ebbf..7da3c16 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.4 \ No newline at end of file +3.0.5 \ No newline at end of file diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index b6e08aa..60d4a20 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -150,7 +150,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $ordersHistory = $api->ordersHistory(); - if ($ordersHistory->isSuccessful()) { + if ($ordersHistory->isSuccessful() && !empty($ordersHistory['history'])) { $ordersHistory = $api->ordersHistory(array(), $ordersHistory['pagination']['totalPageCount']); if ($ordersHistory->isSuccessful()) { @@ -163,7 +163,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $customersHistory = $api->customersHistory(); - if ($customersHistory->isSuccessful()) { + if ($customersHistory->isSuccessful() && !empty($customersHistory['history'])) { $customersHistory = $api->customersHistory(array(), $customersHistory['pagination']['totalPageCount']); if ($customersHistory->isSuccessful()) { @@ -176,9 +176,9 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->model_setting_setting->editSetting( 'retailcrm_history', array( - 'retailcrm_history_orders' => $sinceIdOrders, - 'retailcrm_history_customers' => $sinceIdCustomers, - 'retailcrm_history_datetime' => $generatedAt + 'retailcrm_history_orders' => isset($sinceIdOrders) ? $sinceIdOrders : 1, + 'retailcrm_history_customers' => isset($sinceIdCustomers) ? $sinceIdCustomers : 1, + 'retailcrm_history_datetime' => isset($generatedAt) ? $generatedAt : date('Y-m-d H:i:s') ) ); } diff --git a/src/upload/admin/model/extension/retailcrm/order.php b/src/upload/admin/model/extension/retailcrm/order.php index 178b9f1..be872cc 100644 --- a/src/upload/admin/model/extension/retailcrm/order.php +++ b/src/upload/admin/model/extension/retailcrm/order.php @@ -115,6 +115,10 @@ class ModelExtensionRetailcrmOrder extends Model { } } + if (!empty($order_data['payment_iso_code_2'])) { + $order['countryIso'] = $order_data['payment_iso_code_2']; + } + $order['number'] = $order_data['order_id']; $order['externalId'] = $order_data['order_id']; $order['firstName'] = $order_data['firstname']; @@ -151,6 +155,7 @@ class ModelExtensionRetailcrmOrder extends Model { 'code' => isset($delivery_code) ? $delivery_code : '', 'cost' => $deliveryCost, 'address' => array( + 'countryIso' => $order_data['shipping_iso_code_2'], 'index' => $order_data['shipping_postcode'], 'city' => $order_data['shipping_city'], 'region' => $order_data['shipping_zone'], diff --git a/src/upload/admin/view/template/extension/module/retailcrm.twig b/src/upload/admin/view/template/extension/module/retailcrm.twig index 8aa941d..41c9735 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.twig +++ b/src/upload/admin/view/template/extension/module/retailcrm.twig @@ -97,16 +97,16 @@ - {% if saved_settings.retailcrm_apiversion is defined and saved_settings.retailcrm_apiversion != 'v3' %} + {% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %}