Category listings
Code examples for category listings.
Facets, Filtering and Sorting
Facets can be applied to category listings in a similar way to search. Have a look at the facets guide for more details.
Custom filtering and sorting options are also available for category listings. Have a look at the sorting and filtering guide for more details.
Example
The example shows how to list products in a category. The call is structured much like a search call and the parameters work in the same way so have a look at the explanation of search parameters if you’re unsure how they work.
Other than that, listing categories is simply a matter of calling GetEntitiesByAttribute
and supplying the name of the category that you want to list.
// Below is an example of a request - response cycle of a category listing request
var request = new GetEntitiesByAttributeRequest("Category", categoryName);
request.ResultsOptions.Skip = 0;
request.ResultsOptions.Take = 9;
var response = _loop54Client.GetEntitiesByAttribute(request);
var results = response.Results.Items;
if (!results.Any())
Debug.WriteLine("There were no items in this category.");
foreach (var resultItem in results)
{
var productId = resultItem.GetAttributeValueOrDefault<string>("Id");
var productTitle = resultItem.GetAttributeValueOrDefault<string>("Title");
Debug.WriteLine(productId + " " + productTitle);
//render a product on the category listing page
}
C# source code on Github: CategoryListingController.cs
Last updated