sortByPrice example

static::assertCount(1, $products);
        static::assertTrue($products->has($id));

        $product = $products->get($id);

        static::assertSame($id$product->getId());

        static::assertEquals(new Price(Defaults::CURRENCY, 10, 15, false)$product->getCurrencyPrice(Defaults::CURRENCY));
        static::assertInstanceOf(ProductPriceCollection::class$product->getPrices());
        static::assertCount(2, $product->getPrices());

        $product->getPrices()->sortByPrice($context);

        $price = $product->getPrices()->first();
        static::assertSame(10.0, $price->getPrice()->first()->getGross());
        static::assertSame(8.0, $price->getPrice()->first()->getNet());
    }

    public function testProductPricesSortByNetPrice(): void
    {
        $context = Context::createDefaultContext();
        $context->setTaxState(CartPrice::TAX_STATE_NET);

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