$version
$version :
The version info of the client.
The GravityClient class can be used to send events, item and user information to the recommendation engine and get recommendations.
Example usage:
function createGravityClient() { $config = new GravityClientConfig(); $config->remoteUrl = 'https://saas.gravityrd.com/grrec-CustomerID-war/WebshopServlet'; $config->user = 'sampleUser'; $config->password = 'samplePasswd'; $config->retry = 0; return new GravityClient($config); } $client = createGravityClient(); $context = new GravityRecommendationContext(); $context->numberLimit = 5; $context->scenarioId = 'HOMEPAGE_MAIN'; $context->nameValues = array( new GravityNameValue('minPrice', '100'), ); $client->getItemRecommendation('user1', '123456789abcdef', $context);
Please do not modify the GravityClient.php file (e.g. do not write your configuration parameters into the GravityClient.php file). Using an unmodified client makes version updates easier. Use your own factory function (like createGravityClient in the example above) to pass your configuration information to the GravityClient constructor.
$config : \GravityClientConfig
The client configuration.
__construct(\GravityClientConfig $config)
Creates a new client instance with the specified configuration
\GravityClientConfig | $config |
addEvent(\GravityEvent $event, $async)
Adds an event to the recommendation engine.
\GravityEvent | $event | |
$async |
addItem(\GravityItem $item, $async)
Adds an item to the recommendation engine.
If the item already exists with the specified itemId, the entire item along with its NameValue pairs will be replaced to the new item specified here.
\GravityItem | $item | |
$async |
updateItem(\GravityItem $item)
Existing item will be updated. If item does not exist Exception will be thrown.
Update rules:
\GravityItem | $item | The item to update |
updateItems(array<mixed,\GravityItem> $items)
Existing items will be updated. If item does not exist Exception will be thrown.
Update rules:
array<mixed,\GravityItem> | $items | The items to update |
addUser(\GravityUser $user, $async)
Adds user to the recommendation engine.
If the user already exists with the specified userId, the entire user will be replaced with the new user specified here.
\GravityUser | $user | |
$async |
getItemRecommendation( $userId, $cookieId, \GravityRecommendationContext $context) : \GravityItemRecommendation
Returns a list of recommended items, based on the given context parameters.
$userId | ||
$cookieId | ||
\GravityRecommendationContext | $context |
An object containing the recommended items and other information about the recommendation.
getItemRecommendationBulk( $userId, $cookieId, array $context) : array<mixed,\GravityItemRecommendation>
Given the userId and the cookieId, we can request recommendations for multiple scenarios (described by the context).
This function returns lists of recommended items for each of the given scenarios in an array.
$userId | ||
$cookieId | ||
array | $context |
An Array containing the recommended items for each scenario with other information about the recommendation.