Table of Contents

Class VariantGroupService

Namespace
Dynamicweb.Ecommerce.Variants
Assembly
Dynamicweb.Ecommerce.dll

Provides methods for querying and persisting VariantGroup values, along with their properties, option property values and product relations.

public class VariantGroupService : ICacheStorage<string, VariantGroup>, ICacheStorage<string>, ICacheStorage
Inheritance
VariantGroupService
Implements
Inherited Members

Properties

Info

Gets information about the state of the variant group cache.

public CacheInformation Info { get; }

Property Value

CacheInformation

Methods

ClearCache()

Clears the variant group cache and raises the variant group cleared notification.

public virtual void ClearCache()

ClearCache(IEnumerable<string>)

Clears the given variant groups from the cache and raises the variant group cleared notification.

public virtual void ClearCache(IEnumerable<string> keys)

Parameters

keys IEnumerable<string>

The IDs of the variant groups to evict.

ClearCache(string)

Clears the given variant group from the cache and raises the variant group cleared notification.

public virtual void ClearCache(string key)

Parameters

key string

The ID of the variant group to evict.

ClearOptionValues()

Clears variant group property values cache.

public virtual void ClearOptionValues()

ClearVariantGroupProductRelationCache()

Clears the cache of relations between products and variant groups.

public virtual void ClearVariantGroupProductRelationCache()

ClearVariantGroupPropertiesCache()

Clears variant group properties cache.

public virtual void ClearVariantGroupPropertiesCache()

CreateProductRelation(string, string)

Relates the given product to the given variant group, appending it after the product's existing groups.

public virtual void CreateProductRelation(string productId, string variantGroupId)

Parameters

productId string

The ID of the product.

variantGroupId string

The ID of the variant group.

Delete(VariantGroup)

Deletes the given variant group along with everything belonging to it. Does nothing when variantGroup is null.

public virtual void Delete(VariantGroup variantGroup)

Parameters

variantGroup VariantGroup

The variant group to delete.

DeleteOptionValues(string)

Deletes the property values a variant option carries, in every language.

public virtual void DeleteOptionValues(string optionId)

Parameters

optionId string

The ID of the variant option.

DeleteOptionValues(string, string)

Deletes the property values a variant option carries in one language.

public virtual void DeleteOptionValues(string optionId, string languageId)

Parameters

optionId string

The ID of the variant option.

languageId string

The ID of the language to delete the values for.

DeleteProductRelation(string, string, string)

Deletes variant group relations of the given product, narrowed by group and relation when supplied.

public virtual void DeleteProductRelation(string productId, string groupId = "", string relationId = "")

Parameters

productId string

The ID of the product.

groupId string

The ID of the variant group to limit the deletion to. Every group when empty.

relationId string

The ID of the single relation to delete. Every matching relation when empty.

DeleteProductRelations(IEnumerable<Product>)

Deletes every variant group relation of the given products.

public virtual void DeleteProductRelations(IEnumerable<Product> products)

Parameters

products IEnumerable<Product>

The products to remove the relations from.

DeleteVariantGroup(string)

Deletes the given variant group along with its properties, option property values, product relations and variant options.

public virtual void DeleteVariantGroup(string variantGroupId)

Parameters

variantGroupId string

The ID of the variant group.

DeleteVariantGroupProperty(VariantGroupProperty)

Deletes the given variant group property along with the values the group's options carry for it. Does nothing when variantGroupProperty is null.

public virtual void DeleteVariantGroupProperty(VariantGroupProperty variantGroupProperty)

Parameters

variantGroupProperty VariantGroupProperty

The variant group property to delete.

DeleteVariantGroupProperty(string)

Deletes the variant group property with the given ID, along with the values the group's options carry for it.

public virtual void DeleteVariantGroupProperty(string id)

Parameters

id string

The ID of the variant group property.

DeleteVariantGroupPropertyByGroupId(string)

Deletes every property of the given variant group, along with the values its options carry for them.

public virtual void DeleteVariantGroupPropertyByGroupId(string variantGroupId)

Parameters

variantGroupId string

The ID of the variant group.

GetAllVariantGroups()

Gets every variant group, product families included.

public virtual IList<VariantGroup> GetAllVariantGroups()

Returns

IList<VariantGroup>

All variant groups.

GetFamilyVariantGroups()

Gets every variant group flagged as a product family.

public virtual IList<VariantGroup> GetFamilyVariantGroups()

Returns

IList<VariantGroup>

The variant groups whose Family is true.

