• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/component/elementlist.php
  • Класс: BitrixIblockComponentElementList
  • Вызов: ElementList::initSubQuery
protected function initSubQuery()
{
	$this->storage['SUB_FILTER'] = array();

	if (
		$this->useCatalog
		&& !$this->isMultiIblockMode()
		&& $this->offerIblockExist($this->arParams['IBLOCK_ID'])
	)
	{
		$catalogFilter = array();
		foreach ($this->globalFilter as $key => $value)
		{
			if (CProductQueryBuilder::isCatalogFilterField($key))
			{
				//TODO: remove this hack after new catalog.section filter
				if ($key === '=PRODUCT_UF_PRODUCT_MAPPING')
				{
					continue;
				}
				$catalogFilter[$key] = $value;
				unset($this->globalFilter[$key]);
			}
		}

		$iblock = $this->storage['CATALOGS'][$this->arParams['IBLOCK_ID']];
		$offersFilterExists = !empty($this->globalFilter['OFFERS']) && is_array($this->globalFilter['OFFERS']);

		if ($offersFilterExists)
		{
			$this->storage['SUB_FILTER'] = array_merge($this->globalFilter['OFFERS'], $catalogFilter);
			$this->storage['SUB_FILTER']['IBLOCK_ID'] = $iblock['IBLOCK_ID'];
			$this->storage['SUB_FILTER']['ACTIVE_DATE'] = 'Y';
			$this->storage['SUB_FILTER']['ACTIVE'] = 'Y';

			if ($this->arParams['HIDE_NOT_AVAILABLE'] === 'Y')
			{
				$this->storage['SUB_FILTER']['AVAILABLE'] = 'Y';
			}

			$this->filterFields['=ID'] = CIBlockElement::SubQuery(
				'PROPERTY_'.$iblock['SKU_PROPERTY_ID'],
				$this->storage['SUB_FILTER']
			);
		}
		elseif (!empty($catalogFilter))
		{
			$this->storage['SUB_FILTER'] = $catalogFilter;
			$this->storage['SUB_FILTER']['IBLOCK_ID'] = $iblock['IBLOCK_ID'];
			$this->storage['SUB_FILTER']['ACTIVE_DATE'] = 'Y';
			$this->storage['SUB_FILTER']['ACTIVE'] = 'Y';

			$this->filterFields[] = array(
				'LOGIC' => 'OR',
				array($catalogFilter),
				'=ID' => CIBlockElement::SubQuery(
					'PROPERTY_'.$iblock['SKU_PROPERTY_ID'],
					$this->storage['SUB_FILTER']
				),
			);
		}
	}
}