Algolia Multistore Links Issue


I have setup Algolia for my Multistore with each store having seperate indicies but when searching for a product the URL is incorrect, it uses a different stores URL for a product for example I am on the url when I search products are showing links to

Does anyone know about this issue and can anyone support me to get this resolved?

Hi @gareth.jones,

Could you please look into two settings:

  • System > Configuration > General > Web > Search Engine Optimization and set the field Use Web Server Rewrites to Yes .

  • System > Configuration > General > Web > Unsecure or Secure:


After each, a full reindex is required for the changes to take effect.

I hope this helps!

Hi Ajay,

We are using Magento 2 and we have already setup the settings you mentioned in Magento 2 format, very confused to why this issue occurs

Hi @gareth.jones,

Just wanted to follow up here and see if it has been resolved. If it hasn’t, would it be possible to see a live example? It would help us with investigating your issue.

Let us know,


Hello @betty.suravech

The issue is still continuning to happen, we have developed a URL fix for now which looks like this

require_once 'vendor/algolia/algoliasearch-client-php/algoliasearch.php';
$client = new \AlgoliaSearch\Client('********', '************************');
$indexes = $client->listIndexes();
$indexes = array_shift($indexes);

$wrongBaseUrl = '';
$partOfWrongBaseUrl = '';

foreach ($indexes as $index) {
$indice = $client->initIndex($index['name']);
foreach ($indice->browse('') as $hit) {
if (stripos($hit['url'], $partOfWrongBaseUrl) !== false) {
    if($index['name'] == 'ustradesite_usa_products') {
        $baseUrl = '';
    } elseif($index['name'] == 'uktradestore_ukb2b_products') {
        $baseUrl = '';
    } elseif($index['name'] == 'ukb2cstore_ukb2c_products') {
        $baseUrl = '';
    } else {
    $hit['url'] = str_replace($wrongBaseUrl, $baseUrl, $hit['url']);
    echo 'Saving ' .$hit['objectID'] . PHP_EOL;
			echo "<br>";

We do have issues though because it seems everyday the wrongBaseUrl is changing to another store view as the main one, we have tried contacting the Algolia support multiple times but they won’t provide support about this issue. I have also posted this issue in the github issues for the Algolia module.

If it’s possible to get this fixed asap that would be great because I’ve noticed we are not the only ones encountering this issue!

Hi @gareth.jones,

Thanks for following up and sharing your script with us. After inspecting your script and noticing the index names you have, can you describe your Magento store set up? Are you using different Magento instances for each store or have you set up your stores by store view? Can you also confirm the index name prefix set in Stores > Configuration (possibly for all 3 stores)?

It would be helpful to lend us access to your data as well. You can do that here. You can revoke this access anytime.

Let us know! Thanks!

Hi @betty.suravech,

No problem, in our store we have 3 store views (multistore) with unique products and categories in each store view (though some have the same name)

Index Prefix Names
UKB2C - ukb2cstore_
UKB2B - uktradestore_
USA - ustradesite_

I have also provided access for support as requested.


Line 456 add
$newURL = $product->getUrlModel()->getUrl($product, $urlParams);

Directly below find ‘url’ and replace with, replace the storeurl/code with yours

'url' => str_replace(array('https://STOREURL1/STORECODE1/', 'https://STOREURL2/STORECODE2/', 'https://STOREURL3/STORECODE3/'), array('', '', ''), $newURL),


Line 15


<?php echo $block->getBaseUrl(); ?>



Do the same in


For the following files