Request Parameters | Setters and Adders - findologic/findologic-api GitHub Wiki

Description

Usually parameters are manually parsed and validated, just to be later put together to an string that contains the URL with query parameters. With this library everything regarding the setting of parameters is abstracted into own functions.

Implementation

For each query parameter there are setters and adders. Setters will override any existing values and "adders" are arrays that can have multiple values, where adding multiple values, will not override any existing ones.
For example adding the parameter attrib multiple times will result in a query like ?attrib[specials][0]=Sales&attrib[cat][0]=Women.
All available Setters/Adders can be found below.

Examples

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest
    ->setQuery('shirt')
    ->addAttribute('Color', 'Blue')
    ->addAttribute('Size', 'XL')

// ...send request...

Available Setters/Adders

Please note that some URLs may not be 100% accurate to keep the examples as simple as possible.

setShopkey($value)

  • Required for: none*
  • Parameters:
    • $value: string String containing a valid shopkey, uppercased.
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Sets the shopkey param. It is used to determine the service. The shopkey param is set by default (from the provided config). Only override this param if you are 100% sure you know what you're doing.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setShopkey('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
// Results in https://service.findologic.com/?shopkey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

// ...send request...

setShopUrl($value)

  • Required for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Parameters:
    • $value: string String containing the shop's URL.
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Sets the shopurl param. It is used to determine the service's url.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setShopUrl('www.shop.blubbergurken.io/');
// Results in https://service.findologic.com/?shopurl=www.shop.blubbergurken.io%2F

// ...send request...

setQuery($value)

  • Required for:
    • SuggestionRequest
  • Parameters:
    • $value: string String containing the user's query.
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Sets the query param. It is used as search query.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$suggestionRequest = new SearchRequest();
$suggestionRequest->setQuery('oberlenker');
// Results in https://service.findologic.com/?query=oberlenker

// ...send request...

setCount($value)

  • Required for: none
  • Parameters:
    • $value: int Integer containing the count.
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Sets the count param. It is used to set the number of products that should be displayed.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$suggestionRequest = new SuggestRequest();
$suggestionRequest->setCount(21);
// Results in https://service.findologic.com/?count=21

// ...send request...

addGroup($value)

  • Required for: none
  • Parameters:
    • $value: string String containing the user's group (not usergroup).
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Adds the group param. It is used to show only products for one or more specific groups.
  • FINDOLOGIC Documentation

Usage

//  ...initialization...

$suggestionRequest = new SuggestRequest();
$suggestionRequest->addGroup('Foo')->addGroup('Bar');
// Results in https://service.findologic.com/?group[0]=Foo&group[1]=Bar

// ...send request...

addIndividualParam($key, $value, $method)

  • Required for: none
  • Parameters:
    • $key: string String containing the parameter key.
    • $value: mixed Mixed value containing the parameter value.
    • $method: string To add the value use Request::ADD_VALUE and to set the value use Request::SET_VALUE.
  • Available for:
    • SearchRequest
    • NavigationRequest
    • SuggestionRequest
  • Description: Adds an own param to the parameter list. This can be useful if you want to put some special key value pairs to get a different response from FINDOLOGIC. Using this method is not recommended, as no validation takes place. If you think any parameter is missing for doing FINDOLOGIC requests, please create an issue before using this method.

Usage

//  ...initialization...

$suggestionRequest = new SuggestRequest();
$suggestionRequest->addIndividualParam('Foo', 'Bar', Request::SET_VALUE)
    ->addIndividualParam('Foo', 'Bar', Request::ADD_VALUE);
// Results in https://service.findologic.com/?Foo[0]=Bar&Foo[1]=Bar

// ...send request...

setUserIp($value)

  • Required for:
    • SearchRequest
    • NavigationRequest
  • Parameters:
    • $value: string String containing the user's IP address.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Sets the userip param. It is used for billing and for the user identifier.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setUserIp('127.0.0.1');
// Results in https://service.findologic.com/?userip=127.0.0.1

// ...send request...

setReferer($value)

  • Required for:
    • none
  • Parameters:
    • $value: string String containing the user's referer address.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Sets the referer param. It is used to determine on which page a search was fired.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setReferer('https://blubbergurken.io/sale');
// Results in https://service.findologic.com/?referer=https%3A%2F%2Fblubbergurken.io%2Fsale

// ...send request...

setRevision($value)

  • Required for:
    • SearchRequest
    • NavigationRequest
  • Parameters:
    • $value: string String containing the version number of your API wrapper.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Sets the revision param. It is used to identify the version of the plugin. Can be set to 1.0.0 if you are not sure which value should be passed to the API.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setRevision('8.2.1');
// Results in https://service.findologic.com/?revision=8.2.1

// ...send request...

addAttribute($filterName, $value, $specifier)

  • Required for: none
  • Parameters:
    • $filterName: string String containing the chosen filter name.
    • $value: mixed Mixed value containing the chosen filter value.
    • $specifier: null|string Optional string that is used for sliders such as price. Can be either 'min' or 'max'.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the attrib param. It is used to filter the search results.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->addAttribute('cat', 'Men')
    ->addAttribute('price', 5.0, 'min')
    ->addAttribute('price', 10.71, 'max');
