->
innerJoin('price', 's_articles_details', 'variant', 'variant.id = price.articledetailsID'
) ->
innerJoin('variant', 's_articles', 'product', 'product.id = variant.articleID'
) ->
leftJoin('variant', 's_core_units', 'unit', 'unit.id = variant.unitID'
) ->
leftJoin('price', 's_articles_prices_attributes', 'priceAttribute', 'priceAttribute.priceID = price.id'
) ->
innerJoin('price', '(' .
$cheapestPriceQuery->
getSQL() . ')', 'variantCheapestPrice', 'variantCheapestPrice.id = price.id'
);
$this->fieldHelper->
addUnitTranslation($mainQuery,
$context);
$this->fieldHelper->
addProductTranslation($mainQuery,
$context);
$this->fieldHelper->
addVariantTranslation($mainQuery,
$context);
$this->fieldHelper->
addPriceTranslation($mainQuery,
$context);
$mainQuery->
setParameter(':customerGroup',
$context->
getCurrentCustomerGroup()->
getKey()) ->
setParameter(':fallbackCustomerGroup',
$context->
getFallbackCustomerGroup()->
getKey()) ->
setParameter(':variants',
$variantIds, Connection::PARAM_INT_ARRAY
) ->
setParameter(':priceGroupCustomerGroup',
$customerGroup->
getId());
$data =
$mainQuery->
execute()->
fetchAll(PDO::FETCH_ASSOC
);
$prices =
[];
foreach ($data as $row) { $product =
(string) $row['__variant_ordernumber'
];
$prices[$product]['price'
] =
$this->priceHydrator->
hydrateCheapestPrice($row);
$prices[$product]['price'
]->
setCustomerGroup($customerGroup);