E commerce 在Kentico中以编程方式注入翻译后的产品时出错,是否正确?
有关信息,我已经安装了一个新版本的Kentico v12,我使用的是基本的goat模板 我有一个Web服务中的产品列表(这是我的真实来源),我想注入其中 肯蒂科的后台办公室 从Web服务接收的产品与翻译时使用的语言相关。 如果我有两种语言,比如说荷兰语和法语,我会得到每种产品两次 实例: 假设我的Web服务只有一种产品,但可以识别两种语言,当我使用它时,我将收到两种产品E commerce 在Kentico中以编程方式注入翻译后的产品时出错,是否正确?,e-commerce,kentico,E Commerce,Kentico,有关信息,我已经安装了一个新版本的Kentico v12,我使用的是基本的goat模板 我有一个Web服务中的产品列表(这是我的真实来源),我想注入其中 肯蒂科的后台办公室 从Web服务接收的产品与翻译时使用的语言相关。 如果我有两种语言,比如说荷兰语和法语,我会得到每种产品两次 实例: 假设我的Web服务只有一种产品,但可以识别两种语言,当我使用它时,我将收到两种产品 ProductId:1,语言:NL,名称:NameTranslatedInDutch ProductId:1,语言:FR,名
- ProductId:1,语言:NL,名称:NameTranslatedInDutch
- ProductId:1,语言:FR,名称:NameTranslatedFrench
// I search all documents related to the ProductId received from the webservice
var document = DocumentHelper
.GetDocuments()
.OnSite("Goat")
.Culture(facet.Language)
.Path("/", PathTypeEnum.Children)
.Where(
new WhereCondition(
"DocumentName",
QueryOperator.Equals,
facet.ProductId))
.FirstOrDefault();
// If it already exists I only have to update it
if (document != null)
{
UpdateProductTreeNode(facet, document);
}
// Otherwise i need to insert a new culture version
else
{
// I search for the first possible version for my product
var baseDocument = (SKUTreeNode)DocumentHelper
.GetDocuments()
.OnSite("Goat")
.Path("/", PathTypeEnum.Children)
.Where(
new WhereCondition(
"DocumentName",
QueryOperator.Equals,
facet.ProductId))
.FirstOrDefault();
// I'm sure it's not null, i've already checked it above but didn't copy/paste this part
baseDocument.InsertAsNewCultureVersion(facet.Language, true); // Exception occurs here
var newDocument = DocumentHelper
.GetDocuments()
.OnSite("Goat")
.Culture(facet.Language)
.Path("/", PathTypeEnum.Children)
.Where(
new WhereCondition(
"DocumentName",
QueryOperator.Equals,
facet.ProductId))
.FirstOrDefault();
UpdateProductTreeNode(facet, newDocument);
}
我做错什么了吗?
我应该换一种方式吗
遗憾的是,更新从Web服务接收的数据结构不是一个选项
我的代码质量不是很好,但它并不相关,我正在做一个概念验证,一旦我确信它能工作,质量就会得到提高^^
我遵循了这些教程:
baseDocument.InsertAsNewCultureVersion(facet.Language,true)
if(baseDocument!=null) { baseDocument.SetValue(“产品名称”、“产品名称”) }
baseDocument.InsertAsNewCultureVersion(facet.Language,true)
让我知道这是否有效 多谢各位!这样我就打开了锁:)不客气!很乐意帮忙。