AI OnAI Off
You can do that with IPriceService by using the method
IEnumerable<IPriceValue> GetPrices(MarketId market, DateTime validOn, IEnumerable<CatalogKey> catalogKeys, PriceFilter filter);
or
IEnumerable<IPriceValue> GetPrices(MarketId market, DateTime validOn, IEnumerable<CatalogKeyAndQuantity> catalogKeysAndQuantities, PriceFilter filter);
The parameter catalogKeys is all variant's codes of that product
I'm glad that you are aware that the default implementation of IPriceDetailService is not cached, a few more comments:
Hi,
Using Commerce 12.3.1.
I am trying to find an efficient way to find the highest and lowest price of a product. For example:
Product - Tables (T001) has 3 variants under it; small (T001-SM) priced at $5, medium (T001-M)priced at $7 and large (T001-L) priced at $10. I want to get a range of the prices from minimum to maximum ($5 -$10). I am able to get the price of all variants using IPriceDetailService, but this will kill the website when it goes live. The next option is IPriceService, I know that it is cached and I am unable to get all the prices of product.
Below is the snippet using IPriceDetailService, it works but this is not recommended:
Below is the snippet using IPriceService, but I am unable to get any prices as it gives a count of 0:
Any guidance on this will be helpful.