• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/action/entity/changebasketitemaction.php
  • Класс: BitrixSaleControllerActionEntityChangeBasketItemAction
  • Вызов: ChangeBasketItemAction::selectOfferById
static function selectOfferById(int $iblockId, int $parentId, int $productId, array $offerPropertyCodeList = [])
{
	$offers = CCatalogSku::getOffersList(
		$parentId,
		$iblockId,
		[
			'ACTIVE' => 'Y',
			'ACTIVE_DATE' => 'Y',
			'CATALOG_AVAILABLE' => 'Y',
			'CHECK_PERMISSIONS' => 'Y',
			'MIN_PERMISSION' => 'R',
		],
		['ID', 'IBLOCK_ID', 'XML_ID', 'NAME'],
		['CODE' => $offerPropertyCodeList]
	);

	if (empty($offers[$parentId][$productId]))
	{
		return null;
	}

	$result = [
		'ID' => $offers[$parentId][$productId]['ID'],
		'IBLOCK_ID' => $offers[$parentId][$productId]['IBLOCK_ID'],
		'NAME' => $offers[$parentId][$productId]['NAME'],
		'XML_ID' => $offers[$parentId][$productId]['XML_ID'],
		'PROPERTIES' => $offers[$parentId][$productId]['PROPERTIES'],
	];

	if (mb_strpos($result['XML_ID'], '#') === false)
	{
		$parentData = IblockElementTable::getList([
			'select' => ['ID', 'XML_ID'],
			'filter' => ['ID' => $parentId],
		])->fetch();
		if (!empty($parentData))
		{
			$result['XML_ID'] = $parentData['XML_ID'].'#'.$result['XML_ID'];
		}
	}

	return $result;
}