Table of Contents

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

CacheInformation

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

keys IEnumerable<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

key string

The 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

sequences IEnumerable<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

T

Type 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

sequences is null.

Delete(string)

Deletes every variant combination of the given product.

public virtual void Delete(string productId)

Parameters

productId string

The 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

productId string

The ID of the product.

variantId string

The ID of the variant combination.

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

variantGroups IEnumerable<VariantGroup>

The variant groups to combine.

languageId string

Unused. Kept for backwards compatibility.

Returns

IList<string>

The possible variant IDs, each being the option IDs joined by ".".

Remarks

These are the combinations the groups allow, not the ones the product has - use GetVariantCombinations(string) for the latter.

Exceptions

ArgumentNullException

variantGroups is null.

GetVariantCombination(string, string)

Gets one specific variant combination of the given product.

public virtual VariantCombination? GetVariantCombination(string productId, string variantId)

Parameters

productId string

The ID of the product.

variantId string

The ID of the variant combination.

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

productId string

The 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

variantId string

The variant combination ID, i.e. the option IDs joined by ".", e.g. "VO1.VO2".

languageId string

The ID of the language to get the option names in.

Returns

string

The option names joined by CombinationTextSeparator, or an empty string when variantId is empty.

Save(VariantCombination)

Saves the given variant combination and puts it in the cache.

public virtual void Save(VariantCombination variantCombination)

Parameters

variantCombination VariantCombination

The variant combination to save.

Exceptions

ArgumentNullException

variantCombination is null.

Save(IEnumerable<VariantCombination>)

Saves the given variant combinations in one batch.

public virtual void Save(IEnumerable<VariantCombination> variantCombinations)

Parameters

variantCombinations IEnumerable<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

variantCombinations is 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

TObjectCache

The cache implementation to use.

To top