• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/compatible/eventcompatibility.php
  • Класс: BitrixCatalogCompatibleEventCompatibility
  • Вызов: EventCompatibility::handlerPriceOnBeforeUpdate
static function handlerPriceOnBeforeUpdate(CatalogModelEvent $event)
{
	$result = new CatalogModelEventResult();
	if (!self::allowedEvents())
		return $result;

	self::disableEvents();

	$handlerList = self::getHandlerList('catalog', self::EVENT_ON_BEFORE_PRICE_UPDATE);
	if (!empty($handlerList))
	{
		$error = false;
		$id = $event->getParameter('id');
		$fields = $event->getParameter('fields');
		$externalFields = $event->getParameter('external_fields');
		$oldFields = $fields;
		$oldExternalFields = $externalFields;
		$actions = $event->getParameter('actions');
		$fields['RECALL'] = (isset($actions['OLD_RECOUNT']) && $actions['OLD_RECOUNT'] === true);

		foreach ($handlerList as $handler)
		{
			if (ExecuteModuleEventEx($handler, [$id, &$fields]) === false)
			{
				$error = true;
				break;
			}
		}
		unset($handler);

		if (isset($fields['RECALL']))
		{
			$result->modifyActions(['OLD_RECOUNT' => $fields['RECALL']]);
			unset($fields['RECALL']);
		}
		else
		{
			if (isset($actions['OLD_RECOUNT']))
				$result->unsetActions(['OLD_RECOUNT']);
		}

		self::fillResultData($result, self::ENTITY_PRICE, $oldFields, $oldExternalFields, $fields);
		unset($actions, $oldExternalFields, $oldFields, $externalFields, $fields);

		if ($error)
			self::setHandlerError($result, self::EVENT_ON_BEFORE_PRICE_UPDATE);
		unset($error);
	}
	unset($handlerList);

	self::enableEvents();

	return $result;
}