$this->
loadPrices($criteria,
$result,
$context);
} private function loadPrices(Criteria
$criteria, ProductSearchResult
$result, ShopContextInterface
$context): void
{ $cheapestPriceData =
$this->variantCheapestPriceGateway->
getList($result->
getProducts(),
$context,
$context->
getCurrentCustomerGroup(),
$criteria);
foreach ($result->
getProducts() as $product) { $number =
$product->
getNumber();
if (!\
array_key_exists($number,
$cheapestPriceData)) { $cheapestPriceRule =
$product->
getPriceRules()[0
];
$displayFromPrice =
$product->
displayFromPrice();
} else { $cheapestPriceRule =
$cheapestPriceData[$number]['price'
];
$displayFromPrice =
$cheapestPriceData[$number]['different_price_count'
] > 1;
} if ($product->
isPriceGroupActive()) { $cheapestPriceRule =
$this->
calculatePriceGroupDiscounts($product,
$cheapestPriceRule,
$context);
} $product->
setCheapestPriceRule($cheapestPriceRule);