Table of Contents

Class FieldOption

Namespace
Dynamicweb.Ecommerce.Products
Assembly
Dynamicweb.Ecommerce.dll

Represents a single field option.

[Serializable]
public class FieldOption
Inheritance
FieldOption
Inherited Members

Examples

using Dynamicweb.Ecommerce.Products;

namespace Dynamicweb.Ecommerce.Examples.Products;

public static class ProductFieldOptionHandlerSample
{
    public static string AddOption(string fieldId, string name, string value)
    {
        var option = new FieldOption
        {
            FieldId = fieldId,
            Sort = Services.FieldOptions.MaximumSort(fieldId) + 1,
            Value = value,
            IsDefault = false
        };

        string languageId = Services.Languages.GetDefaultLanguageId();
        option.SetName(languageId, name);

        Services.FieldOptions.Save(option);

        return option.Id;
    }
}

Constructors

FieldOption()

Initializes a new instance of FieldOption.

public FieldOption()

Properties

FieldId

Gets or sets and ID of the related field.

public required string FieldId { get; set; }

Property Value

string

Id

Gets or sets option ID.

public string Id { get; set; }

Property Value

string

Image

Gets or sets the image.

public string? Image { get; set; }

Property Value

string

IsDefault

Gets or sets value indicating whether this option is selected by default.

public bool IsDefault { get; set; }

Property Value

bool

Sort

Gets or sets the sort number.

public int Sort { get; set; }

Property Value

int

Translations

Gets the translations for the current entity

public TranslationCollection<FieldOptionTranslation> Translations { get; }

Property Value

TranslationCollection<FieldOptionTranslation>

Value

Gets or sets the value associated with this option.

public string Value { get; set; }

Property Value

string

Methods

GetName(string)

public string GetName(string languageId)

Parameters

languageId string

Returns

string

SetName(string, string?)

public void SetName(string languageId, string? name)

Parameters

languageId string
name string
To top