/// <summary> /// Sets the variant prices by looping through all of the variants returned by the index. /// </summary> /// <param name="productDocument">The product document.</param> /// <param name="variantInfoList">The variant information list.</param> /// <param name="extendedPrice">The extended price.</param> /// <param name="isLowestPriceVariantSpecified">if set to <c>true</c> the lowest priced variant adjusted price is returned.</param> /// <param name="isLowestPriceVariantListPriceSpecified">if set to <c>true</c> the lowest priced variant list price is returned.</param> /// <param name="isHighestPriceVariantSpecified">if set to <c>true</c> the highest priced variant adjusted price.</param> protected virtual void SetVariantPricesFromProductVariants( CommerceProductSearchResultItem productDocument, List <VariantIndexInfo> variantInfoList, ExtendedCommercePrice extendedPrice, bool isLowestPriceVariantSpecified, bool isLowestPriceVariantListPriceSpecified, bool isHighestPriceVariantSpecified) { if (variantInfoList != null && variantInfoList.Count > 0) { decimal highestPrice = 0.0M; decimal lowestPrice = 0.0M; decimal basePrice = 0.0M; bool processingFirstItem = true; foreach (var variantInfo in variantInfoList) { if (processingFirstItem || variantInfo.ListPrice < lowestPrice) { lowestPrice = variantInfo.ListPrice; basePrice = variantInfo.BasePrice; } if (processingFirstItem || variantInfo.ListPrice > highestPrice) { highestPrice = variantInfo.ListPrice; } processingFirstItem = false; } if (isLowestPriceVariantSpecified) { extendedPrice.LowestPricedVariant = lowestPrice; } if (isLowestPriceVariantListPriceSpecified) { extendedPrice.LowestPricedVariantListPrice = basePrice; } if (isHighestPriceVariantSpecified) { extendedPrice.HighestPricedVariant = highestPrice; } } }
/// <summary> /// Sets the variant prices by looping through all of the variants returned by the index. /// </summary> /// <param name="productDocument">The product document.</param> /// <param name="variantInfoList">The variant information list.</param> /// <param name="extendedPrice">The extended price.</param> /// <param name="isLowestPriceVariantSpecified">if set to <c>true</c> the lowest priced variant adjusted price is returned.</param> /// <param name="isLowestPriceVariantListPriceSpecified">if set to <c>true</c> the lowest priced variant list price is returned.</param> /// <param name="isHighestPriceVariantSpecified">if set to <c>true</c> the highest priced variant adjusted price.</param> protected virtual void SetVariantPricesFromProductVariants( CommerceProductSearchResultItem productDocument, List<VariantIndexInfo> variantInfoList, ExtendedCommercePrice extendedPrice, bool isLowestPriceVariantSpecified, bool isLowestPriceVariantListPriceSpecified, bool isHighestPriceVariantSpecified) { if (variantInfoList != null && variantInfoList.Count > 0) { decimal highestPrice = 0.0M; decimal lowestPrice = 0.0M; decimal basePrice = 0.0M; bool processingFirstItem = true; foreach (var variantInfo in variantInfoList) { if (processingFirstItem || variantInfo.ListPrice < lowestPrice) { lowestPrice = variantInfo.ListPrice; basePrice = variantInfo.BasePrice; } if (processingFirstItem || variantInfo.ListPrice > highestPrice) { highestPrice = variantInfo.ListPrice; } processingFirstItem = false; } if (isLowestPriceVariantSpecified) { extendedPrice.LowestPricedVariant = lowestPrice; } if (isLowestPriceVariantListPriceSpecified) { extendedPrice.LowestPricedVariantListPrice = basePrice; } if (isHighestPriceVariantSpecified) { extendedPrice.HighestPricedVariant = highestPrice; } } }