Skip to main content
The Algolia extension exposes events based on Magento’s dispatched events so that you can customize the behavior of the extension. For information about creating custom event listeners for custom extensions, see Create a custom extension tutorial.

Modify index settings

To change settings before sending them to Algolia, use the {ENTITY}_index_before_set_settings event. For example:
PHP
Make sure to refer where the backend events are dispatched in the code. This lets you see what variables are available for your customization. You can add or change index settings parameters before sending it to Algolia. At this point of the event, the extension has already added and formatted parameters based on your settings. Here’s an example of how an observer could modify index settings:
PHP

Update attribute data

To change entity data before indexing, use the algolia_after_create_{ENTITY}_object events. These events fire in the getObject() method of the entity Helper class. For example, in \Algolia\AlgoliaSearch\Helper\Entity\ProductHelper::getObject() this event is dispatched just before the object is returned for indexing:
PHP
Here’s an example of how an observer could transform the created_at attribute from the default MySQL date format to a timestamp:
PHP

Modify product data

Use the algolia_after_create_product_object event to change the product data sent to Algolia. If you need access to specific attributes that aren’t available in the collection data, request them from the product collection with the algolia_after_products_collection_build event. The product data used for indexing is from a product collection request. The full product model isn’t available during the object creation method. This applies for categories and suggestions indexing as well. They have their own algolia_after_{ENTITY}_collection_build events where you can access the collection. The product collection is created by the \Algolia\AlgoliaSearch\Helper\Entity\ProductHelper::getProductCollectionQuery() method. This method dispatches the algolia_after_products_collection_build event, which lets you access the $collection object:
PHP
In your custom observer, you can access the product collection and add your attribute before the collection loads:
PHP
After adding the attribute, your product can retrieve it in your observer for the algolia_after_create_product_object event:
PHP

Modify the frontend configuration

To let the frontend display the configured UI, the Algolia extension creates the algoliaConfig JavaScript variable by retrieving the configuration from a class. You can change the algoliaConfig object before the page loads by using the algolia_after_create_configuration event. This event is dispatched at the end of \Algolia\AlgoliaSearch\Block\Configuration::getConfiguration():
PHP
The method turns the configuration array into a DataObject so that you can make changes in your observer using getters and setters:
PHP

List of product events

Dispatched before sending products index settings to Algolia

algolia_products_index_before_set_settings Parameters:
  • $storeId
  • $index_settings as data in Magento\Framework\DataObject object (modifiable)

Dispatched after products collection creation

algolia_after_products_collection_build Parameters:
  • $storeId
  • $collection as Magento\Catalog\Model\ResourceModel\Product\Collection (modifiable)
  • $only_visible
  • $include_not_visible_individually

Dispatched before final products collection load

algolia_before_products_collection_load Parameters:
  • $collection as Magento\Catalog\Model\ResourceModel\Product\Collection (modifiable)
  • $store

Dispatched before fetching product attributes for indexing

algolia_product_index_before Parameters:
  • $product as Magento\Catalog\Model\Product
  • $custom_data as data in Magento\Framework\DataObject object (modifiable)

Dispatched after fetching product’s attributes for indexing

algolia_after_create_product_object Parameters:
  • $custom_data as data in Magento\Framework\DataObject object (modifiable)
  • $subProducts as array of sub products
  • $productObject as Magento\Catalog\Model\Product

List of category events

Dispatched before pushing categories index settings to Algolia

algolia_categories_index_before_set_settings Parameters:
  • $storeId
  • $index_settings as data in Magento\Framework\DataObject object (modifiable)

Dispatched after categories collection creation

algolia_after_categories_collection_build Parameters:
  • $store
  • $collection as Magento\Catalog\Model\ResourceModel\Category\Collection (modifiable)

Dispatched before fetching category attributes for indexing

algolia_category_index_before Parameters:
  • $category as Magento\Catalog\Model\Category
  • $custom_data as data in Magento\Framework\DataObject object (modifiable)

Dispatched after fetching category attributes for indexing

algolia_after_create_category_object Parameters:
  • $category as Magento\Catalog\Model\Category
  • $categoryObject as data in Magento\Framework\DataObject object (modifiable)

List of page events

Dispatched before pushing pages index settings to Algolia

algolia_pages_index_before_set_settings Parameters:
  • $store_id
  • $index_settings as data in Magento\Framework\DataObject object (modifiable)

Dispatched after fetching page attributes for indexing

algolia_after_create_page_object Parameters:
  • $page as data in Magento\Framework\DataObject object (modifiable)
  • $pageObject as Magento\Cms\Model\Page

List of suggestion events

Dispatched before pushing suggestions index settings to Algolia

algolia_suggestions_index_before_set_settings Parameters:
  • $store_id
  • $index_settings as data in Magento\Framework\DataObject object (modifiable)

Dispatched after suggestions collection creation

algolia_after_suggestions_collection_build Parameters:
  • $store
  • $collection as Magento\Search\Model\ResourceModel\Query\Collection (modifiable)

Dispatched after fetching suggestion attributes for indexing

algolia_after_create_suggestion_object Parameters:
  • $suggestion as data in Magento\Framework\DataObject object (modifiable)
  • $suggestionObject as Magento\Search\Model\Query

List of additional sections events

Dispatched before pushing additional section index settings to Algolia

algolia_additional_sections_index_before_set_settings Parameters:
  • $store_id
  • $index_settings as data in Magento\Framework\DataObject object (modifiable)

Dispatched after fetching additional section attributes for indexing

algolia_additional_section_items_before_index Parameters:
  • $section
  • $record as data in Magento\Framework\DataObject object (modifiable)
  • $store_id

List of frontend configuration events

Dispatched after frontend configuration creation

algolia_after_create_configuration Parameters:
  • $configuration as data in Magento\Framework\DataObject object (modifiable)
Last modified on May 19, 2026