• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount/index/manager.php
  • Класс: BitrixSaleDiscountIndexManager
  • Вызов: Manager::extractElementsAndSections
private function extractElementsAndSections(array $condition)
{
	if(empty($condition['CLASS_ID']))
	{
		return null;
	}

	if($condition['CLASS_ID'] !== 'CondGroup' || empty($condition['DATA']))
	{
		return null;
	}

	if(empty($condition['CHILDREN']))
	{
		return null;
	}

	if(
		!($condition['DATA']['All'] === 'AND' && $condition['DATA']['True'] === 'True') &&
		!($condition['DATA']['All'] === 'OR'  && $condition['DATA']['True'] === 'True')
	)
	{
		return null;
	}

	$elementIds = $sectionIds = array();
	foreach($condition['CHILDREN'] as $child)
	{
		$onlyOneCondition =
			isset($child['CHILDREN'])
			&& is_array($child['CHILDREN'])
			&& count($child['CHILDREN']) === 1
			&& $child['DATA']['All'] === 'AND'
			&& $child['DATA']['Found'] === 'Found';

		if(
			$child['CLASS_ID'] === 'CondBsktProductGroup' &&
			(
				($child['DATA']['All'] === 'OR' && $child['DATA']['Found'] === 'Found') ||
				$onlyOneCondition
			)
		)
		{
			foreach($child['CHILDREN'] as $grandchild)
			{
				switch($grandchild['CLASS_ID'])
				{
					case 'CondIBElement':
						if (is_array($grandchild['DATA']['value']))
						{
							$elementIds = array_merge($elementIds, $grandchild['DATA']['value']);
						}
						else
						{
							$elementIds[] = $grandchild['DATA']['value'];
						}
						break;
					case 'CondIBSection':
						if($grandchild['DATA']['logic'] === 'Equal')
						{
							$sectionIds[] = $grandchild['DATA']['value'];
						}
						break;
				}
			}
		}
	}

	$elementIds = $this->convertSkuToMainProducts($elementIds);

	return array($elementIds, $sectionIds);
}