Managing search results in a magento 2 multistore environment

We are running a multi-vendor, multi-store magento 2.2.5 instance.
We currently have 2 different storefronts (will be more) with a shared product database
• Products can appear in 1 or both storefronts
• Search visibility is also controlled by logged in user customer segment in each
o Consumer
o Business
o Retail

Is there any way to control visibility in each storefront, or do we have to use a new App ID and API keys etc. Reason is we are in setup mode at moment - have been for past year, and we are barely using the search operations for even basic pay as you go account……looking to keep costs low at moment until live and have revenue coming in!

Hi Richard,

Thanks for contacting Algolia Support.

The common approach to handling multiple storefronts (or environments) is to use a different index prefix for each store. This can be handled in the configuration section of the Algolia extension settings as shown below.

Our extension adheres to the websites, stores, and store views listed in Magento.

The following documentation will be of assistance with further explanation:

Let me know if you have any further questions.
Best regards,

Thank you for answering the question about product visibility for each storefront, but how do we restrict product and price visibility for a customer group in a storefront.

For instance, storefront A has 3 customer segments + guest.

    • B2C
    • B2B (Bus to Bus (for use by that business)
    • B2R (Bus to Retailer / wholesaler (for resale))

Rules are: -

  • B2C and guest pricing is non sensitive and can be publicly visible, and B2B and B2R products not visible for them
  • B2B products and pricing should only be visible to B2B customers once they have logged in.
  • B2R products and pricing should only be visible to B2R customers once they have logged in.

Each product may be set by store admin as available for sale to 1, 2 or 3 customer segments and each may have a different price.

We have worked out how to display the correct price for a product according to the customer segment the current searching customer is in, so all good.

However we have not managed to work out how to restrict visibility or products specific to a segment yet.

We believe:

Product Visibility-Based on customer Segments:

  1. We need to store data inside Algolia product indexes as an array to define which customer group the product should be visible for.
  2. To do this we believe we need to modify the Algolia script so a product is only displayed to customer group associated with the logged in user profile. The script file we believe to do this is “” but the file is encrypted and we can not alter it.

Hi @richardp,

You asked:

and then mentioned:

This sounds like you can successfully identify which segments to show to that user (Segment 1, Segment 2, or Segment 3). Is that right? This is great.

The next concept will then be applying filter:

  • Identify the user, and the segments to show
  • Add a filter to the search query on the InstantSearch frontend to limit the search results to that segment. (see Filtering)
filters: 'segment:1 OR segment:2'
-- or --
filters: 'NOT segment:3'

The more advanced concept will involve Secured API Keys. Because filters on the frontend can be visible and changed by the end-user if you open up the developer tools, you may want to bake-in the filters into the Search API Key so that it is unchangeable by the end-user => this is the role of Secured API Keys.

However, this will require you to create these keys on the backend of your choice and send it to the frontend dynamically as needed for the specific user.

A few options. Although neither is out-of-the-box for the Algolia for Magento integration, they are doable with sufficient developer workforce.

I hope this helps!