• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/storedocumenttable.php
  • Класс: BitrixCatalogStoreDocumentTable
  • Вызов: StoreDocumentTable::withStoreList
static function withStoreList(MainORMQueryQuery $query, array $storeIds)
{
	MainTypeCollection::normalizeArrayValuesByInt($storeIds);
	if (empty($storeIds))
	{
		return;
	}

	$storeIdsForQuery = implode(',', $storeIds);
	$whereExpression = "(STORE_FROM IN ({$storeIdsForQuery}) OR STORE_TO IN ({$storeIdsForQuery}))";
	$tableName = StoreDocumentElementTable::getTableName();

	$query->whereExpr("
		(
			CASE WHEN EXISTS (
				SELECT ID
				FROM {$tableName}
				WHERE DOC_ID = %s
				AND {$whereExpression}
			)
			THEN 1
			ELSE 0
			END
		) = 1
	", ['ID']);
}