• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblock.php
  • Класс: CAllIBlock
  • Вызов: CAllIBlock::getProductId
static function getProductId(int $elementId, int $iblockId): ?int
{
	if ($elementId <= 0 || $iblockId <= 0)
	{
		return null;
	}
	if (self::$catalogIncluded === null)
	{
		self::$catalogIncluded = Loader::includeModule('catalog');
	}
	if (!self::$catalogIncluded)
	{
		return null;
	}

	if (!isset(self::$urlParentCache[$elementId]))
	{
		$list = CCatalogSku::getProductList($elementId, $iblockId);
		self::$urlParentCache[$elementId] = $list[$elementId]['ID'] ?? false;
	}

	return (
		!empty(self::$urlParentCache[$elementId])
			? self::$urlParentCache[$elementId]
			: null
	);
}