CheapestPriceContainer example

$propertyGroupSorter->expects(static::once())->method('sort');

        $subscriber = new ProductSubscriber(
            $productVariationBuilder,
            $calculator,
            $propertyGroupSorter,
            $maxPurchaseCalculator,
            $isNewDetector,
            $this->createMock(SystemConfigService::class),
        );

        $cheapestPrice = new CheapestPriceContainer([]);

        $entity = (new PartialEntity())->assign([
            'id' => Uuid::randomHex(),
            'properties' => new EntityCollection(),
            'cheapestPrice' => $cheapestPrice,
        ]);

        $subscriber->salesChannelLoaded(
            new SalesChannelEntityLoadedEvent(
                $this->createMock(ProductDefinition::class),
                [$entity],
                
$cheapestPrice = new RetryableQuery(
            $this->connection,
            $this->connection->prepare('UPDATE product SET cheapest_price = :price WHERE id = :id AND version_id = :version')
        );

        $accessorQuery = new RetryableQuery(
            $this->connection,
            $this->connection->prepare('UPDATE product SET cheapest_price_accessor = :accessor WHERE id = :id AND version_id = :version')
        );

        foreach ($all as $productId => $prices) {
            $container = new CheapestPriceContainer($prices);

            $cheapestPrice->execute([
                'price' => serialize($container),
                'id' => Uuid::fromHexToBytes($productId),
                'version' => $versionId,
            ]);

            $variantIds = $container->getVariantIds();

            if (!$variantIds) {
                continue;
            }
Home | Imprint | This part of the site doesn't use cookies.