Get value StringDictionary type on metafield Commerce 10.4



We have set up a StringDictionary property on our variation node in Commerce, but figured it would be better to create it by code.

Is there a way to programmatically setting StringDictionary property on model for the variation?
If not, since it's possible to configure it via Commerce Manager, is there a way to get the values using the catalog API?


Mar 20, 2017 14:36


No, unfortunately that is not supported. However you can try this approach:

It's not tested (and therefore not recommended by us), but it might work.

We have plan to support stringdictionary but it will not happen anytime soon.



Mar 20, 2017 16:46

Hi Quan,

Thanks for the quick answer. But since the stringdictionary type is implemented in Commerce via the back-end it must be some way of getting the values out in the view via MVC?
If not with catalog API, perhaps via Metadata or some other way? If it does, i would highly appreciate some kind of example to get us further in our progress.

Thanks for the optional solution, we'll look into that aswell!


Mar 21, 2017 13:56

If you just want to get the StringDictionary - one of the option is the MetaObject. Once you loaded the MetaObject, you can simply have this code:

var stringDict = metaObject["<StringDictionaryMetafieldName>"] as MetaStringDictionary;

Mar 21, 2017 14:13


this seemed to have worked. I tried out the following code:

CatalogEntryDto dto = CatalogContext.Current.GetCatalogEntryDto(currentContent.Code,
new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Request));

CatalogEntryDto.CatalogEntryRow catRow =

MetaObject mo = MetaObject.Load
(CatalogContext.MetaDataContext, catRow.CatalogEntryId, catRow.MetaClassId);

var stringdict = mo["StringDictionaryMetaFiledName"] as MetaStringDictionary;

where currentContent.Code is the variation code set in Commerce back-end.
I also added a few nullchecks, but the main thing about the code seems to be working.
Thanks for this Quan!


Mar 21, 2017 16:33
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.