Sitecore 在我将项目添加到bucket中后,如何修改分支的子项目?

Sitecore 在我将项目添加到bucket中后,如何修改分支的子项目?,sitecore,sitecore8,sitecore7.2,Sitecore,Sitecore8,Sitecore7.2,我已经定义了使用相同层次结构但不同布局的分支数。 我从外部源导入数据,并以编程方式在bucket中创建项。我根据一些逻辑获得对正确分支的引用,并使用以下代码创建分支项目并将其添加到我的bucket中: BranchItem branch = News.GetNewsBranchItem(item.Genre); if (branch == null) { Sitecore.Diagnostics.Log.Error(string.Format("Missing branch for {}

我已经定义了使用相同层次结构但不同布局的分支数。 我从外部源导入数据,并以编程方式在bucket中创建项。我根据一些逻辑获得对正确分支的引用,并使用以下代码创建分支项目并将其添加到我的bucket中:

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);
然后我想访问branch first child,它实际上是我想填充数据并完成操作的新闻项:

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);
并注意到新闻条目被正确填充。。。
感谢任何帮助

在漫长的一天之后已经很晚了,所以我在上面发布了一个愚蠢的问题。 下面的代码返回新闻项而不是分支项:

Item newlyCreatedBranch = parent.Add(ItemUtil.ProposeValidItemName(item.Title), branch);
一旦我考虑了退回的物品,我想要填充的物品问题就解决了。 注释代码不是必需的:

Item newsItem = parent.Add(ItemUtil.ProposeValidItemName(item.Title), branch);
//Item newsItem = newlyCreatedBranch.Children[0];