Posted on 13/08/2019 02:32:45
Hi Nuno,
I've wrote small example which allow you recreate custom field lists options:
private void RecreateCustomListFieldOptions(string fieldId, FieldOptionCollection options)
{
var field = new ProductField(fieldId);
Ecommerce.Common.Application.KillProductFields();
FieldOption.DeleteAll(fieldId);
foreach (var opt in options)
{
opt.FieldId = fieldId;
opt.Save();
}
FieldOptionTranslation.DeleteExcessOptions();
foreach (var language in Ecommerce.Services.Languages.GetLanguages())
{
foreach (var opt in options)
{
var translatedOption = FieldOptionTranslation.GetTranslatedOption(opt.Id, language.LanguageId);
if (translatedOption == null)
{
translatedOption = new FieldOptionTranslation()
{
LanguageId = language.LanguageId,
OptionId = opt.Id
};
}
translatedOption.Name = opt.Name;
translatedOption.Save();
}
}
FieldOptionTranslation.ClearCache();
}
The full class is here: gist