Class VariantCombinationService
- Namespace
- Dynamicweb.Ecommerce.Variants
- Assembly
- Dynamicweb.Ecommerce.dll
Provides methods for querying and persisting the VariantCombination values of a product.
public class VariantCombinationService : ICacheStorage<string, IDictionary<string, VariantCombination>>, ICacheStorage<string>, ICacheStorage
- Inheritance
-
VariantCombinationService
- Implements
- Inherited Members
Properties
Info
Gets information about the state of the variant combination cache.
public virtual CacheInformation Info { get; }
Property Value
Methods
ClearCache()
Clears all cached combinations and raises the variant combination cleared notification.
public virtual void ClearCache()
ClearCache(IEnumerable<string>)
Clears the cached combinations of the given products and raises the variant combination cleared notification.
public virtual void ClearCache(IEnumerable<string> keys)
Parameters
keysIEnumerable<string>The IDs of the products to evict.
ClearCache(string)
Clears the cached combinations of the given product and raises the variant combination cleared notification.
public virtual void ClearCache(string key)
Parameters
keystringThe ID of the product to evict.
CrossProduct<T>(IEnumerable<IEnumerable<T>>)
Gets the cross product for two or more sequences (A x B).
public static IEnumerable<IEnumerable<T>> CrossProduct<T>(IEnumerable<IEnumerable<T>> sequences)
Parameters
sequencesIEnumerable<IEnumerable<T>>Sequence of datasets to cross
Returns
- IEnumerable<IEnumerable<T>>
One sequence per combination, each holding one item from every input sequence.
Type Parameters
TType of objects in the datasets
Examples
Twodimensional example for DataSet A and DataSet B all combinations of any value from A (a) combined with any combination of a value from B (b) Formally written as (a,b) where a in A, b in B or A x B
Exceptions
- ArgumentNullException
sequencesis null.
Delete(string)
Deletes every variant combination of the given product.
public virtual void Delete(string productId)
Parameters
productIdstringThe ID of the product.
Delete(string, string)
Deletes one specific variant combination of the given product.
public virtual void Delete(string productId, string variantId)
Parameters
GetAllPossibleVariantIds(IEnumerable<VariantGroup>, string)
Builds every variant ID that can be formed by taking one option from each of the given variant groups, i.e. the cross product of their options.
public virtual IList<string> GetAllPossibleVariantIds(IEnumerable<VariantGroup> variantGroups, string languageId)
Parameters
variantGroupsIEnumerable<VariantGroup>The variant groups to combine.
languageIdstringUnused. Kept for backwards compatibility.
Returns
Remarks
These are the combinations the groups allow, not the ones the product has - use GetVariantCombinations(string) for the latter.
Exceptions
- ArgumentNullException
variantGroupsis null.
GetVariantCombination(string, string)
Gets one specific variant combination of the given product.
public virtual VariantCombination? GetVariantCombination(string productId, string variantId)
Parameters
Returns
- VariantCombination
The combination, or null when the product has no such combination.
GetVariantCombinations(string)
Gets every variant combination of the given product.
public virtual IList<VariantCombination> GetVariantCombinations(string productId)
Parameters
productIdstringThe ID of the product.
Returns
- IList<VariantCombination>
The combinations of the product; empty when it has none or no product ID was given.
GetVariantName(string, string)
Gets the display name of a variant combination, composed from the names of the variant options it is made of.
public virtual string GetVariantName(string variantId, string languageId)
Parameters
variantIdstringThe variant combination ID, i.e. the option IDs joined by ".", e.g. "VO1.VO2".
languageIdstringThe ID of the language to get the option names in.
Returns
- string
The option names joined by CombinationTextSeparator, or an empty string when
variantIdis empty.
Save(VariantCombination)
Saves the given variant combination and puts it in the cache.
public virtual void Save(VariantCombination variantCombination)
Parameters
variantCombinationVariantCombinationThe variant combination to save.
Exceptions
- ArgumentNullException
variantCombinationis null.
Save(IEnumerable<VariantCombination>)
Saves the given variant combinations in one batch.
public virtual void Save(IEnumerable<VariantCombination> variantCombinations)
Parameters
variantCombinationsIEnumerable<VariantCombination>The variant combinations to save.
Remarks
Unlike Save(VariantCombination) this does not update the cache; clear it with ClearCache() when the saved combinations must be visible to subsequent reads.
Exceptions
- ArgumentNullException
variantCombinationsis null.
SetCacheType<TObjectCache>()
Switches the variant combination cache to the given cache implementation.
public virtual void SetCacheType<TObjectCache>() where TObjectCache : ServiceCache<string, IDictionary<string, VariantCombination>>
Type Parameters
TObjectCacheThe cache implementation to use.