CCrmProduct::handlerAfterProductUpdate

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmProduct
  4. handlerAfterProductUpdate
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product.php
  • Класс: \CCrmProduct
  • Вызов: CCrmProduct::handlerAfterProductUpdate
static function handlerAfterProductUpdate(Main\Event $event): void
{
	if (!isset(self::$catalogIncluded))
	{
		self::$catalogIncluded = Loader::includeModule('catalog');
	}

	$id = $event->getParameter('id');
	$fields = $event->getParameter('fields');

	if (isset($fields['ID']))
	{
		unset($fields['ID']);
	}

	$datetimeFields = [
		'TIMESTAMP_X',
		'DATE_CREATE',
		'ACTIVE_FROM',
		'ACTIVE_TO',
	];
	foreach ($datetimeFields as $fieldName)
	{
		if (isset($fields[$fieldName]) && $fields[$fieldName] instanceof Main\Type\DateTime)
		{
			$fields[$fieldName] = $fields[$fieldName]->toString();
		}
	}
	unset($fieldName);
	if (isset($fields['PRICES']))
	{
		$crmPriceType = self::getSelectedPriceTypeId();
		if (self::$catalogIncluded && is_array($fields['PRICES']))
		{
			foreach ($fields['PRICES'] as $price)
			{
				if (isset($price['CATALOG_GROUP_ID']) && $price['CATALOG_GROUP_ID'] == $crmPriceType)
				{
					$fields['PRICE'] = $price['PRICE'];
					$fields['CURRENCY'] = $price['CURRENCY'];
					break;
				}
			}
			unset($price);
		}
		unset($fields['PRICES']);
	}

	foreach (GetModuleEvents('crm', self::EVENT_ON_AFTER_UPDATE, true) as $crmEvent)
	{
		ExecuteModuleEventEx($crmEvent, [$id, $fields]);
	}
	unset($crmEvent);
	unset($fields, $id);
}

Добавить комментарий