Enable suggestions in the Magento configuration
Enable suggestions for the Autocomplete menu
You must first enable the suggestions inside the autocomplete menu. To do so, visit Stores > Algolia Search > Autocomplete Menu in your back-office.
- Number of queries (0 by default): Maximum number of results shown in the autocomplete menu. Setting a value greater than 0 automatically activates the feature.
- Minimum query popularity (1000 by default)
- Minimum number of results per query (2 by default)
Get the Magento suggestions to work
Once you’ve enabled query suggestions, clear the Magento cache and run a suggestions reindex:
Create the Query Suggestions index in the Algolia dashboard
To create a Query Suggestions index, go to your Algolia dashboard:- Click on Query Suggestions
- Click on New Query Suggestions

query_suggestions_test
).
Select the different languages you’re using and the source index (for example, your main product index).
You can click “Accept and Continue” to create the Query Suggestions index.
After a few seconds, your new index will be available.
Go the “indices” section in the Algolia dashboard to find it between your other indices.

Replace the default suggestions index with the Query Suggestions index
To use Algolia’s Query Suggestions, you will need to use the appropriate frontend hooks provided by the extension. You can find some examples of frontend hooks usage in the custom extension guide. For details of how to turn off default suggestions, see Indexing suggestions. To contain the required frontend hooks, create a new Magento module (for exampleAlgolia_CustomAlgolia
) or install the freely available starter extension that you can customize further for your application.
The Autocomplete library was upgraded from v0 to v1 as of
3.8.0
of the Algolia Search Integration for Magento extension. Depending on your installed version, a different approach to customization will be required. In general, Algolia recommends running on the very latest version of our extension.Customize on latest version
Query suggestions are implemented by a plugin. To customize, use theafterAutocompletePlugins
frontend hook provided by the extension.
To ensure your customized plugin loads, enable query suggestions in the Magento configuration by setting “Number of queries” to a value greater than 0 in
Stores > Configuration > Algolia Search > Autocomplete Menu.
view/frontend/web/js/hooks.js
file and register it in requirejs-config.js
:
JavaScript
JavaScript
- Extract the index of the existing query suggestions plugin that needs replacing.
- Instantiate a new plugin containing the new index for the Query Suggestions data (for example the
query_suggestions_test
index created previously). - Provide all definitions related to presentation and behavior (templates, search parameters, and keyboard navigation).
Customize on versions 3.7
and earlier
Use the beforeAutocompleteSources
frontend hook provided by the extension.
In your custom module, create the view/frontend/layout/algolia_search_handle.xml
file and add the following to the <head>
section:
HTML
view/frontend/web/js/hooks.js
file and implement the logic for your hook there, or paste the contents of this gist in the file.
JavaScript
- Map over the different sources of the Autocomplete menu, to find the Magento’s default suggestions source that needs to be replaced.
- Instantiating a new source containing the Query Suggestions data (inside the
query_suggestions_test
index created previously). - Overriding the source with the created data.