diff --git a/CHANGELOG.md b/CHANGELOG.md index 95d89858..cc47e86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-10-22 v6.5.35 +- Исправлена подписка модуля на событие сохранения заказа + ## 2024-10-21 v6.5.34 - Исправлена ошибка агента выгрузки изменений при наличии у заказа клиента без магазина diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 7f8c92f2..0f5d5e40 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 59d7adea..12a4c52d 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -1090,6 +1090,7 @@ class intaro_retailcrm extends CModule RegisterModuleDependences('sale', 'OnSalePaymentEntityDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'paymentDelete'); RegisterModuleDependences('main', 'OnAfterUserRegister', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserRegister'); RegisterModuleDependences('main', 'OnAfterUserAdd', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserAdd'); + RegisterModuleDependences('sale', 'OnSaleOrderSaved', $this->MODULE_ID, 'RetailCrmEvent', 'orderSave', 99); COption::SetOptionString($this->MODULE_ID, Constants::CRM_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types']))); COption::SetOptionString($this->MODULE_ID, Constants::CRM_INVENTORIES_UPLOAD, 'N'); diff --git a/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php b/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php index 83512e01..b764b243 100644 --- a/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php +++ b/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php @@ -228,7 +228,7 @@ class LoyaltyInstaller $eventManager->unRegisterEventHandler( $event['FROM_MODULE'], $event['EVENT_NAME'], - $this->MODULE_ID, + Constants::MODULE_ID, EventsHandlers::class, $event['EVENT_NAME'].'Handler' ); diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 6011b85c..4156a051 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -18,7 +18,7 @@ namespace Intaro\RetailCrm\Component; */ class Constants { - public const MODULE_VERSION = '6.5.34'; + public const MODULE_VERSION = '6.5.35'; public const CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; public const CRM_USERS_MAP = 'crm_users_map'; diff --git a/intaro.retailcrm/lib/component/handlers/eventshandlers.php b/intaro.retailcrm/lib/component/handlers/eventshandlers.php index 7e686c3e..f084b75f 100644 --- a/intaro.retailcrm/lib/component/handlers/eventshandlers.php +++ b/intaro.retailcrm/lib/component/handlers/eventshandlers.php @@ -132,9 +132,6 @@ class EventsHandlers try { /** @var Order $order */ $order = $event->getParameter('ENTITY'); - - $saveResult = RetailCrmEvent::orderSave($order); - Utils::handleApiErrors($saveResult); $isBonusInput = ( !empty($_POST['bonus-input']) diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index a98f60ae..1aed6ded 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -612,6 +612,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { ConfigProvider::setLoyaltyProgramStatus('Y'); } else { ConfigProvider::setLoyaltyProgramStatus('N'); + $loyaltyEventClass = 'Intaro\RetailCrm\Component\Handlers\EventsHandlers'; + UnRegisterModuleDependences('sale', 'OnSaleOrderSaved', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleOrderSavedHandler'); + UnRegisterModuleDependences('sale', 'OnSaleComponentOrderResultPrepared', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleComponentOrderResultPreparedHandler'); } try { diff --git a/intaro.retailcrm/updater.php b/intaro.retailcrm/updater.php index 77382528..1bb1eadb 100644 --- a/intaro.retailcrm/updater.php +++ b/intaro.retailcrm/updater.php @@ -5,6 +5,7 @@ use Bitrix\Main; use Bitrix\Main\Context; use Bitrix\Main\EventManager; use Bitrix\Main\Loader; +use Bitrix\Main\Config\Option; use Bitrix\Main\Localization\Loc; use Bitrix\Main\ORM\Fields\DatetimeField; use Bitrix\Main\ORM\Fields\IntegerField; @@ -60,7 +61,8 @@ class ToModuleTable extends Main\Entity\DataManager return [ new IntegerField( 'id', - ['primary' => true, 'autocomplete' => true]), + ['primary' => true, 'autocomplete' => true] + ), new DatetimeField('TIMESTAMP_X', ['required' => true]), new IntegerField('sort'), new StringField( @@ -676,9 +678,9 @@ class LoyaltyProgramUpdater public function getGroupIdByPersonId($personId): ?int { $lpOrderGroupName = [ - 'ru' => 'Программа лояльности', - 'en' => 'Loyalty Program' - ][Context::getCurrent()->getLanguage()] ?? 'Программа лояльности'; + 'ru' => 'Программа лояльности', + 'en' => 'Loyalty Program' + ][Context::getCurrent()->getLanguage()] ?? 'Программа лояльности'; try { $lpGroup = OrderPropsGroupTable::query() @@ -925,8 +927,7 @@ class LoyaltyProgramUpdater 'DESCRIPTION' => $lpBonusInfo, ]; - while ($bonusProp = $bonusProps->Fetch()) - { + while ($bonusProp = $bonusProps->Fetch()) { CSaleOrderProps::Update($bonusProp['ID'], $updateInfo); } @@ -1104,15 +1105,13 @@ class UpdateSubscribe foreach ($templateNames as $directory => $templates) { foreach ($templates as $template) { $templatePath = $_SERVER['DOCUMENT_ROOT'] - . '/local/templates/.default/components/bitrix/' . $template['name'] . '/' . $directory - ; + . '/local/templates/.default/components/bitrix/' . $template['name'] . '/' . $directory; if (!file_exists($templatePath)) { $pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' . $template['name'] - . '/templates/' . $template['templateDirectory'] - ; + . '/templates/' . $template['templateDirectory']; CopyDirFiles( $pathFrom, @@ -1180,8 +1179,15 @@ function update() { Loader::includeModule('sale'); Loader::includeModule('highloadblock'); + $loyaltyEventClass = 'Intaro\RetailCrm\Component\Handlers\EventsHandlers'; COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5'); + RegisterModuleDependences('sale', 'OnSaleOrderSaved', 'intaro.retailcrm', 'RetailCrmEvent', 'orderSave', 99); + + if (Option::get('intaro.retailcrm', 'loyalty_program_toggle') !== 'Y') { + UnRegisterModuleDependences('sale', 'OnSaleOrderSaved', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleOrderSavedHandler'); + UnRegisterModuleDependences('sale', 'OnSaleComponentOrderResultPrepared', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleComponentOrderResultPreparedHandler'); + } } function createCustomPropertyFile()