Issue with magento instantsearch.js

I am having some difficulty after updating the algolia magento extension from 1.7.0 to 1.9.0 on the instantresult pages getting products from my external WP index showing up.

We have customized the algolia extension to include 2 WP indexes for pages and posts on both the autocomplete and instantsearch sections of the Algolia magento extension. The autocomplete section works and returns results, however on the instantsearch page, the same indexes for searches / posts keep returning 0 results.

Here is an example page that should return WP hits on the bottom:

https://iwtdev.interweave.com/store/index.php/catalogsearch/result/?q=red

and here is the JS that I am using:
https://iwtdev.interweave.com/store/js/fw_algoliasearch/fw_instantsearch.js

Here is a screenshot of one of the algolia indexes from the dashboard returning 6 hits when you query directly from the dashboard:

Any idea why this isn’t working / why the JS from the page is returning 0 hits for both indexes?

Hello @robert.krule,

I checked your website and the instant search uses a secured API key which is generated for Magento needs. It includes a filter parameter search_visibility=1, which makes sure only Magento products which should be displayed on a search page are fetched. However it affects the wp_posts search as well now as it uses the same API key. But your posts don’t have such an attribute, that’s why is not fetched:

The solution for you would be to use “regular” search API key to search through posts. Is that doable for you?

Thanks Jan!

You pointed me in the right direction there, so basically I overrode configuration.phtml, added a new property to algoliaConfig and made a new secure api key with filters / attributes being open. Then I hashed it all with the helper method you provide, and then save it to algoliaConfig.

Modified the JS to look for the new apiKey property with the open query. Now its returning results!

Really appreciate it, I stared at this for several days before reaching out.

Thanks,

Rob

2 Likes

Hello Rob,

great to hear you made it work, awesome job! :100:
I you’ll have any further question in the future, don’t hesitate to reach out again. I’ll be happy to help.

Happy coding :sunny: