Delete Records from Index
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.
To delete records from the Klevu indexes, first locate your Klevu API and REST AUTH keys and create an AccountCredentials object (see Quickstart for steps).
Next, retrieve the IDs used to index any records you wish to delete.
Important: the ID must match the value used when adding the record initially.
As records of all types (KLEVU_PRODUCT, KLEVU_CATEGORY, etc) share an ID pool, you should implement a naming convention to differentiate records whose IDs would otherwise clash (for example, sending a product and a category, both with ID 1)
Create a new Indexing\Batch\DeleteService object and call the sendByIds method with the array of IDs collated previously, catching and handling any exceptions thrown during execution.
At this point, you will have an ApiResponseInterface which can be checked for success status, as well as any errors returned by the Klevu API.
Alternatively, if you RecordInterface(s) already created, you can pass these to Batch\DeleteService::send . Records passed to send only require an id property.