Skip to content

Product Category Search with our PHP client

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

Start by making a Searcher-instance.

php
use Relewise\Searcher;
// You have to `use` the above to create a Searcher.

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

To make requests with the SDK you need to use the types from our PHP SDK. The types are located in the namespace Relewise\Models and an example of using a concrete type could be the following:

php
use Relewise\Models\ProductSearchRequest;

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

Also remember to specify your Server URL in your request.

The following shows an example on how to perform a product category search:

php

$searcher = new Searcher(
    '00000000-0000-0000-0000-000000000001',
    'your API Key'
);
$searcher->serverUrl = 'the server URL for the dataset';

$request = ProductCategorySearchRequest::create(
    new Language("da"),
    new Currency("DKK"),
    UserFactory::anonymous(),
    "Location",
    null,
    0,
    30
);

$request->setSettings(
    ProductCategorySearchSettings::create()->setSelectedCategoryProperties(
        SelectedProductCategoryPropertiesSettings::create()
            ->setDisplayName(true)
            ->setPaths(true)
            ->setDataKeysFromArray(["Description", "ImagePath"])
        )
    );

$response = $searcher->productCategorySearch($request);

By using SelectedCategoryProperties it is possible to select the specific properties, from Relewise, that you need for rendering a category tile, list etc. That way we can store fields that are needed for e.g. filtering or Merchandising, but which might not be needed when rendering the actual product. This allows us to reduce the payload on the HTTP responses, by only returning a minimum set of necessary information.

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