Question

After moving to Magento ver. 2.2.2 from Magento var. 2.1.9 the Related Products, Up-Sells, and Cross-Sells modal panel from catalog product edit doesn't show anymore. I can see these error in the console

Uncaught TypeError: Cannot read property 'apply' of undefined
at registry.js:59
at Registry._resolveRequest (registry.js:418)
at Registry._addRequest (registry.js:385)
at Registry.get (registry.js:229)
at async (registry.js:58)
at UiClass.applyAction (button.js:78)
at Array.forEach (<anonymous>)
at UiClass.action (button.js:56)
at HTMLButtonElement.<anonymous> (knockout.js:3863)
at HTMLButtonElement.dispatch (jquery.js:5226)

After many debugging hours I found the KO component applied to product_form.product_form.related.related.modal is Magento_Ui/js/form/form instead of Magento_Ui/js/modal/modal-component

Can anyone help or point me in the right direction to fix it?

Was it helpful?

Solution

I don't have enough info to determine the fix, but it sounds like a file you have overwritten needs updating with something from the core.

I would start by removing all customisations you've done to related/upsell/crosssells and see if that resolves the issue, if it does then start removing those files one-by-one. If removing a file fixes it then you know the issue is related to that file. You can then run a diff with your version and the updated core version to hopefully see what you need to include.

It may help to go through the release notes for each release and check what changes have been made to related/upsell/crosssells, for example in 2.2.2 these changes were made:

A price change to a custom option affects only that option. Previously, changing the price of a custom option also affected the price of related products. GitHub-4588, GitHub-5798, GitHub-6041, GitHub-6097

And

Magento now successfully loads re-ordered related products when Edge-Mode is activated.

If removing all your changes fails then I wish you extra good luck.

Hope this helps.

OTHER TIPS

This type of errors often happens with upgrades, as Magento2 customisations are often not self-contained and rely on unofficial dependencies. Usually they indicate broken dependencies in the AMD/require-js constraints, that may be introduced by 3rd-party and bespoke extensions and themes.

I think the suggestion posted by Andrey Konosov is valid, as debugging knockoutJs otherwise is not a straightforward task, especially when many of these customisations are in place.

From the error you posted, it looks like knockout is triggered within jquery code, which may suggest jquery could be loaded in an inappropriate way (for instance injected forcefully via layout XML, rather than using require() or define() or dependency system, etc. Of course, this is just a guess, as the details posted are not nearly enough to make any judgements, however - if I was you - I'd start with debugging Javascript to find out what is happening, and the suggested knockout-context-debugg extension may be of big help for that.

Should you have more details about this problem, or any links that demonstrate the problem, or other information such as a list of extensions/themes active in you Magento installation, I'd be happy to give some more insights.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top