🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Integrations / Magento 2

How many records are created?

To be able to provide fast results, the engine pre-computes a part of the order at indexing time. This means only one sorting is available for a single index. Each additional sort will result in an additional index.

In Magento, this means that by default these indices are creates:

  • One per store
  • One per store per additional sort order (such as by price or by date)

To calculate the amount of records this generates, take a look at the following example:

A Magento app has two stores (for two languages) which both have 100 products. Both stores have additional sorts on price and date, resulting in a total of 4 additional sorts.

Using this scenario, you would need to index:

Sort Records Total
Default sorting 100×2 200
Custom sorting 100×2×4 800
Total records   1000

If the customer group feature is enabled, each customer group will result in an extra index on the pricing sorting. Following the preceding example, but with a total of 5 customer groups will result in:

Sort Records Total
Default sorting 100×2 200
Pricing sorting 100×2×2×5 2000
Custom sorting 100×2×2 400
Total records   2600

The amount of records indexed can be lowered by removing some of the sorts. The sorts can be configured in the extensions’ administration panel.

Sorting configuration

Console error after reindexing: “Cannot read property ‘autocomplete’ of undefined”

This error indicates the extension’s templates were not rendered. These templates are rendered into the before_body_end block, please make sure the theme renders this block. If this block is rendered by the theme, please confirm that symlinks are enabled in Magento’s configuration. This can be enabled in the administration section by navigating to System > Configuration > Advanced > Developer.

404 not found error in Magento configuration

This issue should be resolved by logging out and logging in to the Magento Administration Panel again.

Empty index after pressing ‘Reindex’

In case the indexing queue is enabled, pressing the ‘Reindex’ button will push indexing jobs to the queue. This means the indexing will happen only when the queue is running, and not immediately when the button is pressed. Please make sure the indexing queue is set up correctly and the amount of items to be indexed do not exceed the limits. More information about the indexing queue can be found here.

First, make sure the products are properly indexed by Algolia. This can be achieved by navigating to the Explorer, selecting the index containing your products and searching the product.

In case the product shows up in the Explorer, please confirm the product has the right visibility settings. When products are only visible in the Catalog, they will not show up while searching. They will only show up on the instant search page in the category section.

In case the product does not show up in the Explorer, the product is not indexed (properly). Make sure the product adheres to the requirements the extension uses to determine if a product can be indexed. If the product meets the set requirements, please hit ‘Reindex’ again.

Should the problem persist, please turn on logging and investigate the log files. This should provide more insights into what’s going on during a reindexing operation.

Products not found by SKU

If a product can’t be found by searching for the products’ SKU, please make sure that the latest version of the extension is installed. If you can’t find the product on the latest version of the extension, check if SKU is set as a searchable attribute. This can be checked in the Algolia configuration in the Magento backend.

Deleted products are still showing up after reindexing

If deleted products keep showing up in your search after reindexing, please make sure that the latest version of the extension is installed. If the extension is below version 1.6.0, an issue can arise when directly changing products in the database. Because no Magento hooks are triggered when manipulating the database directly, the extension could not recognize that a product was deleted/edited. Version 1.6.0 contains a fix for this issue, so please update the extension if needed.

Huge increase in indexing operations

Sometimes, it happens that the amount of indexing operations skyrockets (up to 10x the normal amount of indexing operations) without an apparent reason. When digging deeper, a few common problems may arise which causes these spikes.

The most probable reason is an automatic import of products from an ERP system into the catalog by a third-party tool, extension, or custom code. The tool can update a lot of catalog product information: it can change the stock, the prices and any other information about a product. All these changes can trigger a save event in Magento. the extension listens to these save events to automatically keep your products up to date. That’s why each change will trigger an indexing operation.

This can become really problematic when the third-party tool, extension, or custom code triggers multiple save events per product. When it’s updating the price of a product and saving this change, and after that it’s updating the description of the product and saving this change too, the save event will be fired twice. This means the extension will update the index twice, even though one time would have been enough. This can cause a massive spike in the amount of indexing operations.

How to fix

First of all, identify which plug-in or piece of code triggers all the save events. When the problem is found, try to limit the amount of operations it performs. If this is not possible, try turning off indexing while the process of the tool is running, and enable indexing again when it’s done. If all the preceding steps fail, try to use the indexing queue. The indexing queue will merge jobs if possible to limit the amount of indexing operations.

Some third-party tools bypass the save-mechanism in Magento by updating the database directly. This can cause your indices to be out-of-sync. A full reindex is needed to fix this issue.

