Ben Sewards
Ben Sewards

Reputation: 2661

Using the BucketManager in Sitecore

I have a simple core library for my web app that I am using to test the Item Bucket API. I have a class of properties and methods where, for example, I would like to query through a movie item bucket in Sitecore using the properties and a constants class that stores the template IDs.

The problem I am having is when using the BucketManager class to call the static method Search(), it doesn't recognize the second param, templates:"String"

BucketManager Sitecore GetAllMovies

Has anyone had this problem before? I'm also having a BucketList problem in Sitecore where only the standard values of a template are showing a BucketList TemplateFilter source (request a screenshot if you're interested in this bug).

Upvotes: 1

Views: 1419

Answers (2)

Ben Sewards
Ben Sewards

Reputation: 2661

The Sitecore Item Bucket Developer Guide intended on excluding a non-optional parameter called out hitCount, which is an attribute that allows the paging of results. Without this parameter, I had an invalid method signature, which caused the error.

Here is the correct code:

public List<Item> GetAllMovies() {
            var hc = 0;
            return BucketManager.Search(
                MovieFolder, 
                out hc, 
                templates: Constants.Constants.TemplateIDs.MoviesItemTemplateID
            ).Select(i=> i.GetItem()).Where(i=>i != null).ToList();
        }

Also, don't forget to cast the IENumberable as a List of Items as a result.

Upvotes: 2

Andrew
Andrew

Reputation: 551

Try to add such string

using Sitecore.ItemBucket.Kernel.ItemExtensions.Axes;

Upvotes: 0

Related Questions