getCalculatedPrices example

$error = sprintf('Case "%s": Product with key %s not found', $message$key);
                    static::assertInstanceOf(SalesChannelProductEntity::class$product$error);

                    $error = sprintf('Case "%s": Product with key %s, no calculated price found', $message$key);
                    static::assertInstanceOf(CalculatedPrice::class$product->getCalculatedPrice()$error);

                    $error = sprintf('Case "%s": Product with key %s, calculated price not match', $message$key);
                    static::assertEquals($assertion['price']$product->getCalculatedPrice()->getUnitPrice()$error);

                    $error = sprintf('Case "%s": Product with key %s, advanced prices count not match', $message$key);
                    static::assertEquals(\count($assertion['prices']), \count($product->getCalculatedPrices())$error);
                    foreach ($assertion['prices'] as $index => $expected) {
                        $price = $product->getCalculatedPrices()->get($index);

                        $error = sprintf('Case "%s": Product with key %s, advanced prices with index %s not match', $message$key$index);
                        static::assertInstanceOf(CalculatedPrice::class$price$error);
                        static::assertEquals($expected$price->getUnitPrice()$error);
                    }

                    $error = sprintf('Case "%s": Product with key %s, cheapest price not match', $message$key);
                    static::assertEquals($assertion['cheapest']$product->getCalculatedCheapestPrice()->getUnitPrice()$error);
                }
            }
'parentId' => $product->getParentId(),
            'stock' => $product->getStock(),
        ];

        $lineItem->replacePayload($payload['purchasePrices' => true]);
    }

    private function getPriceDefinition(SalesChannelProductEntity $product, SalesChannelContext $context, int $quantity): QuantityPriceDefinition
    {
        $this->priceCalculator->calculate([$product]$context);

        if ($product->getCalculatedPrices()->count() === 0) {
            return $this->buildPriceDefinition($product->getCalculatedPrice()$quantity);
        }

        // keep loop reference to $price variable to get last quantity price in case of "null"         $price = $product->getCalculatedPrice();
        foreach ($product->getCalculatedPrices() as $price) {
            if ($quantity <= $price->getQuantity()) {
                break;
            }
        }

        
ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $availability = null;
        $listingPrices = null;
        $combinations = null;
        $configurations = null;
        $variantConfiguration = null;
        $products = $this->productGateway->getList($numbers$context);
        $average = $this->voteService->getAverages($products$context);
        $cheapest = $this->getCheapestPrices($products$shop->getId());
        $calculated = $this->getCalculatedPrices($shop$products$cheapest);
        $categories = $this->getCategories($products);
        $properties = $this->getProperties($products$context);

        $variantFacet = $this->variantHelper->getVariantFacet();

        $productIds = array_map(
            static function DListProduct $product) {
                return $product->getId();
            },
            $products
        );

        
Home | Imprint | This part of the site doesn't use cookies.