Table of Contents

Class VariantCombination

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

One combination of variant options on a product, identified by the product ID and a variant ID made up of the participating variant option IDs joined by ".", e.g. "VO_RED.VO_LARGE".

[Serializable]
public class VariantCombination : IComparable<VariantCombination>
Inheritance
VariantCombination
Implements
Inherited Members

Constructors

VariantCombination()

Initializes a new instance of the VariantCombination class.

public VariantCombination()

Fields

CombinationTextSeparator

The separator placed between variant option names when a combination is rendered as text, e.g. "Red - Large".

public const string CombinationTextSeparator = " - "

Field Value

string

Properties

HasRowInProductTable

Gets a value indicating whether this combination is an extended variant, i.e. whether it has a product row of its own, as opposed to a simple variant that only exists as a combination.

public bool HasRowInProductTable { get; }

Property Value

bool

ProductId

Gets or sets the product ID.

public required string ProductId { get; set; }

Property Value

string

VariantId

Gets or sets the variant ID, i.e. the IDs of the variant options making up this combination joined by ".".

public required string VariantId { get; set; }

Property Value

string

Methods

CompareTo(VariantCombination?)

Compares this combination with another by product ID, then by variant ID, both case-insensitively.

public int CompareTo(VariantCombination? other)

Parameters

other VariantCombination

The combination to compare with this instance.

Returns

int

A negative value when this combination sorts before other, zero when they sort equally, and a positive value when it sorts after.

Equals(object?)

Determines whether the given object is this same instance.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true when obj is this instance; otherwise, false.

Remarks

Only reference equality is considered, so two combinations describing the same product and variant are not equal. Use CompareTo(VariantCombination?) - or compare ProductId and VariantId - to match on value.

GetHashCode()

Returns a hash code derived from VariantId, ignoring case.

public override int GetHashCode()

Returns

int

The hash code for this combination.

GetProduct(string)

Gets the variant product this combination points at.

public Product? GetProduct(string languageId)

Parameters

languageId string

The ID of the language to read the product in.

Returns

Product

The variant product, or null when this is a simple combination without a product row.

GetVariantName(string)

Gets the display name of this combination, composed from the names of its variant options.

public string GetVariantName(string languageId)

Parameters

languageId string

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

Returns

string

The option names joined by CombinationTextSeparator, e.g. "Red - Large".

GetVariantOptionIds()

Gets the IDs of the variant options making up this combination.

public string[] GetVariantOptionIds()

Returns

string[]

The option IDs, in the order they appear in VariantId; empty when no variant ID is set.

Operators

operator ==(VariantCombination, VariantCombination)

Determines whether two combinations are the same instance, or both null.

public static bool operator ==(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination.

right VariantCombination

The second combination.

Returns

bool

true when both operands are the same instance or both are null; otherwise, false.

Remarks

Follows Equals(object?), which only considers reference equality.

operator >(VariantCombination, VariantCombination)

Determines whether the left combination sorts after the right one, per CompareTo(VariantCombination?).

public static bool operator >(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination. A null value never sorts after anything.

right VariantCombination

The second combination.

Returns

bool

true when left sorts after right; otherwise, false.

operator >=(VariantCombination, VariantCombination)

Determines whether the left combination sorts after or equally to the right one, per CompareTo(VariantCombination?).

public static bool operator >=(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination. A null value only qualifies when right is null too.

right VariantCombination

The second combination.

Returns

bool

true when left does not sort before right; otherwise, false.

operator !=(VariantCombination, VariantCombination)

Determines whether two combinations are different instances.

public static bool operator !=(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination.

right VariantCombination

The second combination.

Returns

bool

The negation of the operator ==(VariantCombination, VariantCombination) operator.

operator <(VariantCombination, VariantCombination)

Determines whether the left combination sorts before the right one, per CompareTo(VariantCombination?).

public static bool operator <(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination. A null value sorts before any instance.

right VariantCombination

The second combination.

Returns

bool

true when left sorts before right; otherwise, false.

operator <=(VariantCombination, VariantCombination)

Determines whether the left combination sorts before or equally to the right one, per CompareTo(VariantCombination?).

public static bool operator <=(VariantCombination left, VariantCombination right)

Parameters

left VariantCombination

The first combination. A null value sorts before or equally to anything.

right VariantCombination

The second combination.

Returns

bool

true when left does not sort after right; otherwise, false.

To top