SaaS CMS has officially launched! Learn more now.

How to get all products?


In the CMs i can use this bit of code to gett al lpages of a certain type:

var pageTypeId = contentTypeRepository

var criteriaCollection = new PropertyCriteriaCollection
new PropertyCriteria
Condition = CompareCondition.Equal,
Name = "PageTypeID",
Type = PropertyDataType.PageType,
Value = pageTypeId.ToString(),
Required = true

return pageCriteriaQueryService.FindPagesWithCriteria(
criteriaCollection).Select(x => x as RoyaltySchemeType)

I want to be able to do the equivilant in commerce, so get all products that are of a certain type regardless of where they live int he tree... I'm guessing this is a simple one, how do I go about doign it?

Jun 29, 2015 18:26


//this.Root = e commerce root
ContentLinks = this.contentLoader.GetDescendents(this.Root),
                    Languages = this.languageBranchRepository.ListEnabled()
                        .Select(x => x.Culture)


Jun 29, 2015 18:36

Thanks for the code.  Our cataloug has somethign silly like 10,000 items in it, so this api call would take a while I guessing?  I will give it a test but prob need more somethign like CatalogEntrySearchCriteria although I have no idea how to use it  to filter on product types :(

Edited, Jun 29, 2015 18:38
CatalogEntrySearchCriteria criteria = new CatalogEntrySearchCriteria();
criteria.SearchPhrase = "fanon";
SearchManager manager = new SearchManager(AppContext.Current.ApplicationName);
SearchResults results = manager.Search(criteria);

try if this still works

Jun 29, 2015 18:41

To filter on content types, you can specify the ClassType of the CatalogEntrySearchCriteria - as Khan's answer - something like:

criteria.ClassType.Add("product"); //variation/bundle/...

If you want to filter down to the metaclass, use this:

                criteria.Add("_metaclass", new SimpleValue() { key = "_metaclass", value = <metaclass Name>});



Jun 30, 2015 0:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.