Convert Sitecore items into an Sitecore Item Bucket

What are Item Buckets in Sitecore?

Everything is an item in the Sitecore content tree. An item bucket is a content repository inside Sitecore content tree that can store other content items. The major difference between the normal items and item buckets in the content tree is that Sitecore item buckets can store an unlimited amount of items theoretically without displaying in the content tree.

Benefits of Item Buckets in Sitecore

  1. All the items in the Item Buckets are hidden by default which helps the content tree to be faster.
  2. By Default, all the items inside item buckets are automatically organized in a logical format so that the performance of the search engine increases.
  3. An item bucket can hold millions of item without slowing down the UI performance and content tree loading.
  4. You could have unlimited item buckets in your project. Make sure you split the item buckets logically.
  5. You do not have to write any extra logic or code to fetch items from item buckets.
  6. Sitecore has an API to make any Sitecore item bucketable programmatically.

When to use an Sitecore Item Buckets?

An item bucket addresses the problem of managing large no of items in a content tree. So to decide if you want to use item buckets or not you should look at the content tree structure and if you feel it is best to hide all the descendants of the item in the structure you should opt for item buckets.

How to Configure Item Buckets in Sitecore?

There is basically two way of configuring Item buckets in Sitecore.

Configure Item Bucket at Item Level

You can create an item bucket from a new content item or convert an existing item structure into an item bucket. To Create, an Item Bucket at item level follows the below Steps

  1. Click on the item for which you need to make it bucketable
  2. Click the Configure tab and then in the Buckets group, click Bucket to convert the new item into an item bucket.
How To Configure Item Buckets In Sitecore

Configure Item Bucket at Template Level

Making a Template Bucketable If you have a large number of similar content items that you want to hide in an item bucket, it makes more sense to make the template that they are based on bucketable. To make a template bucketable:

  1. In the Content Editor, on the View tab, in the View group, select the Standard Fields check box.
  2. Select one of the content items that you want to make bucketable.
  3. In the right-hand pane, on the Content tab, expand the Quick Info section.
  4. Click the template link and the template that this content item is based on opens in the Template Manager.
  5. In the Template Manager, in the content tree, expand the template in question and select the _Standard Values item.
  6. In the right-hand pane, click the Content tab.
  7. Scroll down and expand the Item Buckets section.
  8. Select the check box for Bucketable – Can be stored as an unstructured item in an item bucket.
  9. Save your changes. After you have made the template bucketable, you must synchronize every item bucket that contains content items that are based on this bucketable container. This updates their structure and hides the bucketable items.
  10. In the Content Editor, select the item bucket folder that contains items based on this template.
  11. On the Configure tab, in the Buckets group, click Sync
How To Configure Sitecore Item Buckets In Sitecore At Template Level

How to make Sitecore item bucketable programmatically?

using Sitecore.Buckets.Extensions;

public static void CovertToBucketItem(Item SubFolderItem)
{ 
    Sitecore.Buckets.Managers.BucketManager.CreateBucket(SubFolderItem);
    using (new Sitecore.Data.Items.EditContext(SubFolderItem, SecurityCheck.Disable))
    {
        if (!IsBucketItemCheck(SubFolderItem))
        {
            IsBucketItemCheckBox(SubFolderItem).Checked = true;
        }
    }
}
public static bool IsBucketItemCheck( Item item)
{
    return (((item != null) && (item.Fields[Sitecore.Buckets.Util.Constants.IsBucket] != null)) && item.Fields[Sitecore.Buckets.Util.Constants.IsBucket].Value.Equals("1"));
}

public static CheckboxField IsBucketItemCheckBox( Item item)
{
    return item.Fields[Sitecore.Buckets.Util.Constants.IsBucket];
}

All subitems can be added to SubFolderItem in the usual way.

SubFolderItem.Add(SubItemName,SubItemTemplate)

Make sure that template Standard Value for Subitems have the field Bucketable checked

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like