GetFilteredVariantGroups()

Gets every variant group except the ones flagged as product families.

public virtual IList<VariantGroup> GetFilteredVariantGroups()

Returns

IList<VariantGroup>

The variant groups whose Family is false.

GetProductRelations(VariantGroup)

Gets the relations tying the given variant group to every product that varies over it.

public virtual IEnumerable<VariantGroupProductRelation> GetProductRelations(VariantGroup variantGroup)

Parameters

variantGroup VariantGroup

The variant group.

Returns

IEnumerable<VariantGroupProductRelation>

The relations of the group; empty when no product uses it.

Exceptions

ArgumentNullException

variantGroup is null.

GetProductRelations(VariantGroup, string)

Gets the relations between the given variant group and the given product.

public virtual IEnumerable<VariantGroupProductRelation> GetProductRelations(VariantGroup variantGroup, string productId)

Parameters

variantGroup VariantGroup

The variant group.

productId string

The ID of the product.

Returns

IEnumerable<VariantGroupProductRelation>

The relations between the two; empty when the product does not use the group.

Exceptions

ArgumentNullException

variantGroup is null.

GetProductRelations(string)

Gets the variant group relations of the given product, in sort order.

public virtual IEnumerable<VariantGroupProductRelation> GetProductRelations(string productId)

Parameters

productId string

The ID of the product.

Returns

IEnumerable<VariantGroupProductRelation>

The relations of the product; empty when it has none.

GetVariantGroup(string)

Gets the variant group with the given ID.

public virtual VariantGroup? GetVariantGroup(string variantGroupId)

Parameters

variantGroupId string

The ID of the variant group.

Returns

VariantGroup

The variant group, or null when no group has that ID.

GetVariantGroupOptionPropertyValue(string, string, string, bool)

Gets the value a variant option carries for one of its group's properties.

public virtual string GetVariantGroupOptionPropertyValue(string optionId, string propertyId, string languageId, bool showUntranslated = false)

Parameters

optionId string

The ID of the variant option.

propertyId string

The ID of the variant group property.

languageId string

The ID of the language to get the value in.

showUntranslated bool

When true, falls back to the default language if the requested language has no value.

Returns

string

The property value, or an empty string when there is none.

GetVariantGroupProperties()

Gets every variant group property defined across all variant groups.

public virtual IEnumerable<VariantGroupProperty> GetVariantGroupProperties()

Returns

IEnumerable<VariantGroupProperty>

The variant group properties.

GetVariantGroupProperty(string)

Gets the variant group properties for the specified group.

public virtual IList<VariantGroupProperty> GetVariantGroupProperty(string groupId)

Parameters

groupId string

The ID of the variant group.

Returns

IList<VariantGroupProperty>

The properties of the group; empty when it has none.

GetVariantGroupsByProductId(string)

Gets the variant groups with options.

public virtual IList<VariantGroup> GetVariantGroupsByProductId(string productId)

Parameters

productId string

The product id.

Returns

IList<VariantGroup>

The IList<T>.

Save(VariantGroup)

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

public virtual void Save(VariantGroup variantGroup)

Parameters

variantGroup VariantGroup

The variant group to save.

Exceptions

ArgumentNullException

variantGroup is null.

Save(VariantGroupProductRelation)

Saves the given relation between a product and a variant group.

public virtual void Save(VariantGroupProductRelation relation)

Parameters

relation VariantGroupProductRelation

The relation to save. Its sorting decides the order the group appears in on the product.

Save(VariantGroupProperty)

Saves the given variant group property.

public virtual void Save(VariantGroupProperty variantGroupProperty)

Parameters

variantGroupProperty VariantGroupProperty

The variant group property to save.

SaveValue(string, string, string, string)

Saves the value a variant option carries for one of its group's properties, in the given language.

public virtual void SaveValue(string optionId, string propertyId, string languageId, string propertyValue)

Parameters

optionId string

The ID of the variant option.

propertyId string

The ID of the variant group property.

languageId string

The ID of the language to save the value for.

propertyValue string

The property value.

SetCacheType<TObjectCache>()

Switches the variant group cache to the given cache implementation.

public void SetCacheType<TObjectCache>() where TObjectCache : ServiceCache<string, VariantGroup>

Type Parameters

TObjectCache

The cache implementation to use.

VariantGroupCounter(string)

Gets the number of variant groups the given product varies over.

public virtual int VariantGroupCounter(string productId)

Parameters

productId string

The ID of the product.

Returns

int

The count of variant group relations on the product.

To top