Integration Guides
OpenCart Integration
Install the official SearchX extension from your OpenCart admin panel.
Overview
The SearchX extension is the recommended way to integrate SearchX with OpenCart. Once installed and configured from the admin panel, it automatically:
- Replaces the native search bar and search results page with the SearchX widget.
- Injects the SDK and preload hints on every storefront page — no template files to edit.
- Handles Add to Cart and Add to Wishlist directly, using OpenCart's own cart API.
- Auto-detects your active theme (Journal 3, So-eMarket, and the default OpenCart theme are supported out of the box).
You can enable, disable, or update credentials at any time from the admin panel without touching any files.
Requirements
OpenCart 3.0.3.x (PHP 5.5+) or 4.x (PHP 8.1+), plus administrator access to your OC admin panel. Grab your App ID and API Key from the SearchX dashboard before you start.
If your theme isn't auto-detected yet, or you don't have access to the extension installer, see Manual Integration below.
Step 1: Download the extension
- Open your application in the SearchX dashboard and go to the Details tab.
- Scroll to Install JS Snippet and select the OpenCart tab.
- Download the package that matches your store version:
- OpenCart 4.x →
searchx.ocmod.zip - OpenCart 3.x →
searchx-oc3.ocmod.zip
- OpenCart 4.x →
You can also find SearchX by searching the OpenCart Marketplace and installing it from there.
Filename matters
Upload only the original downloaded file. If your browser saves a duplicate as searchx.ocmod (1).zip, delete it and re-download — OpenCart validates the filename and silently rejects anything that doesn't end in exactly .ocmod.zip.
Step 2: Upload and apply the package
- In your OC admin, go to Extensions → Installer.
- Click Upload and select the zip file you downloaded.
- Wait for the success message — SearchX now appears in the Installer list.
- Click the green Install (+) button next to SearchX to extract and register the files.
OpenCart 3 only: one extra step
After installing, go to Extensions → Modifications and click the Refresh button (yellow arrow icon). This applies a small OCMOD patch to OpenCart's router so dot-notation routes (used by the wishlist API) resolve correctly. Skip this step on OpenCart 4.
Step 3: Install the module
Go to Extensions → Extensions and filter the type dropdown to Modules.
Find SearchX in the list and click Install (+).
The extension shows as Disabled at this stage — that's expected. You'll enable it in the next step.
Click the Edit (pencil) button next to SearchX to open its settings page.
Step 4: Configure credentials
Fill in the settings form and save.
| Field | What to enter |
|---|---|
| App ID | Your SearchX App ID, from the application's Details tab. |
| API Key | Your SearchX API Key, from the application's API Keys tab. |
| Platform | opencart or custom — see Platform Setting below. |
| Custom CSS URL | Optional. Path to a CSS file for custom styling. See Widget Styling. |
| Search Page URL | Optional. Defaults to /index.php?route=product/search&search={query}. Only change this if your store uses custom SEO URLs for search. |
| Locale URL | Optional. Path to locale JSON files with a {{lng}} placeholder, for multi-language stores. |
| Status | Set to Enabled when you're ready to go live. |
Click Save (floppy disk icon, top-right) when you're done.
Step 5: Clear the cache and verify
OpenCart caches compiled templates, so clear the cache before checking the storefront:
- Go to your admin Dashboard.
- Click the blue circular Refresh button in the top-right of the statistics area.
Then do a hard refresh on your storefront (Cmd/Ctrl + Shift + R). You should see:
- The SearchX search bar in place of the native search input.
- Instant suggestions as you type.
- The full SearchX results page at your search route.
- Add to Cart / Add to Wishlist updating without a page reload.
If something looks wrong, confirm Status is Enabled and your credentials are saved correctly, then check the browser console for messages prefixed [SearchX].
Platform Setting
The Platform field controls how Add to Cart and Add to Wishlist resolve products, and depends on what your SearchX product feed uses as unique_id:
| Platform | When to use | How it works |
|---|---|---|
custom (default) | Your feed's unique_id is a SKU. | The extension looks up the SKU against oc_product to resolve the numeric product_id, then adds it to the cart. |
opencart | Your feed's unique_id is the numeric OpenCart product_id. | Used directly — no lookup step needed. |
A platform mismatch breaks Add to Cart silently, so double-check which identifier your feed exports before going live.
For non-extension integrations, see Event Handling for the equivalent platform SDK setting.
Theme Support
The extension auto-detects your active theme — no configuration needed:
| Theme | Search box selector |
|---|---|
| Journal 3 | #search.dropdown |
| So-eMarket | #search.input-group |
| Default OpenCart theme | #search |
Theme detection is served from the SDK, so support for new themes ships as a CDN update — you don't need to reinstall or upgrade the extension.
Updating, Disabling, and Uninstalling
- Update credentials: Extensions → Extensions → Modules → SearchX → Edit, change the fields, and save. No cache clear needed for credential-only changes.
- Disable temporarily: Same settings page, set Status to Disabled, save, and clear the template cache. The native search bar returns immediately; all settings are preserved.
- Uninstall: Extensions → Extensions → Modules, click Uninstall next to SearchX. This removes the event hooks and saved settings; the extension files stay on the server until you delete the
extension/searchx/folder (OC4) or the files copied by the installer (OC3).
Manual Integration
If you can't use the extension — for example, your theme isn't auto-detected yet and you need custom mount points — you can integrate SearchX by editing three template files directly.
Step 1: Configure Footer & Initialization
Add the SDK scripts and initialization to your footer template.
File: catalog/view/template/common/footer.twig
<!-- SearchX SDK Dependencies (React 18) -->
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- SearchX SDK Core -->
<script src="https://sdk.searchxengine.ai/searchx-sdk.umd.js"></script>
<script>
(function () {
var storedLang = localStorage.getItem('searchx_lang') || 'en';
window.SEARCHX_LANG = storedLang;
function initSearchX() {
if (!window.SearchXSDK) {
console.warn('SearchX SDK not loaded yet.');
return;
}
window.SearchXSDK.init({
app_id: 'YOUR_APP_ID',
api_key: 'YOUR_API_KEY',
components: {
SearchBar: { root: 'search-bar' },
SearchPage: { root: 'search-page' },
},
customCSSUrl: '/catalog/view/stylesheet/custom/client-theme.css',
customLocaleUrl: '/catalog/view/stylesheet/custom/locales/' + storedLang + '.json',
defaultLanguage: storedLang,
settings: {
// Layout & behaviour
platform: 'opencart',
compactPagination: true,
defaultProductsPerPage: 24,
// Search bar popup
showPopupAddToCart: true,
showPopupSearchIcon: true,
// Product cards
showBrand: true,
showSizes: true,
showColor: true,
showAddToCartButton: true,
wishlistEnabled: true,
// Filter sidebar
showBrandFacet: true,
showCategoryFacet: true,
showPriceRangeFilter: true,
showSizeFilter: true,
showColorFilter: true,
},
});
window.dispatchEvent(new Event('searchx:ready'));
window.searchxReady = Promise.resolve();
}
if (window.SearchXSDK) {
initSearchX();
} else {
window.addEventListener('load', initSearchX);
}
})();
</script>
Language Persistence
The integration stores the user's selected language in localStorage under the key searchx_lang. This ensures the search widget respects the user's language preference across page navigations.
Step 2: Search Bar Integration
Replace your existing search input with the SearchX container.
File: catalog/view/template/common/search.twig
<div id="search-bar" class="searchx-bar-container"></div>
<script>
(function () {
function mountSearchBar() {
if (window.SearchXSDK && window.SearchXSDK.mount) {
if (document.getElementById('search-bar')) {
SearchXSDK.mount('Searchbar', { root: 'search-bar' });
}
}
}
if (window.searchxReady) {
mountSearchBar();
} else {
window.addEventListener('searchx:ready', mountSearchBar);
}
})();
</script>
Step 3: Search Results Page
Update your search results template to use SearchX.
File: catalog/view/template/product/search.twig
Add the SearchX container inside your content area. Use Twig's header and footer includes as usual, and place the SearchX container where the default product listing loop was:
<div id="content" class="container">
<!-- Your existing breadcrumbs here -->
<!-- SearchX Results Container -->
<div id="search-page" class="searchx-page-container"></div>
</div>
<script>
(function () {
function mountSearchPage() {
var rootId = 'search-page';
if (!document.getElementById(rootId)) return;
if (window.SearchXSDK && window.SearchXSDK.mount) {
try {
SearchXSDK.mount('SearchPage', { root: rootId });
} catch (err) {
console.error('SearchX: Failed to mount SearchPage', err);
}
}
}
document.addEventListener('DOMContentLoaded', function () {
if (window.searchxReady) {
mountSearchPage();
} else {
window.addEventListener('searchx:ready', mountSearchPage);
}
});
})();
</script>
When integrating manually, set the platform setting to "opencart" to enable OpenCart-specific Add to Cart behavior via its native API routes. For more details, see Event Handling.
Next Steps
- Customize the widget appearance with Widget Styling.
- Set up custom translations with Localization.