loadPrices example

$conditions = array_filter($conditionsfunction DVariantCondition $condition) {
            return $condition->expandVariants();
        });

        if (empty($conditions)) {
            return;
        }

        // executed if no price condition included in search request
        $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];
                
Home | Imprint | This part of the site doesn't use cookies.