BatteryIncluded PHP SDK

The official PHP SDK for BatteryIncluded. It syncs your products and content to a BatteryIncluded collection and gives you typed access to search, suggestions, recommendations and more.

$apiClient = new ApiClient(new CurlHttpClient(), 'https://api.batteryincluded.io/api/v1/collections/', $collection, $apiKey);

// 1. sync a product
$product = new ProductBaseDto('1002');
$product->setName('Ultra HD LED TV 65"');
$product->setPrice(699);
(new SyncService($apiClient))->syncOneOrManyElements($product);

// 2. search for it
$searchStruct = new BrowseSearchStruct();
$searchStruct->setQuery('TV');
$result = (new BrowseService($apiClient))->browse($searchStruct);

foreach ($result->getHits() as $hit) {
    echo $hit['document']['_PRODUCT']['name'];
}

What’s inside

Topic Classes
Getting started ApiClient, CurlHttpClient, HttpClientInterface
Syncing documents ProductBaseDto, BlogBaseDto, SyncService
Translations (i18n) addTranslation(), I18nResolver
Availability setAvailability(), AvailabilityResolver
Backend configuration Filterable fields, filters, suggest fields, relevance
Search & filters BrowseService, BrowseSearchStruct, BrowseResponse, facets, extensions
Suggestions SuggestService, SimilarSearchService, HighlightsService
Recommendations RecommendationsService, CartRecommendationsService, PresetsService
Demo shop A complete storefront built with the SDK
Development Tests, code style, static analysis

For AI coding agents

Let your agent read llms-full.txt: installation, sync, translations, portal configuration, search, suggestions and a verification checklist in one file. llms.txt lists all pages of this documentation.

Requirements

  • PHP 8.2 or higher with the curl and mbstring extensions
  • A BatteryIncluded collection and its API key

The API reference documents all endpoints the SDK talks to.