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);

// INJECT SAMPLE render-items BEGIN
RenderItems(response);
// INJECT SAMPLE END
C# source code on Github: CategoryListingController.cs
// Below is an example of a request - response cycle of a category listing request

GetEntitiesByAttributeRequest request = new GetEntitiesByAttributeRequest("Category", categoryName);
request.resultsOptions.skip = 0;
request.resultsOptions.take = 9;

GetEntitiesByAttributeResponse response = loop54Client.getEntitiesByAttribute(request);
// INJECT SAMPLE render-items BEGIN
renderItems(response);
// INJECT SAMPLE END
Java source code on Github: CategoryListingController.java
// Below is an example of a request - response cycle of a category listing request
var response = client.getEntitiesByAttribute("Category", categoryName, {skip: 0, take:9}).then((r) => {
    var data = r.data
    // INJECT SAMPLE render-items BEGIN
    renderItems(data);
    // INJECT SAMPLE END
  }
);
JavaScript source code on Github: categorylisting.js
/* Configure a request to get the 9 first items in the Meat category */
$request = $connector->getEntitiesByAttribute('Category', 'Meat');
$request->resultsOptions()
    ->skip(0)
    ->take(9);

/* Actually perform the request */
$response = $connector->query($request);

/* Print all results in this response. */
echo 'Items in category:' . PHP_EOL;
foreach ($response->getResults() as $entity) {
    $id = $entity->getId();
    $title = $entity->getAttribute('Title');
    echo $id . ': ' . $title . PHP_EOL;
}
PHP source code on Github: Simple.php