The search on the front of your Magento installation is displayed without going through the Magento backend. This means the extension has to generate the UEL for images at indexing time, not at the time of searching. When the extension generates this image, Magento will provide it with a cached and resized version of the image to display. One of the possible reasons that images are missing, is that this cache could not be generated automatically by the Magento installation.

First, please make sure the latest version of the extension is installed. If the version of your extension is lower than 1.5.x, please update.

The main problems with images are:

  • Images appear and then disappear. This problem usually means that the image cache has been dropped. This is often triggered manually from the backend of Magento (System > Cache Management) or through the command line. When the image cache is cleared, indexed image links become invalid because the file will be nonexistent. A full reindex should fix this problem.
  • Images aren’t showing at all. This problem usually means one of two things. Either there is an issue with the directory permissions, or there’s a memory issue. First, make sure the media/ directory has the correct permissions. The permissions should be set to 770/660. If this doesn’t work, enable logging. With logging enabled, run a full reindex and open the log file after to see what’s going wrong. If nothing useful comes from the log files, please check the Magento and Apache/nginx log files as well to check if the problem lies there.

Algolia on a custom search page template

The real-time search experience is implemented using JavaScript in the users’ browser. This means the real-time search doesn’t have access to the templates of your theme, and the search results are not yet available in the PHP code of the theme.

To customize the design of the InstantSearch results page and the autocomplete menu, please check this guide.

Fatal error: Class ‘AlgoliaSearch\Version’ not found in …/AlgoliaHelper.php on line xx

When this error occurs, the extension is probably installed incorrectly. Choose from two supported ways to install the extension: Composer or the Component Manager. Please reinstall the extension according to these instructions.

Sometimes, links of the Magento installation can show up with an additional /magento/ in the URL. Most likely, this is because web server rewrites are turned off. Navigate to Stores > Configuration > General > Web > Search Engine Optimization and set the field Use Web Server Rewrites to Yes. When this setting is updated, a full reindex is required for the changes to take effect.

This error can occur when your app has the pub/ directory as the root directory for the Magento installation. This is usually considered a good practice, but it has some drawbacks. The extension can’t know which directory is the root folder for Magento, so it always assume the base directory is your root folder.

The best way to handle this problem is to make your server ignore /pub in the URL.

If it’s not possible to change the server configuration, a setting is provided in Stores > Configuration > Algolia Search > Advanced > Remove /pub/ from image URLs. When this setting is changed, please reindex the catalog.

Increase in delete operations on Algolia

To make sure the extension only indexes products which are supposed to be indexed, all the products are processed when performing a reindex without the indexing queue enabled. If a product being processed isn’t enabled, out of stock, or invisible, the delete operation is performed in Algolia, even if the product is not present in the Algolia index at all.

The solution to this problem is to enable the queue. With the queue enabled, only products that meet the requirements are indexed and pushed to Algolia. The indexing queue makes use of atomic reindexing. Because of this, your current index will not be updated: instead, a temporary new index is created. This temporary index will replace your current index when it’s filled with all the correct objects.

‘No’ values in filters

When a product doesn’t have any value assigned to an attribute, the value of this attribute will be automatically set to ‘No’ by Magento. To turn off indexing for ‘No’ values, set the Index empty value setting in your searchable attributes to No for the attributes you want to ignore ‘No’ values for.

Changing any index setting requires a full reindex of all data.

indexer.php in indexed URLs

When server rewrites are turned off in the Magento installation and a reindex is done through the command line, indexer.php will be added to the URLs. The only way to prevent this, is to turn on server rewrites.

This can be done by navigating to System > Configuration > General > Web > Search Engine Optimalization and setting Use Web Server Rewrites to Yes.

Error: Rules quota exceeded. Please contact us if you need an extended quota

When trying to update Algolia’s configuration, or reindexing products, this error may occur. This probably means the amount of Rules you’re allowed to use may be limited, depending on your plan.

The extension only creates rules when explicitly configured to do so. Rules can be configured in the Facets configuration.

To solve this error, either reduce the number of rules you are using, or upgrade the plan to get a higher limit through the billing section in the Algolia dashboard.

What settings are handled by the Magento dashboard vs Algolia dashboard?

Each type of data - products, categories, pages, query suggestions and additional sections - controls a different set of settings when enabled for indexing.

Products

Categories

Pages

Query Suggestions

Additional Sections

Any settings that are not in this list can be managed through the Algolia dashboard. If you’re a developer, it’s also possible to push settings programmatically by hooking into the algolia_products_index_before_set_settings event.

