Examples of default records
-
Index name:
magento2_products_enJSON -
Index name:
magento2_products_deJSON -
Index name:
magento2_products_esJSON
Implement multi-language search
The records must contain values in all supported languages to search on one store view in those languages.Create a record in the extension
- Create a custom extension, which lets you listen to the extension’s custom events.
-
Create an event listener for the
algolia_after_create_product_objectevent, the same way as written in the custom event extensionalgolia_products_index_before_set_settings. -
From the
$observervariable passed to theexecute()method, fetch:custom_dataproductObjectsubProducts
-
The Algolia record is an
arrayin thecustom_dataobject and can be modified like any other PHP array. -
Fetch searchable attributes, such as name, description, or manufacturer, in all other languages and add it to the record in
custom_data. Structure the data according to the example record.
Example of an observer’s execute() method
PHP
Index settings
If your records are structured like the example record, you don’t need to send specific settings to Algolia because you only need to make parent attributes, such as name, description, or manufacturer, searchable. You can do this in the Magento Admin.Showcase record
JSON