London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Importing DictionaryMultiValue keys

Vote:
 

Hi.


Is it possible via the CSV import to create new entries in a DictionaryMultiValue property so the users/editors don't have to create them manually in Commerce Manager before hand themselves?

For example - if we have a ProductColor property which is MultiValue (a product can have multiple colors) and they want to import a new cataloge with new colors, then instead of having to manually create the entrires for all the color variances, having the import do it?

#178338
May 09, 2017 14:54
Vote:
 

Thanks, but no - the other question I made was in regards to the actual format of the CSV file; it doesn't answer if it's possible for the import to create the values that do not exists.

For example, if I read in a value of "red, blue, green" but only "red" and "blue" are defined in the dictionary - is there any way, any class I can override, any API I can call, or an import to run, that can create the "green" value for me?
Or will it be a manual process for each value?

Thanks in advance.

#178366
Edited, May 10, 2017 8:43
Vote:
 

Ah sorry - read it too fast.

Yes, it's possible to use APIs to create DictionaryMultiValue - you just can't create it with CSV Import. 

Here's an example of creating a new metafield of type DictionaryMultiValue, and add Hello and World to it. The APIs are not pretty, but they do the work:

var metaField = MetaField.Create(MetaDataContext.Instance, "", metaFieldName, metaFieldName, "",        

        MetaDataType.DictionaryMultiValue , 10, false, false, false, false);

if (!metaField.Dictionary.Contains("Hello"))

{     

metaField.Dictionary.Add(new MetaDictionaryItem("Hello"));

}

if (!metaField.Dictionary.Contains("World"))

{     

metaField.Dictionary.Add(new MetaDictionaryItem("World"));

}



#178372
May 10, 2017 11:18
Vote:
 

Ahh great - I'll take a look at it and test it out for my purpose.


Thank you for your time.

#178373
May 10, 2017 11:20
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.