1
0
mirror of synced 2024-11-21 21:06:09 +03:00

Исправлена подписка на событие сохранения заказа (#368)

This commit is contained in:
ellynoize 2024-10-23 17:05:39 +03:00 committed by GitHub
parent 7e260a2d22
commit 534757e6c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 16 deletions

View File

@ -1,3 +1,6 @@
## 2024-10-22 v6.5.35
- Исправлена подписка модуля на событие сохранения заказа
## 2024-10-21 v6.5.34 ## 2024-10-21 v6.5.34
- Исправлена ошибка агента выгрузки изменений при наличии у заказа клиента без магазина - Исправлена ошибка агента выгрузки изменений при наличии у заказа клиента без магазина

View File

@ -1 +1 @@
- Исправлена ошибка агента выгрузки изменений при наличии у заказа клиента без магазина - Исправлена подписка модуля на событие сохранения заказа

View File

@ -1090,6 +1090,7 @@ class intaro_retailcrm extends CModule
RegisterModuleDependences('sale', 'OnSalePaymentEntityDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'paymentDelete'); RegisterModuleDependences('sale', 'OnSalePaymentEntityDeleted', $this->MODULE_ID, 'RetailCrmEvent', 'paymentDelete');
RegisterModuleDependences('main', 'OnAfterUserRegister', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserRegister'); RegisterModuleDependences('main', 'OnAfterUserRegister', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserRegister');
RegisterModuleDependences('main', 'OnAfterUserAdd', $this->MODULE_ID, 'RetailCrmEvent', 'OnAfterUserAdd'); 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_CATALOG_BASE_PRICE, htmlspecialchars(trim($_POST['price-types'])));
COption::SetOptionString($this->MODULE_ID, Constants::CRM_INVENTORIES_UPLOAD, 'N'); COption::SetOptionString($this->MODULE_ID, Constants::CRM_INVENTORIES_UPLOAD, 'N');

View File

@ -228,7 +228,7 @@ class LoyaltyInstaller
$eventManager->unRegisterEventHandler( $eventManager->unRegisterEventHandler(
$event['FROM_MODULE'], $event['FROM_MODULE'],
$event['EVENT_NAME'], $event['EVENT_NAME'],
$this->MODULE_ID, Constants::MODULE_ID,
EventsHandlers::class, EventsHandlers::class,
$event['EVENT_NAME'].'Handler' $event['EVENT_NAME'].'Handler'
); );

View File

@ -18,7 +18,7 @@ namespace Intaro\RetailCrm\Component;
*/ */
class Constants 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 CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null';
public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-';
public const CRM_USERS_MAP = 'crm_users_map'; public const CRM_USERS_MAP = 'crm_users_map';

View File

@ -132,9 +132,6 @@ class EventsHandlers
try { try {
/** @var Order $order */ /** @var Order $order */
$order = $event->getParameter('ENTITY'); $order = $event->getParameter('ENTITY');
$saveResult = RetailCrmEvent::orderSave($order);
Utils::handleApiErrors($saveResult);
$isBonusInput = ( $isBonusInput = (
!empty($_POST['bonus-input']) !empty($_POST['bonus-input'])

View File

@ -612,6 +612,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
ConfigProvider::setLoyaltyProgramStatus('Y'); ConfigProvider::setLoyaltyProgramStatus('Y');
} else { } else {
ConfigProvider::setLoyaltyProgramStatus('N'); ConfigProvider::setLoyaltyProgramStatus('N');
$loyaltyEventClass = 'Intaro\RetailCrm\Component\Handlers\EventsHandlers';
UnRegisterModuleDependences('sale', 'OnSaleOrderSaved', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleOrderSavedHandler');
UnRegisterModuleDependences('sale', 'OnSaleComponentOrderResultPrepared', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleComponentOrderResultPreparedHandler');
} }
try { try {

View File

@ -5,6 +5,7 @@ use Bitrix\Main;
use Bitrix\Main\Context; use Bitrix\Main\Context;
use Bitrix\Main\EventManager; use Bitrix\Main\EventManager;
use Bitrix\Main\Loader; use Bitrix\Main\Loader;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Localization\Loc; use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ORM\Fields\DatetimeField; use Bitrix\Main\ORM\Fields\DatetimeField;
use Bitrix\Main\ORM\Fields\IntegerField; use Bitrix\Main\ORM\Fields\IntegerField;
@ -60,7 +61,8 @@ class ToModuleTable extends Main\Entity\DataManager
return [ return [
new IntegerField( new IntegerField(
'id', 'id',
['primary' => true, 'autocomplete' => true]), ['primary' => true, 'autocomplete' => true]
),
new DatetimeField('TIMESTAMP_X', ['required' => true]), new DatetimeField('TIMESTAMP_X', ['required' => true]),
new IntegerField('sort'), new IntegerField('sort'),
new StringField( new StringField(
@ -676,9 +678,9 @@ class LoyaltyProgramUpdater
public function getGroupIdByPersonId($personId): ?int public function getGroupIdByPersonId($personId): ?int
{ {
$lpOrderGroupName = [ $lpOrderGroupName = [
'ru' => 'Программа лояльности', 'ru' => 'Программа лояльности',
'en' => 'Loyalty Program' 'en' => 'Loyalty Program'
][Context::getCurrent()->getLanguage()] ?? 'Программа лояльности'; ][Context::getCurrent()->getLanguage()] ?? 'Программа лояльности';
try { try {
$lpGroup = OrderPropsGroupTable::query() $lpGroup = OrderPropsGroupTable::query()
@ -925,8 +927,7 @@ class LoyaltyProgramUpdater
'DESCRIPTION' => $lpBonusInfo, 'DESCRIPTION' => $lpBonusInfo,
]; ];
while ($bonusProp = $bonusProps->Fetch()) while ($bonusProp = $bonusProps->Fetch()) {
{
CSaleOrderProps::Update($bonusProp['ID'], $updateInfo); CSaleOrderProps::Update($bonusProp['ID'], $updateInfo);
} }
@ -1104,15 +1105,13 @@ class UpdateSubscribe
foreach ($templateNames as $directory => $templates) { foreach ($templateNames as $directory => $templates) {
foreach ($templates as $template) { foreach ($templates as $template) {
$templatePath = $_SERVER['DOCUMENT_ROOT'] $templatePath = $_SERVER['DOCUMENT_ROOT']
. '/local/templates/.default/components/bitrix/' . $template['name'] . '/' . $directory . '/local/templates/.default/components/bitrix/' . $template['name'] . '/' . $directory;
;
if (!file_exists($templatePath)) { if (!file_exists($templatePath)) {
$pathFrom = $_SERVER['DOCUMENT_ROOT'] $pathFrom = $_SERVER['DOCUMENT_ROOT']
. '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/'
. $template['name'] . $template['name']
. '/templates/' . $template['templateDirectory'] . '/templates/' . $template['templateDirectory'];
;
CopyDirFiles( CopyDirFiles(
$pathFrom, $pathFrom,
@ -1180,8 +1179,15 @@ function update()
{ {
Loader::includeModule('sale'); Loader::includeModule('sale');
Loader::includeModule('highloadblock'); Loader::includeModule('highloadblock');
$loyaltyEventClass = 'Intaro\RetailCrm\Component\Handlers\EventsHandlers';
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5'); 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() function createCustomPropertyFile()