Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Multilanguage node and entry API creation (7.5)

Vote:
 

Hi,

When createing/updating nodes and entries from code how do you specify what language version you want to update?

I have the following code,

-------------

var productNode = _contentRepository.GetDefault<Core.Models.MetaData.ProductNode>(parentReference);
productNode.Name = _catalogRepository.GetSafeProductName(name);
productNode.Code = code;
productNode.DisplayName = name;
return _contentRepository.Save(productNode, SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

-------------

and that creates the node and sets the english "DisplayName" property to name but the catalog also supports germany, how do I set the german DisplayName property? Same with entries but I suspect that the code is the same for the two?

/Viktor

#78841
Dec 04, 2013 10:49
Vote:
 

Any information on this or is it impossible?

/Viktor

#79125
Dec 10, 2013 8:56
Vote:
 

The contentrepository for comerce should work just like cms.  So if you whatever languange branch you are working in should be the one that is updated.  

#79192
Dec 10, 2013 20:01
Vote:
 

Load the content in the second language you want to edit, clone, update and save:
var productNodeGerman = _contentRepository.Get<Core.Models.MetaData.ProductNode>(contentLink, new LanguageSelector("de"));
productNodeGerman = (Core.Models.MetaData.ProductNode)productNodeGerman.CreateWriteableClone();
productNodeGerman.Name = "Deutsch";
_contentRepository.Save(productNodeGerman, SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

This is somewhat different from CMS where you have to create the language version. In commerce all languages are immediately available (but with empty property values) so you skip that step and work like you would do the second time you edit content in CMS.

#79193
Dec 10, 2013 20:14
Vote:
 

Thanks!

/Viktor

#79211
Dec 11, 2013 8: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.