Developer forum

Forum » Rapido » Get FieldOptionName from Product

Get FieldOptionName from Product

Kasper Pedersen
Reply

Hello. is it possible to get the selected FieldOptionName from a Dynamicweb.Ecommerce.Products.Product? I have a Product field of the type List box where the Name and Value in the options are different, but it seems that it is only possible to retrieve the value. 


Replies

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply
This post has been marked as an answer

Hi,

 

var options = FieldOptionService.GetOptionsByFieldId(fieldId);
foreach(var option in options)
{
var optionName = option.GetName(LanguageId)
}

 

or

 

var optionTranslation = FieldOptionService.GetOptionById(optionId).GetName(LanguageId);

 

if you only have fieldValue, vut do not know fieldOptionId then may be you may need

var fieldOption = field.GetFieldOptions()?.FirstOrDefault(option => option.Value.Equals(fieldValue, StringComparison.OrdinalIgnoreCase));
var optionName = fieldOption.GetName(LanguageId);
Votes for this answer: 1

 

You must be logged in to post in the forum