Try our conversational search powered by Generative AI!

How to add StringDictionary to commerce from code



i have added new property of type PropertyDictionaryMultiple and now i need to add 500 choosable items to it and really dont want to do it manually.. 

[Display(Name = "my special property", GroupName = GroupNames.Categoriestab, ,Order = 1400)]
public override ItemCollection AccessProperties { get; set; }

is there a way to populate them from code?


Jan 13, 2016 13:57

by populating i mean addind them to the system so that they are choosable on variants :)

Jan 13, 2016 14:45


StringDictionary is not supported by strongly typed content type currently. Gatis made a custom implementation here:  - I did not try it and I don't know if it works as you wanted, but you can try it yourself.



Jan 14, 2016 8:29

Thanks Quan, i found that one but was hoping there was a easier way to solve this today.. :)

Jan 14, 2016 13:27

Quan is there a way to add  MetaDataType.EnumMultiValue from code? 

like for this one:

[Display(Name = "my special property", GroupName = GroupNames.Categoriestab, ,Order = 1400)]
public override ItemCollection<string> AccessProperties { get; set; }

Jan 14, 2016 16:04

You should be able to use the property itself as it maps to EnumMultiValue


Jan 18, 2016 18:41

thanks all for your help :)

using Get and Store from MetaDictionaryItemStore solved my issue

this solved my issue:

MetaDictionaryItemStore newItemStore = ServiceLocator.Current.GetInstance<MetaDictionaryItemStore>();

var allItems = (IEnumerable<MetaDictionaryItemModel>)newItemStore.Get(parentCategoryId, new ItemRange()).Data;

if (!allItems.Where(s => s.DefaultValue.Equals(name)).Any())
var newModel = new MetaDictionaryItemModel();
newModel.DefaultValue = name;
newModel.IsInUse = true;
newModel.OwnerMetaFieldId = parentCategoryId;
newModel.Value = name;

Jan 23, 2016 12:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.