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
In Laminas\DependencyPlugin\DependencyRewriterV2::onPrePoolCreate
Updating dependencies
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).
Errors are:
Uncaught TypeError: Cannot read properties of null (reading ātagNameā)
at index.production.js:2:61744
at index.production.js:2:62743
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 recommend.js:16:37
at Object.execCb (require.js:1696:33)
at Module.check (require.js:883:51)
at Module. (require.js:1139:34)
at require.js:134:23
at require.js:1189:21
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?
@michael.king thanks for looking at this.
It happens sporadically on product pages. I canāt see any pattern with product types or page content. You can tell when the error has happened because the āAdd to basketā button is greyed out.
Iāve just had it happen on this page: https://www.backstitch.co.uk/make-your-own-christmas-caravan
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:
Hi @rachel.trott1 ,
Also strongly looking forward to getting a stable fix from you, as we have a Magento migration planned in a couple of days, and we also discovered this problem recently.
@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 support@algolia.com if you have more questions.
If you have any third party extensions installed then make sure they are compatible with magento 2.4.5 incompatiblities between extensions and upgraded magento version can cause various compressor issues including problems with autocomplete. check with the extension developer for updates or patches if needed. Thanks.