# Instant Search Quickstart
- XT Search for Algolia - PrestaShop Quickstart
- Configure Algolia Search in the PrestaShop module
- Configure the Cron Job in the PrestaShop module
- Execute the index task for products
- Configure the shop front-end module
- Configure the instant search
- Define the positions to show the module
- Choose the layout for each position
- Overriding modules
- Translating Dynamic Product Attributes
- Ready for PrestaShop
These are the essential steps to configure XT Search for Algolia.
# XT Search for Algolia - PrestaShop Quickstart
# Configure Algolia Search in the PrestaShop module
Access the general configuration, and fill the Algolia Configuration:
- Application ID
- Search-Only API Key
- Admin API Key
- Index Name
If your site is multilingual, and you want to create separate indexes, then you must enable Multilingual Indexes. At this time, Algolia automatically creates the indexes.
Save the configuration.
# Configure the product filter
The connector allows entering a list of category IDs to filter the indexed products, the Category Filter. For instance: 2,6,9.
# Configure the Cron Job in the PrestaShop module
Enter the information required to enable the cron job indexer:
Save the configuration.
# Web Front-end processing, for use with CRON
The front-end processing feature is intended to provide the capability to perform unattended, scheduled indexing on your site.
The front-end indexing URL performs a single indexing step. You will only see a message upon completion, should it be successful or not. There are a few limitations, though:
It is not designed to be run from a web browser but from an unattended CRON script, utilizing
wget or CRON as a means of accessing the function.
The script is not capable of showing progress messages.
Before beginning to use this feature, you must set up XT Search to support the front-end indexing option. First, go to XT Search's main page and click on the Component Configuration / Cron Job item. Below it, you will find the option named Base URL Override and Secret word. In that box, you have to enter a password which will allow your CRON job to convince XT Search that it has the right to publish from the call. After you are done, click the Save button on top to save the settings and close the dialog.
Most hosts offer a control panel of some kind. There has to be a section for something like "CRON Jobs", "scheduled tasks", and the like. The help screen in there describes how to set up a scheduled job.
If your host only supports entering a URL in their "CRON" feature, this will most likely not work with XT Search. There is no workaround. It is a hard limitation imposed by your host.
If you are on a UNIX-style OS host (usually, a Linux host), you most probably have access to a command-line utility called wget.
Do not forget to surround the URL in double-quotes. If you don't the command will fail, and it will be your fault! The reason is that the ampersand is also used to separate multiple commands in a single command-line. If you don't use the double-quotes at the start and end of the indexing URL, your host will think that you tried to run multiple commands and load your site's homepage instead of the front-end indexing URL.
If you are unsure, check with your host. Sometimes you have to get from them the full path to wget in order for CRON to work, thus turning the above command-line to something like:
Contact your host; they usually have a nifty help page for all this stuff. Read also the section on CRON jobs below.
wget is multi-platform command-line utility program. It is frequently included in the operating systems. The wget homepage is here: https://www.gnu.org/software/wget/wget.html (opens new window).
Other alternative commands are:
To execute the incremental indexing with the Web Front-end processing, add the paramenter
incremental=1. Check the following examples:
The ampersands above should be written as a single ampersand, not as an HTML entity (&). Failure to do so will result in a 403: Forbidden error message, and no indexing will occur. This is not a bug. It is the way wget works.
# Multi-Store Cron Job Configuration
The cron job indexes each store on a Multi-Store site separately. In this way, each store can follow different indexing strategies.
On a Multi-Store site, the cron job command must have the additional parameter
For instance, the cron job command for store 1234 can be the following command:
And, the cron job command for store 1234 and incremental indexing can be the following command:
# Multilingual Cron Job Configuration
The cron job indexes each language on a Multilingual site separately. In this way, each store can follow different indexing strategies.
On a Multilingual site, the cron job command must have the additional parameter
languages 1 and 2 can be the following commands:
And, the cron job command for languages 1 and 2 and incremental indexing can be the following command:
# Free Online CRON Schedulers
If you are still having trouble with the above options, and your hoster does not provide any Cron job support, use any online Cron job scheduler service available on the web. Do not worry about security because what these sites do is merely accessing the Url at a certain interval, which is open to anyone.
EasyCron (opens new window) is an online Cron Service.
- Trusted by the Pros.
- Save your time.
- Easy to reason about.
- Alternative to Linux Cron.
EasyCron offers a poweful set of functions:
- Standard Cron expression
- 3 ways to specify execution time
- Email Notification
- Cron Job Execution Logs
- Execution Time Prediction
- Separate Failure Logs
- Customize HTTP Method
- Customize HTTP Headers
- Powerful API
- Output Regexp Matching
- Configure Timeout
- Timezone Adaptable
- User-Friendly Interface
- No Need to Install
# Execute the index task for products
- Click on "Full Indexing"
- Visit the Indexed records in Algolia Dashboard (opens new window).
# Configure the shop front-end module
By default, the autocomplete module does not show images. If prefer to show images, fill the image field.
# Configure the instant search
The instant search can be shown as a linked feature in the autocomplete module, or the instant search can also be shown in a central page position (check the positions below).
After you configure the Algolia connection and index all records, by default, the module generates facets for each field. Additionally, you can also define new facets in the Algolia Dashboard.
After the facets definition step, you can define the facets that are going to be available in the site search in the " FRONT-END CONFIGURATION - INSTANT SEARCH / Facets" field.
On the Algolia backend, these are the configured facets (you can configure more facets than the available on the front-end):
# Configure the price Facet
price is a special facet. If you define facets with these field names
price_tax_exc, then the range filter will be automatically generated:
# Configure the Sort By widget
The Sort By widget requires the definition of the "replica" indices to sort the search results. For more information: https://www.algolia.com/doc/api-reference/widgets/sort-by/js/#about-this-widget (opens new window)
This is the configuration that is shown in the demo site with "replica" indices:
- Name, A to Z
- Name, Z to A
- Price, low to high
- Price, high to low
The definition of the Sort By field is:
NAME_A_TO_Z, NAME_Z_TO_A, LOW_TO_HIGH, HIGH_TO_LOW.
The site has two languages; two replica indices have to defined for each language. The module automatically appends the language code to the indice name. These are the defined indices, following the naming convention of indices:
- HIGH_TO_LOW_en-US, the replica indice configured with to sort by ´price_amount´ ascending
- LOW_TO_HIGH_en-US, the replica indice configured with to sort by ´price_amount´ descending
- NAME_A_TO_Z_en-US, the replica indice configured with to sort by ´name´ ascending
- NAME_Z_TO_A_en-US, the replica indice configured with to sort by ´name´ descending
- HIGH_TO_LOW_fr-FR, the replica indice configured with to sort by ´price_amount´ ascending
- LOW_TO_HIGH_fr-FR, the replica indice configured with to sort by ´price_amount´ descending
- NAME_A_TO_Z_fr-FR, the replica indice configured with to sort by ´name´ ascending
- NAME_Z_TO_A_fr-FR, the replica indice configured with to sort by ´name´ descending
This is the definition of the sorting of one of the replica indices:
The replica indices can be configured freely, so you can fully customize how the search works. Please, remember to configure the facets for each replica indice.
# Define the positions to show the module
The Autocompletion Classic module is designed to be a drop-in replacement for the "Search bar". It can be shown in the same positions.
As a reference implementation, this is how our demo site is configured on PrestaShop 1.7:
# Choose the layout for each position
The module has three possible layouts:
- Instant Search, the search module that shows a search box, facets, search results, stats, and pagination.
- Instant Search Autocomplete, the search module that shows a search box and, when the user starts typing, the facets, search results, stats, and pagination in a floating dialog.
- Autocomplete Classic, the search module that shows a search box and the search results list in a floating dialog. This module is based on the legacy Algolia API v3.
To select which widget layout must be shown in each position:
# Overriding modules
The module has several ways to customize the search templates. You can override the module
tpl files. For more information, please, the official PrestaShop documentation: Home > PrestaShop 1.7 > Themes > Reference > Overriding modules (opens new window)
There are the default templates that can be overriden:
Templates for PrestaShop 1.7:
Templates for PrestaShop 1.6:
Partial templates that can also be overriden:
To create the Smarty template overrides, note that the files must be created in the template directory
For instance, for the Classic template and the
xt_instantsearch_module.tpl, the path would be:
# Translating Dynamic Product Attributes
The labels of the dynamic product attributes are generated on-the-fly. In this way, you are free to customize the translation of the labels shown in the sidebar.
As a consequence, in the sidebar, you can find a label such as
In particular, the "Category" label is already defined in the language file:
To add other attributes of your store, you can add new lines at the end of the language file, duplicating the same Category label translation. The ID of translation is the label encoded via MD5 (This is an online service for MD5 encoding https://md5-hash-online.waraxe.us (opens new window)). For instance, the category ID translation is defined in this way:
# Ready for PrestaShop
This is the simplest configuration. Now, you can start searching for products and continue with the module or Algolia customization.