From e28ce27b8953576559f93bd924de96fdbc1a39bd Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 18 Apr 2019 09:43:44 +0300 Subject: [PATCH] Fixed bug with incorrect value of delivery service received by order history --- .../classes/general/history/RetailCrmHistory_v5.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 2e7265cc..9e2d7745 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -994,10 +994,15 @@ class RetailCrmHistory if (isset($orderCrm['delivery']['service']['code'])) { $deliveryCode = \Bitrix\Sale\Delivery\Services\Manager::getCodeById($deliveryId); - + $serviceCode = $orderCrm['delivery']['service']['code']; + $services = \Bitrix\Sale\Delivery\Services\Manager::getService($deliveryId)->getProfilesList(); + if (!array_key_exists($serviceCode, $services)) { + $serviceCode = strtoupper($serviceCode); + $serviceCode = str_replace(array('-'), "_", $serviceCode); + } if ($deliveryCode) { try { - $deliveryService = \Bitrix\Sale\Delivery\Services\Manager::getObjectByCode($deliveryCode . ':' . $orderCrm['delivery']['service']['code']); + $deliveryService = \Bitrix\Sale\Delivery\Services\Manager::getObjectByCode($deliveryCode . ':' . $serviceCode); } catch (Bitrix\Main\SystemException $systemException) { RCrmActions::eventLog('RetailCrmHistory::deliveryEdit', '\Bitrix\Sale\Delivery\Services\Manager::getObjectByCode', $systemException->getMessage()); }