ProductPriceCollection example

protected $streams;

    protected ?ProductDownloadCollection $downloads = null;

    /** * @var array<int, string> */
    protected array $states = [];

    public function __construct()
    {
        $this->prices = new ProductPriceCollection();
    }

    public function __toString(): string
    {
        return (string) $this->getName();
    }

    public function getProductReviews(): ?ProductReviewCollection
    {
        return $this->productReviews;
    }

    
'quantityStart' => 1,
                        'quantityEnd' => 2,
                    ]),
                ]),
            ]),
            [],
        ];

        yield 'Only matching rule ids will be calculated' => [
            (new PartialEntity())->assign([
                'taxId' => Uuid::randomHex(),
                'prices' => new ProductPriceCollection([
                    (new ProductPriceEntity())->assign([
                        '_uniqueIdentifier' => Uuid::randomHex(),
                        // not inside the context (see above inside mock)                         'ruleId' => Defaults::SALES_CHANNEL_TYPE_API,
                        'price' => new PriceCollection([
                            new Price(Defaults::CURRENCY, 3, 3, false),
                        ]),
                        'quantityStart' => 1,
                        'quantityEnd' => null,
                    ]),
                ]),
            ]),
foreach ($this->getIterator() as $element) {
            /** @var ProductPriceCollection $prices */
            $prices = $element->getPrices();

            $rules[] = (array) $prices;
        }

        /** @var array<ProductPriceEntity> $productPriceEntities */
        $productPriceEntities = array_merge(...$rules);

        return new ProductPriceCollection($productPriceEntities);
    }

    /** * @param list<string> $optionIds */
    public function filterByOptionIds(array $optionIds): self
    {
        return $this->filter(function DProductEntity $product) use ($optionIds) {
            $ids = $product->getOptionIds() ?? [];
            $same = array_intersect($ids$optionIds);

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