We have recently upgraded magento from 2.3.5 to 2.4.5
I have uninstalled and reinstalled algolia with the following reinstalled:
Using version ^3.9 for algolia/algoliasearch-magento-2
./composer.json has been updated
Running composer update algolia/algoliasearch-magento-2
Loading composer repositories with package information
Lock file operations: 3 installs, 0 updates, 0 removals
Also installed algolia-search-inventory as suggested in a message in magento admin.
First issue is that the autocomplete doesn’t show when queries are entered into the search bar. Search input DOM Selector is set to #search
Second issue is that I am getting JS errors in the console when autocomplete is enabled that cause issues with other parts of the site (buttons made inactive).
Uncaught TypeError: Cannot read properties of null (reading ‘tagName’)
at reactive (index.production.js:2:61070)
at e.autocomplete (index.production.js:2:61273)
at HTMLInputElement. (autocomplete.js:465:67)
at Function.each (jquery.js:365:1)
at ue.fn.init.each (jquery.js:137:1)
at HTMLDocument. (autocomplete.js:336:48)
at c (jquery.js:3187:1)
at Object.add [as done] (jquery.js:3246:1)
Uncaught ReferenceError: algoliObjectId is not defined
at Object.execCb (require.js:1696:33)
at Module.check (require.js:883:51)
at Module. (require.js:1139:34)
at each (require.js:59:31)
at Module.emit (require.js:1188:17)
at Module.check (require.js:938:30)
at Module. (require.js:1139:34)
Live site is at www.backstitch.co.uk but I have turned off autocomplete as user couldn’t add products (button inactive).
Just to update progress on this issue.
I’ve had the following help from an Algolia support ticket I raised:
In regards to the first error “Uncaught TypeError: Cannot read properties of null (reading ‘tagName’)”, could you confirm what DOM selector are you using in Algolia search → Advanced → Search input DOM Selector ? If you’re using the default selector .algolia-search-input it should work. If you have a different DOM selector other than the default one: .algolia-search-input , you might encounter this issue. Our Magento team is aware of the issue and they are working on a fix for that, though we do not have an ETA to share at the moment.
The second error “Uncaught ReferenceError: algoliaObjectId is not defined” issue could be related to caching. Could you please clear your cache and make sure that the cache is cleared if you are using a CDN?
As I mentioned before we are using the #seach DOM selector, so I will have a go at changing that in our template tomorrow.
Cache has been cleared more time than I can count!
This turned out to be an issue with the template we are using.
I have changed the DOM Selector in Algolia search → Advanced → Search input to .algolia-search-input`
Also had to make an edit in the file app/design/frontend/Infortis/base/Magento_Theme/layout/default.xml to get the top.search block to display in the correct place.
I’m still getting the “Uncaught ReferenceError: algoliObjectId is not defined” issue sporadically.
Sometimes this is Uncaught ReferenceError: algoliaConfig is not defined.
Both refer to the Algolia_AlgoliaSearch/recommend.js file.
I’ve noticed the error I’m getting is actually algoliObjectId not algoliaObjectId as previously stated.
This is resolved by refreshing the page.
We don’t use a CDN and I have cleared the cache many times. I have also cleared the cache in the browser.
We don’t have recommended products enabled in Algolia magento admin, so it’s frustrating this file is causing errors.
Is there a way of bypassing it needing to be loaded?
I’ve had to remove Algolia from our live site again as it was causing too many errors.
A solution that looks to work on our staging site is as follows:
In file: vendor/algolia/algoliasearch-magento-2/view/frontend/layout/algolia_search_handle.xml
Comment out the following line:
My reasoning here is that as both errors we’re getting are in recommend.js, and we don’t use the recommend feature, that not loading recommend.js will be a crude solution.
If any one can suggest a problem with this or a better way of not loading the file that would be really helpful.
Just upgraded from 3.1.0 to 3.9.0.
I experience the same errors.
Recarding tagName, I need a fix or suggestion as fast as possible please.
Regarding algoliObjectId: It appears sporadically and seems to be a classic “race condition” between two scripts due to async requirejs loading. Btw there is no need to put the property definition in to requirejs:
@gerald Thank you for reaching out. The PR we provided will be part of the scheduled release end of January. In the meantime you can use that as patch if you would like. Please contact firstname.lastname@example.org if you have more questions.