Skip to content

Sorting a product collection

Looking for setup prerequisites, authentication details, and package references? Start with the PHP SDK landing page.

When using your own search engine and you want to get a personalized sorting of a collection of Products, you can use SortProducts.

Before going any further, read about handling different types of users here.

php
$recommender = new Recommender(
    "00000000-0000-0000-0000-000000000001",
    "your API Key"
);
$recommender->serverUrl = "the server URL for the dataset";

$productIds = array("p-1", "p-2", "p-3");

$request = SortProductsRequest::create(
    Language::create("da"),
    Currency::create("DKK"),
    "Product Listing Page",
    $this->getUser(),
    $productIds
);

$response = $recommender->sortProducts($request);

The recommended way of using Relewise for category pages is using our search features. Read about how to use our Search API for category pages here.

Don't know us? Don't worry - you can find more information about us, by visiting our main page www.relewise.com