• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount/gift/relateddata.php
  • Класс: BitrixSaleDiscountGiftRelatedDataTable
  • Вызов: RelatedDataTable::getGiftsData
static function getGiftsData(array $discount)
{
	$sectionIds = $elementIds = array();

	if (
		(empty($discount['ACTIONS_LIST']) || !is_array($discount['ACTIONS_LIST']))
		&& checkSerializedData($discount['ACTIONS']))
	{
		$discount['ACTIONS_LIST'] = unserialize($discount['ACTIONS'], ['allowed_classes' => false]);
	}

	if(!isset($discount['ACTIONS_LIST']['CHILDREN']) && is_array($discount['ACTIONS_LIST']['CHILDREN']))
	{
		return array($elementIds, $sectionIds);
	}

	foreach($discount['ACTIONS_LIST']['CHILDREN'] as $child)
	{
		if(!isset($child['CLASS_ID']) || !isset($child['DATA']) || $child['CLASS_ID'] !== CSaleActionGiftCtrlGroup::getControlID())
		{
			continue;
		}
		foreach($child['CHILDREN'] as $gifterChild)
		{
			switch($gifterChild['CLASS_ID'])
			{
				case 'GifterCondIBElement':
					$elementIds = array_merge($elementIds, (array)$gifterChild['DATA']['Value']);
					break;
				case 'GifterCondIBSection':
					$sectionIds = array_merge($sectionIds, (array)$gifterChild['DATA']['Value']);
					break;
			}
		}
		unset($gifterChild);
	}
	unset($child);

	return array($elementIds, $sectionIds);
}