• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/tree.php
  • Класс: BitrixSaleLocationis
  • Вызов: is::getPathToNodeByCondition
static function getPathToNodeByCondition($filter, $parameters = array(), $behaviour = array('SHOW_LEAF' => true))
{
	$filter = Assert::expectNotEmptyArray($filter, '$filter');

	if(!is_array($behaviour))
		$behaviour = array();
	if(!isset($behaviour['SHOW_LEAF']))
		$behaviour['SHOW_LEAF'] = true;

	if(empty($parameters))
		$parameters = array();

	// todo: try to do this job in a single query with join. Speed profit?

	$node = self::getList(array('filter' => $filter, 'limit' => 1))->fetch();
	if(!isset($node['ID']))
		throw new MainSystemException(Loc::getMessage('SALE_LOCATION_TREE_ENTITY_NODE_NOT_FOUND_EXCEPTION'));

	$parameters['filter']['<=LEFT_MARGIN'] = intval($node['LEFT_MARGIN']);
	$parameters['filter']['>=RIGHT_MARGIN'] = intval($node['RIGHT_MARGIN']);

	if(!$behaviour['SHOW_LEAF'])
		$parameters['filter']['!=ID'] = $node['ID'];

	$parameters['order'] = array(
		'LEFT_MARGIN' => 'asc'
	);

	return self::getList($parameters);
}