如何以编程方式恢复Sitecore项目桶?

时间:2017-11-20 06:38:26

标签: sitecore sitecore8

当我通过登录sitecore手动恢复项目存储桶时,它按预期工作。但是,当通过下面的代码时,会出现一个意外的短语“此包含器中有隐藏的项目”,并且通过启用存储桶复选框时,不存在子项目。

Sitecore.Buckets.Managers.BucketManager.Unbucket(项目);

Unexpected phrase 'There are hidden items in this container'

1 个答案:

答案 0 :(得分:1)

在反汇编代码中,Unbucket按钮的作用是,Unbucket(item)调用不仅仅是:

BucketManager.UnBucketItem(contextItem);
foreach (Item current in from item in contextItem.GetChildren(ChildListOptions.SkipSorting)
where item.TemplateID.ToString() == Constants.BucketFolder
select item)
{
  ItemManager.DeleteItem(current);
}

首先是unbucket项目,然后浏览剩余的存储文件夹并将其删除。