Class VariantOption
- Namespace
- Dynamicweb.Ecommerce.Variants
- Assembly
- Dynamicweb.Ecommerce.dll
One selectable option within a VariantGroup, e.g. "Red" in a "Colour" group. Variant options are combined across groups to form a VariantCombination.
[Serializable]
public class VariantOption : IComparable<VariantOption>
- Inheritance
-
VariantOption
- Implements
- Inherited Members
Properties
Color
Gets or sets the colour of this option, used when its group is displayed as VariantColor.
public string? Color { get; set; }
Property Value
GroupId
Gets or sets the ID of the VariantGroup this option belongs to.
public required string GroupId { get; set; }
Property Value
Icon
Gets or sets the path of the icon shown for this option in the administration.
public string? Icon { get; set; }
Property Value
Id
Gets or sets the ID of the variant option. Assigned by the database when the option is first saved.
public string Id { get; set; }
Property Value
LargeImage
Gets or sets the path of the large image for this option.
public string? LargeImage { get; set; }
Property Value
MediumImage
Gets or sets the path of the medium image for this option.
public string? MediumImage { get; set; }
Property Value
SmallImage
Gets or sets the path of the small image for this option.
public string? SmallImage { get; set; }
Property Value
SortOrder
Gets or sets the sort order of this option within its group. Options are ordered by this value first, then by Id.
public int SortOrder { get; set; }
Property Value
Translations
Gets the per-language translations of this option. Use GetName(string) and SetName(string, string?) to read and write the translated name.
public TranslationCollection<VariantOptionTranslation> Translations { get; }
Property Value
Methods
Clone()
Clones this instance.
public VariantOption Clone()
Returns
- VariantOption
The instance of the VariantOption.
CompareTo(VariantOption?)
public int CompareTo(VariantOption? other)
Parameters
otherVariantOptionThe option to compare with this instance.
Returns
- int
A negative value when this option sorts before
other, zero when they sort equally, and a positive value when it sorts after.
Equals(object?)
Determines whether the given object is a VariantOption with the same Id, ignoring case.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with this instance.
Returns
GetHashCode()
Returns a hash code derived from Id, ignoring case.
public override int GetHashCode()
Returns
- int
The hash code for this variant option.
GetName(string)
Gets the name of this variant option in the given language.
public string GetName(string languageId)
Parameters
languageIdstringThe 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.
SetName(string, string?)
Sets the name of this variant option in the given language, adding the translation when it is missing.
public void SetName(string languageId, string? name)
Parameters
Operators
operator ==(VariantOption, VariantOption)
public static bool operator ==(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option.
rightVariantOptionThe second option.
Returns
- bool
true when the options are equal per Equals(object?); otherwise, false.
operator >(VariantOption, VariantOption)
Determines whether the left option sorts after the right one, per CompareTo(VariantOption?).
public static bool operator >(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option. A null value never sorts after anything.
rightVariantOptionThe second option.
Returns
operator >=(VariantOption, VariantOption)
Determines whether the left option sorts after or equally to the right one, per CompareTo(VariantOption?).
public static bool operator >=(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option. A null value only qualifies when
rightis null too.rightVariantOptionThe second option.
Returns
operator !=(VariantOption, VariantOption)
Determines whether two options have different IDs.
public static bool operator !=(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option.
rightVariantOptionThe second option.
Returns
- bool
The negation of the operator ==(VariantOption, VariantOption) operator.
operator <(VariantOption, VariantOption)
Determines whether the left option sorts before the right one, per CompareTo(VariantOption?).
public static bool operator <(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option. A null value sorts before any instance.
rightVariantOptionThe second option.
Returns
operator <=(VariantOption, VariantOption)
Determines whether the left option sorts before or equally to the right one, per CompareTo(VariantOption?).
public static bool operator <=(VariantOption left, VariantOption right)
Parameters
leftVariantOptionThe first option. A null value sorts before or equally to anything.
rightVariantOptionThe second option.