【发布时间】:2015-11-11 15:28:06
【问题描述】:
我已经定义了使用相同层次结构但布局不同的分支数量。 我正在从外部源导入数据并以编程方式在存储桶中创建项目。我根据一些逻辑获得对正确分支的引用,并使用以下代码创建分支项并将其添加到我的存储桶中:
BranchItem branch = News.GetNewsBranchItem(item.Genre);
if (branch == null)
{
Sitecore.Diagnostics.Log.Error(string.Format("Missing branch for {} genre!", item.Genre), this);
Sitecore.Diagnostics.Log.Error(string.Format("Failed to import import item id: {0}", item.Id.ToString()), this);
return;
}
Item newlyCreatedBranch = parent.Add(ItemUtil.ProposeValidItemName(item.Title), branch);
然后我想访问分支第一个子项,这实际上是我想要填充数据并完成操作的新闻项目:
Item newsItem = newlyCreatedBranch.Children[0];
newsItem.Editing.BeginEdit();
newsItem[SCG.BasePage2.FieldIds.MetaKeywords] = item.Keywords;
.
.
.
newsItem.Editing.EndEdit();
过程成功完成后,我确实检查了新创建的项目,并惊讶地发现我缺少内容?!
我很惊讶,因为之前我访问并填充了我的分支子节点
parent.Add(ItemUtil.ProposeValidItemName(item.Title), branch);
并注意到新闻项目已正确填写... 任何帮助表示赞赏
【问题讨论】:
标签: sitecore sitecore8 sitecore7.2