Settings applied in the Algolia dashboard will overwrite any settings you do in Magento until a full reindex is performed though Magento. This will reset all the index settings to the settings set in the Magento Dashboard.

Create query redirects

You can create a query redirect by using Magento’s default Search Terms feature. You can find this feature by going to Marketing > Search Terms in your Magento back-office. You can modify a previously searched query or click “Add New Search Term” to create a new query redirect.

Add best sellers to sort order

Best Sellers can be added to your sort order configuration in Stores > Configuration > Algolia Search > Instant Search Results Page > Sorts. To add this sort order, click “Add” to add a new row and configure Attribute to ordered_qty, and set the Sort direction as Descending.

Please note that adding this sort order adds ordered_qty and total_ordered attributes to your product objects, aggregated from the sales_order_item table. This can potentially increase your indexing time.

Enable partial updates

If you need to perform partial updates, you can enable this feature in Stores > Configuration > Algolia Search > Advanced > Partial Updates. This will index your data using the partialUpdateObjects method instead of saveObjects. You should enable this option if you want to update only some attributes of your records from an external source without overriding Magento data.

From version 2 and up, URL parameters are appended to the product links in your search if you enable conversion tracking. This is so search can be ties to a conversion event using the queryID parameter. As best SEO practice, use canonical links for your product pages. You can enable this setting by going to Stores > Configuration > Catalog > Catalog > Search Engine Optimization > Use Canonical Link Meta Tag For Products.

WeltPixel layered navigation and other third party plug-ins and modules

The Algolia Magento extension may not be compatible with other third-party Magento plug-ins and modules dealing with layered navigation, catalog search, or pagination, such as WeltPixel. There’s no support for usage in conjunction with the extension.

Porto and other themes

The Autocomplete menu guide has more information about how to implement a custom theme.

To display InstantSearch results, the extension uses the .columns element. If your theme doesn’t include the default .columns element, you need to change the value for Stores > Configuration > Algolia Search > Instant Search Page Results > DOM Selector to an element that works for your theme.

See the Frontend (UI/UX) guide for more information about configuring your frontend to help support your custom theme.

How to add numeric attributes as non-castable

To access the configuration page for Algolia in your Magento project, navigate to Stores > Algolia Search > Credentials and Basic Setup > Advanced in the Admin panel.

From there, you can specify which text fields or non-castable attributes to include under Product numeric textfield attributes that should not be converted into a numeric field by Magento.

Add numeric attributes as non-castable

How to increase the max record size limit in the extension?

The Magento extension caps the max record size to 10kb by default.

If your Algolia plan includes a higher max record size allowance, you can increase this value in the extension by following the steps below:

For extension version 3.9.1 and later

To configure the Algolia extension, follow these steps:

  1. In the Admin panel of your Magento project, go to Stores > Algolia Search > Credentials and Basic Setup > Advanced to open the configuration page for Algolia.

  2. Enter the value for Max record size limit per record as per your requirement.

    Max record size limit per record configuration

  3. Click Save Config at the top right to save your configuration.

For extension version 3.9.0 and below

Customizing the record size limit

By default, the user can fetch the max record size limit set in the extension by calling the method Algolia\AlgoliaSearch\Helper\ConfigHelper::getMaxRecordSizeLimit().

The method returns the DEFAULT_MAX_RECORD_SIZE constant defined in the same class, which is set to 10000.

1
2
3
4
public function getDefaultMaxRecordSize()
{
   return self::DEFAULT_MAX_RECORD_SIZE;
}

This method is public, that means that you can use a standard Magento plugin to override this value.

Create a custom module

First, you need to create a custom module where you can register and implement the custom behavior. To achieve this, you can look at the guide on creating a custom extension.

Register the plugin

Create a etc/di.xml file with the following code:

1
2
3
4
5
6
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Algolia\AlgoliaSearch\Helper\ConfigHelper">
       <plugin name="algoliaUpdateMaxRecordSize" type="Algolia\CustomAlgolia\Plugin\ConfigHelperPlugin"/>
   </type>
</config>

Create the Plugin

Now, create the plugin class in the Plugin/ConfigHelperPlugin.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace Algolia\CustomAlgolia\Plugin;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;

class ConfigHelperPlugin
{
   public function afterGetMaxRecordSizeLimit(ConfigHelper $subject, $result)
   {
       // You can either return a new value or add a custom logic if that's needed
       return 20000;
   }
}

Clean the Magento cache, and you’re all set.

Did you find this page helpful?