2

I asked a question related to a configuration of mappings via code some time ago. I have an issue with adding of multilingual strings to a target(Sitecore) item.

Initial question: Data Mapping Using Code

I found that I have to add 1 more step (Select Languages) comparing with a default flow. Also, I used "Resolve Multilanguage Sitecore Item Dictionary" pipeline step instead of "Resolve Sitecore Item". I could populate at least shared fields before the changes above, but can't do it now.

Have following error in the log:

ManagedPoolThread #6 17:12:28 ERROR [Data Exchange] Pipeline step processing will abort because no source object could be resolved from the pipeline context. (pipeline: Single Attribute Sync Pipeline, pipeline step: Apply Mapping, pipeline step identifier: acc13c65-140a-484a-bb6c-11d0cb999774, target location: ec64487d-e7e6-40b0-a86c-40c74b95e04e)

As I understand, my custom ValueMappingSet is not valid anymore. Does somebody have any example of mapping multi-language data via code?

Update:

My steps:

Select languages enter image description here

Resolve Multilanguage Sitecore Item Dictionary enter image description here

Apply Mapping enter image description here

Thanks in advance.

3

If I rightly understand you don't want to use configuration for mapping and you need to implement multi language support for mapping Sitecore items.

I will begin form the end.

There is Update Sitecore Item Pipeline Step - pipeline step that can create or update Sitecore item(s).

This pipeline step can handle 2 target objects. It checks whether types are:

  1. ItemModel
  2. IDictionary<string,ItemModel> where key is language

Here is how you can use code mapping:

var target = GetTarget(); //returns IDictionary<string,ItemModel>
var source = GeSource();  //returns source object

//Check if item model exist by language before map data

target["en"]["fieldTitle"] = source["en"].Title;
target["en"]["fieldDescription"] = source["en"].Description;

target["uk"]["fieldTitle"] = source["uk"].Title;
target["uk"]["fieldDescription"] = source["uk"].Description;

When target is Dictionary?

Target is dictionary when Select Languages Pipeline Step and Resolve Multilanguage Sitecore Item Dictionary Pipeline Step are used.

  • Select Languages Pipeline Step - allows to specify supported languages.
  • Resolve Multilanguage Sitecore Item Dictionary Pipeline Step - resolves item by language and creates target dictionary for specified languages if it does not exist.

Update from Maxim:

I had a wrong configuration in pipeline step "Resolve Multilanguage Attribute Item" ("Resolved Object Location" was empty). Vlad helped me to find this missing setting and solve my exception.

To populate the fields I used the following logic (based on Vlad's suggestions):

enter image description here

  • Hi Vlad. Thanks for so quick response. I have couple more questions: 1. Is it correct that I have to create my own Update Sitecore Item step to handle the dictionary (as in your example)? 2. What about shared (not localized) strings? Shall I have another pipeline step to update these fields? 3. On which step should the new versions of Sitecore item be created? In usual flow we check it in "Resolve Sitecore Item" step (we check the index, find the existing item or create a new one to have a target for the next step). What about multilanguage flow? – Max Jun 8 '18 at 12:30
  • 1. no if you target is dictionary as i mentioned in the answer. I know that you have your custom mapping so that is an example about. 2. no. 3. not sure about version but language will be resolved. You should use "Resolve Multilanguage Sitecore Item Dictionary Pipeline Step" – Vlad Shpak Jun 11 '18 at 8:33
  • Hi, I can't reach ValueMappingSet class (in Apply mapping step) atm. I can see that Source object was not resolved at all. Question: Shall the Source object be resolved in a different way? I have updated the initial post with couple images. – Max Jun 11 '18 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.