// Results in https://service.findologic.com/?attrib[cat][0]=Men&attrib['price']['min']=5.0&attrib['price']['max']=10.71

// ...send request...

setOrder($value)

  • Required for: none
  • Parameters:
    • $value: string String that contains the order how the results should be ordered.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Sets the order param. It is used to set the order of the products. Please use the given OrderType for setting this value. E.g. OrderType::RELEVANCE for the FINDOLOGIC relevance.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setOrder(OrderType::TOP_SELLERS_FIRST);
// Results in https://service.findologic.com/?order=salesfrequency%20DESC

// ...send request...

addProperty($value)

  • Required for: none
  • Parameters:
    • $value: string String value containing the property that should be returned additional to the response.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the properties param. If set the response will display additional data that was exported in this column.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->addProperty('ordernumber')
    ->addAttribute('extraColumn');
// Results in https://service.findologic.com/?properties[0]=ordernumber&properties[1]=extraColumn

// ...send request...

addPushAttrib($value)

  • Required for: none
  • Parameters:
    • $key: string String value containing the filter name that should be pushed.
    • $value: string String value containing the filter that should be pushed.
    • $factor: string Float value containing the factor of how much the filter should be pushed.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the pushAttrib param. It is used to push products based on their attributes and the factor.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->addPushAttrib('Color', 'Black', 2.1)
    ->addPushAttrib('cat', 'Men', 1.3)
    ->addPushAttrib('vendor', 'Nike', 2.4);
// Results in https://service.findologic.com/?pushAttrib[Color][Black][0]=2.1&pushAttrib[cat][Men][1]=1.3&pushAttrib[vendor][Nike][2]=2.4

// ...send request...

setFirst($value)

  • Required for: none
  • Parameters:
    • $value: int Integer value containing the first product that should be shown.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the first param. It is used for pagination between pages. If your count is for example 20 and you switch to the second page, set this parameter to 20 --> the first product on the next page. Do not set the parameter to 21, because the product listing is 0-based.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setFirst(20);
// Results in https://service.findologic.com/?first=20

// ...send request...

setIdentifier($value)

  • Required for: none
  • Parameters:
    • $value: string String value containing ID of the product that should be shown.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the identifier param. It is used to display only the item that is given. If this param is set, the query param is being ignored by FINDOLOGIC.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setIdentifier('ABCD-1234');
// Results in https://service.findologic.com/?identifier=ABCD-1234

// ...send request...

addOutputAttrib($value)

  • Required for: none
  • Parameters:
    • $value: string String value containing parameter that should be available in the template.
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the identifier param. It is used to add given attributes to the template.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->addOutputAttrib('ordernumber')
    ->addOutputAttrib('somethingElse');
// Results in https://service.findologic.com/?outputAttrib[0]=ordernumber&outputAttrib[1]=somethingElse

// ...send request...

setForceOriginalQuery()

  • Required for: none
  • Parameters:
    • none
  • Available for:
    • SearchRequest
    • NavigationRequest
  • Description: Adds the forceOriginalQuery param. It is used for Smart Did-You-Mean. If called, the Smart Did-You-Mean functionality is disabled and the search results are based on the user's query.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SearchRequest();
$searchRequest->setForceOriginalQuery();
// Results in https://service.findologic.com/?forceOriginalQuery=1

// ...send request...

addAutocompleteBlocks($value)

  • Required for: none
  • Parameters:
    • $value: string String value containing the autocomplete block that should be displayed.
  • Available for:
    • SuggestRequest
  • Description: Adds the autocompleteblocks param. It allows overriding the blocks that are configured to be displayed in the customer-login. As value use the BlockType class. For example BlockType::SUGGEST_BLOCK.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SuggestRequest();
$searchRequest->addAutocompleteBlocks(BlockType::SUGGEST_BLOCK)
    ->addAutocompleteBlocks(BlockType::CAT_BLOCK)
    ->addAutocompleteBlocks(BlockType::PROMOTION_BLOCK);
// Results in https://service.findologic.com/autocomplete.php?autocompleteblocks[0]=suggest&autocompleteblocks[1]=cat&autocompleteblocks[2]=promotion

// ...send request...

setUsergrouphash($value)

  • Required for: none
  • Parameters:
    • $value: string String value containing the usergroup hash.
  • Available for:
    • SuggestRequest
  • Description: Adds the usergrouphash param. It indicates which usergroup's products are used for generating suggestions. This parameter is only relevant in case usergroup information is exported.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SuggestRequest();
$searchRequest->setUsergrouphash('IEJvQVhFVlVh');
// Results in https://service.findologic.com/autocomplete.php?usergrouphash=IEJvQVhFVlVh

// ...send request...

setMultishopId($value)

  • Required for: none
  • Parameters:
    • $value: int Integer value containing the multishop id.
  • Available for:
    • SuggestRequest
  • Description: Adds the multishop_id param. Required for PlentyMarkets shops. Has no effect for other shop systems.
  • FINDOLOGIC Documentation for this parameter.

Usage

//  ...initialization...

$searchRequest = new SuggestRequest();
$searchRequest->setMultishopId(5);
// Results in https://service.findologic.com/autocomplete.php?multishop_id=5

// ...send request...

Notes

  • [ * ] Is set automatically by the config, but would otherwise be a required value.