• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/product.php
  • Класс: BitrixCatalogControllerProduct
  • Вызов: Product::processItemEvent
static function processItemEvent(array $arParams, array $arHandler): array
{
	$id = null;
	$event = $arParams[0] ?? null;

	if (!$event)
	{
		throw new RestException('event object not found trying to process event');
	}

	if($event instanceof Event) // update, add
	{
		$id = $event->getParameter('id');
	}
	else if($event instanceof BitrixMainORMEvent) // delete
	{
		$item = $event->getParameter('id');
		$id = is_array($item) ? $item['ID']: $item;
	}

	if (!$id)
	{
		throw new RestException('id not found trying to process event');
	}

	$product = BitrixCatalogModelProduct::getCacheItem($id);

	$type = $product['TYPE']  ?? null;

	if (!$type)
	{
		throw new RestException('type is not specified trying to process event');
	}

	return [
		'FIELDS' => [
			'ID' => $id,
			'TYPE' => $type
		],
	];
}