0
我已經定義了使用相同層次但不同佈局的分支的數量。 我正在從外部源導入數據並以編程方式在存儲桶中創建項目。我獲得參考,以適當的分支基於某種邏輯我用下面的代碼來創建並添加一個分支項目到我的水桶:一旦我向桶中添加了一個項目,如何修改分支的子項目?
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);
填補我的分支子節點,並注意到這條新聞正確填寫... 任何幫助表示讚賞