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
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
ProductId
Gets or sets the product ID.
public required string ProductId { get; set; }
Property Value
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
Methods
CompareTo(VariantCombination?)
Compares this combination with another by product ID, then by variant ID, both case-insensitively.
public int CompareTo(VariantCombination? other)
Parameters
otherVariantCombinationThe 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
objobjectThe object to compare with this instance.
Returns
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
languageIdstringThe ID of the language to read the product in.
Returns
GetVariantName(string)
Gets the display name of this combination, composed from the names of its variant options.
public string GetVariantName(string languageId)
Parameters
languageIdstringThe 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
Operators
operator ==(VariantCombination, VariantCombination)
Determines whether two combinations are the same instance, or both null.
public static bool operator ==(VariantCombination left, VariantCombination right)
Parameters
leftVariantCombinationThe first combination.
rightVariantCombinationThe second combination.
Returns
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
leftVariantCombinationThe first combination. A null value never sorts after anything.
rightVariantCombinationThe second combination.
Returns
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
leftVariantCombinationThe first combination. A null value only qualifies when
rightis null too.rightVariantCombinationThe second combination.
Returns
operator !=(VariantCombination, VariantCombination)
Determines whether two combinations are different instances.
public static bool operator !=(VariantCombination left, VariantCombination right)
Parameters
leftVariantCombinationThe first combination.
rightVariantCombinationThe 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
leftVariantCombinationThe first combination. A null value sorts before any instance.
rightVariantCombinationThe second combination.
Returns
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
leftVariantCombinationThe first combination. A null value sorts before or equally to anything.
rightVariantCombinationThe second combination.