$ids =
[];
foreach ($products as $product) { $ids[] =
$product->
getId();
} $ids =
array_unique($ids);
$query =
$this->connection->
createQueryBuilder();
$query ->
addSelect('products.id as productId'
) ->
addSelect('relations.position as __relations_position'
) ->
addSelect($this->fieldHelper->
getPropertySetFields()) ->
addSelect($this->fieldHelper->
getPropertyGroupFields()) ->
addSelect($this->fieldHelper->
getPropertyOptionFields()) ->
addSelect($this->fieldHelper->
getMediaFields()) ;
$query->
from('s_filter_articles', 'filterArticles'
) ->
innerJoin('filterArticles', 's_articles', 'products', 'products.id = filterArticles.articleID'
) ->
innerJoin('filterArticles', 's_filter_values', 'propertyOption', 'propertyOption.id = filterArticles.valueID'
) ->
innerJoin('products', 's_filter', 'propertySet', 'propertySet.id = products.filtergroupID'
) ->
innerJoin('propertySet', 's_filter_relations', 'relations', 'relations.groupID = propertySet.id'
) ->
innerJoin('propertyOption', 's_filter_options', 'propertyGroup', 'propertyGroup.id = propertyOption.optionID AND relations.optionID = propertyGroup.id'
)