• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/component/element.php
  • Класс: BitrixIblockComponentElement
  • Вызов: Element::chooseOffer
protected function chooseOffer($offers, $iblockId)
{
	$uniqueSortHash = array();

	foreach ($offers as $offer)
	{
		$elementId = $offer['LINK_ELEMENT_ID'];

		if (!isset($this->elementLinks[$elementId]))
			continue;

		if (!isset($uniqueSortHash[$elementId]))
		{
			$uniqueSortHash[$elementId] = array();
		}

		$uniqueSortHash[$elementId][$offer['SORT_HASH']] = true;

		if ($this->elementLinks[$elementId]['OFFER_ID_SELECTED'] == 0 && $offer['CAN_BUY'])
		{
			$this->elementLinks[$elementId]['OFFER_ID_SELECTED'] = $offer['ID'];
		}
	}
	unset($elementId, $offer);

	foreach ($this->elementLinks as &$element)
	{
		if ($element['OFFER_ID_SELECTED'] == 0)
			continue;

		if (count($uniqueSortHash[$element['ID']]) < 2)
		{
			$element['OFFER_ID_SELECTED'] = 0;
		}
	}
}