ProductProviderBase Class |
Namespace: Dynamicweb.Ecommerce.LiveIntegration.Products
The ProductProviderBase type exposes the following members.
Name | Description | |
---|---|---|
ProductProviderBase | Initializes a new instance of the ProductProviderBase class |
Name | Description | |
---|---|---|
ExtractPrices |
Extracts the prices.
| |
FillProductValues |
Fills the product values.
| |
GetPrice |
Gets the price.
| |
GetProductFromVariantComboId |
Gets the product from variant combo identifier.
| |
GetProductIdentifier(Product) |
Creates a unique product identifier by concatenating the product ID or number (depends on the CalculatePriceUsingProductNumber setting), the variant ID and the language ID.
Override to build up your own unique identifier.
| |
GetProductIdentifier(Product, String) |
Creates a unique product identifier by concatenating the product ID or number (depends on the CalculatePriceUsingProductNumber setting), the variant ID and the language ID.
Override to build up your own unique identifier.
| |
GetProductPrices |
Gets the product prices list.
| |
IsLivePriceEnabledForProduct |
Checks if the product is enabled for the live prices requests.
Override this method if you want to skip some products from being looked up in the ERP.
|
using Dynamicweb.Ecommerce.Integration; using Dynamicweb.Ecommerce.Products; namespace Dynamicweb.Ecommerce.LiveIntegration.Examples { /// <summary> /// Class CustomProductProvider. /// </summary> /// <seealso cref="Products.ProductProviderBase" /> public class CustomProductProvider : Products.ProductProviderBase { /// <summary> /// Gets the product identifier. /// </summary> /// <param name="product">The product.</param> /// <returns>System.String.</returns> public override string GetProductIdentifier(Product product) { return GetProductIdentifier(product, null); } /// <summary> /// Gets the product identifier. /// </summary> /// <param name="product">The product.</param> /// <param name="unitId">The product unit Id.</param> /// <returns>System.String.</returns> public override string GetProductIdentifier(Product product, string unitId) { string unit = string.IsNullOrEmpty(unitId) ? string.Empty : $"-{unitId}"; return $"{product.Id}-{product.VariantId}-{product.LanguageId}-{product.Number}{unit}"; } /// <summary> /// Gets the price. /// </summary> /// <param name="product">The product.</param> /// <param name="quantity">The quantity.</param> /// <returns>System.Nullable<System.Double>.</returns> public override double? GetPrice(ProductInfo product, double quantity) { // Example: if we have a price per kilogram - we need to multiply it by quantity double unitPrice; if(double.TryParse(product["TotalPrice"].ToString(), out unitPrice)) { return unitPrice * quantity; } else { return base.GetPrice(product, quantity); } } } }