-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shim declaration ignored #83
Comments
I think this is a problem with MagePal DataLayer, because it doesn't wait for customer data to initialize. Unfortunately, in Magento it was done in such a way that customer data is a JavaScript module that can't do almost anything until it gets initialized with inline data it gets, e.g.:
so adding a shim that other module should wait for it to load is not enough. The only idea that I have would be to move MagePal DataLayer initialization ( I'm not sure if that's clear enough, but in case of any questions let me know. |
Assuming you're using Magepal Googletagmanager, you can do the following: (make needed adjustments for other modules ofc, check their layout files, element names, etc) Create a folder in your theme called Magepal_GoogleTagManager Create a folder in that folder called layout Create a file called default.xml Contents of default.xml:
Thanks to @krzksz info getting me onto the right track, figured I'd share my solution for people. |
Thank you @krzksz and @Quazz ! I had the same issue and your suggestions helped me solve it. Please note that the module is named Also File
|
Magento 2.4.1, we are using a module which has the following in requirejs-config.js:
However, customer-data is not initialized before datalayer, specifically the constructor.
We get an error like this:
Uncaught TypeError: Cannot read property 'get' of undefined
Referring to this line in Magento_Customer/js/customer-data:
I added some console.log in customer-data and can see that getExpiredSectioNNames is called somehow BEFORE the constructor of customer-data:
is called, which initializes the "storage" variable. So, the above constructor which calls customerData.initStorage() is NOT called before the first call to getExpiredSectionNames function which is in the same class.
This happens only after running Magepack. If Magepack is disabled, all works fine, and the constructor of customer-data is called first.
I already tried fixes mentioned here (magento/baler#6) however they didn't help, still the constructor isn't called in customer-data somehow.
Maybe it is related to this too https://magento.stackexchange.com/questions/316253/overriding-core-user-data-files-for-magepack however this person does not mention what he "fixed in customer-data" exactly.
Thank you very much for any insight!
The text was updated successfully, but these errors were encountered: