Table of Contents

Class VariantGroup

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

A group of VariantOption values that a product can vary over, e.g. a "Colour" group holding "Red" and "Blue". A product is related to one or more variant groups, and one option from each group makes up a VariantCombination.

[Serializable]
public class VariantGroup : IEquatable<VariantGroup>
Inheritance
VariantGroup
Implements
Inherited Members

Constructors

VariantGroup()

Initializes a new instance of the VariantGroup class.

public VariantGroup()

Properties

ExpandInProductIndex

When true, the index will contain one document per distinct value of this group (instead of one per master or one per leaf variant). Use this on e.g. a "Color" group to surface t-shirt red and t-shirt blue as separate list entries.

public bool ExpandInProductIndex { get; set; }

Property Value

bool

Family

Gets or sets a value indicating whether this group is a product family, i.e. whether its options were generated from the product numbers of separate products combined into one master product.

public bool Family { get; set; }

Property Value

bool

true if family, otherwise, false.

Id

Gets or sets the ID of the variant group. Assigned by the database when the group is first saved.

public string Id { get; set; }

Property Value

string

Translations

Gets the per-language translations of this group. Use GetName(string)/SetName(string, string?) and GetLabel(string)/SetLabel(string, string?) to read and write the translated texts.

public TranslationCollection<VariantGroupTranslation> Translations { get; }

Property Value

TranslationCollection<VariantGroupTranslation>

VariantDisplayType

Gets or sets how the options of this group are presented to the customer in the frontend.

public VariantGroupDisplayType VariantDisplayType { get; set; }

Property Value

VariantGroupDisplayType

Methods

Equals(VariantGroup?)

Determines whether the given group has the same ID, label and name as this one, all ignoring case.

public bool Equals(VariantGroup? group)

Parameters

group VariantGroup

The group to compare with this instance.

Returns

bool

true when all three match; otherwise, false.

Remarks

The label and name are compared in the current ecommerce context language.

Equals(object?)

Determines whether the given object is a VariantGroup equal to this one.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true when the groups are equal per Equals(VariantGroup?); otherwise, false.

GetAllVariantOptions()

Gets every variant option defined in this group, ordered by sort order.

public IList<VariantOption> GetAllVariantOptions()

Returns

IList<VariantOption>

The options in this group.

GetHashCode()

Returns a hash code derived from Id, ignoring case.

public override int GetHashCode()

Returns

int

The hash code for this variant group.

GetLabel(string)

Gets the label of this group in the given language. The label is the text shown next to the option selector in the frontend.

public string GetLabel(string languageId)

Parameters

languageId string

The ID of the language to get the label in.

Returns

string

The translated label; the default language's label when the requested language has no translation, and Id when neither has one.

GetName(string)

Gets the name of this group in the given language.

public string GetName(string languageId)

Parameters

languageId string

The ID of the language to get the name in.

Returns

string

The translated name; the default language's name when the requested language has no translation, and Id when neither has one.

GetProperties()

Gets the properties defined on this group, i.e. the extra per-option fields its options can carry.

public IList<VariantGroupProperty> GetProperties()

Returns

IList<VariantGroupProperty>

The properties of this group.

GetVariantGroupProductRelations()

Gets the relations tying this group to the products that vary over it.

public IEnumerable<VariantGroupProductRelation> GetVariantGroupProductRelations()

Returns

IEnumerable<VariantGroupProductRelation>

The product relations for this group.

GetVariantOptions(string)

Gets the options from this group that the given product actually has variant combinations for.

public IList<VariantOption> GetVariantOptions(string productId)

Parameters

productId string

The ID of the product.

Returns

IList<VariantOption>

The subset of this group's options that are in use on the product.

SetLabel(string, string?)

Sets the label of this group in the given language, adding the translation when it is missing.

public void SetLabel(string languageId, string? label)

Parameters

languageId string

The ID of the language to set the label for.

label string

The variant group label.

SetName(string, string?)

Sets the name of this group in the given language, adding the translation when it is missing.

public void SetName(string languageId, string? name)

Parameters

languageId string

The ID of the language to set the name for.

name string

The variant group name.

To top