1. Go to this page and download the library: Download bradsearch/search-sync-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bradsearch / search-sync-sdk example snippets
use BradSearch\SyncSdk\Config\SyncConfig;
use BradSearch\SyncSdk\SynchronizationApiSdk;
use BradSearch\SyncSdk\Models\FieldConfigBuilder;
// Create configuration
$config = new SyncConfig(
baseUrl: 'https://your-api-endpoint.com',
authToken: 'your-auth-token',
timeout: 30, // total request timeout, seconds
connectTimeout: 10, // connection-establishment timeout, seconds
verifySSL: true
);
// Define field configuration
$fieldConfiguration = FieldConfigBuilder::ecommerceFields();
// Or build custom fields:
// $fieldConfiguration = [
// 'title' => FieldConfigBuilder::textKeyword(),
// 'price' => FieldConfigBuilder::keyword(),
// 'categories' => FieldConfigBuilder::hierarchy(),
// ];
// To add custom fields or override existing default ecommerce field config with custom values:
// $variants = ['material'];
// #fieldConfiguration = FieldConfigBuilder::addToEcommerceFields($variants);
// Initialize SDK
$syncSdk = new SynchronizationApiSdk($config, $fieldConfiguration);
// Create an index
$syncSdk->createIndex('my-product-index');
// Create an index with locales
$syncSdk->createIndex('my-product-index', ['en', 'fr', 'de']);
// Delete an index
$syncSdk->deleteIndex('my-product-index');