CheapestPriceFacade example

// mock context to simulate currency and tax states         $context = $this->createMock(SalesChannelContext::class);

        // currency key will be provided, we want to test different currencies are taking into account         $context->expects(static::any())->method('getCurrencyId')->willReturn($ids->get($currencyKey));

        // we also want to test different tax states (gross/net)         $context->expects(static::any())->method('getTaxState')->willReturn($taxState);
        $context->expects(static::any())->method('getItemRounding')->willReturn(new CashRoundingConfig(2, 0.01, true));

        return new CheapestPriceFacade($entity$original$stubs$context);
    }
}

    }

    /** * The `calculatedCheapestPrice` property returns the cheapest price of the product. The price object will * be wrapped into a `PriceFacade` object which allows to manipulate the price. * * @return PriceFacade|null Returns a `PriceFacade` if the product has a calculated cheapest price, otherwise `null` */
    public function calculatedCheapestPrice(): ?PriceFacade
    {
        return $this->product->get('calculatedCheapestPrice') ? new CheapestPriceFacade(
            $this->product,
            $this->product->get('calculatedCheapestPrice'),
            $this->priceStubs,
            $this->context
        ) : null;
    }

    /** * The `calculatedPrice` property returns the price of the product. The price object will * be wrapped into a `PriceFacade` object which allows to manipulate the price. * * @return PriceFacade|null Returns a `PriceFacade` if the product has a price, otherwise `null` */
Home | Imprint | This part of the site doesn't use cookies.