Examples / How To
Account Management

Retrieve Klevu Account Details

6min

This guide assumes you have installed the latest version of klevu/php-sdk , either via composer or from source, and autoloading is functioning as expected.

Examples in this guide are for vanilla PHP and, as such, will use new to instantiate objects. If you are using a modern framework such as Magento or Symfony, you should utilise your object manager for dependency injection and preferencing of interfaces where possible.

Retrieving Klevu Account Information

To retrieve information about your Klevu account, first locate your Klevu API and REST AUTH keys and create an AccountCredentials object (see Quickstart for steps).

Next, instantiate an AccountLookupService object and call the execute method to create an Account model containing your account details. The execute method will throw exceptions if any issues arise, so you should catch and handle these appropriately.

At this point, you will have an Account object containing your KMC information, including endpoints which can be used for subsequent operations (such as indexing or analytics)

PHP


Retrieving Enabled Klevu Feature Flags

To retrieve information about your Klevu account, first locate your Klevu API and REST AUTH keys and create an AccountCredentials object (see Quickstart for steps).

Next, instantiate an AccountFeaturesService object and call the execute method to create an AccountFeatures model containing Klevu feature flags. The execute method will throw exceptions if any issues arise, so you should catch and handle these appropriately.

At this point, you will have an Account Features object which can be used to determine which solutions should be supported in your application.

PHP


For ease in use in your application, you can also attach the Account Features object to an existing Account model for ease of reference in your application

PHP



Source Code Reference