Magento 2

Centos 7

Mariadb 10

When I try to add a product from the admin panel I get the spinning wheel of death.

import-handler.js:44 Uncaught TypeError: component.getPreview is not a function at UiClass. (import-handler.js:44) at Registry._resolveRequest (registry.js:418) at Registry.addRequest (registry.js:385) at Registry.get (registry.js:229) at UiClass. (import-handler.js:43) at underscore.js:73 at Function..each._.forEach (underscore.js:145) at UiClass.setHandlers (import-handler.js:40) at UiClass.initialize (import-handler.js:27) at UiClass.initialize (wrapper.js:109)

It seems like I am missing one or more JS files. I have cleared cache redeployed, done everything I think of to try to get back whatever file is lost.

Permissions have been set over and over and over.

Any idea how to find out what JS file or files is/are missing. If this is even the case.

  • Is this in a clean Magento 2 installation? If yes, which exact version? It's possible it is a Magento core bug then and you might want to report it over at GitHub – Alex Mar 25 '18 at 15:29
  • Website is old and this section was working before – Shakir Khan Mar 25 '18 at 15:33
  • Do you fix it @Jesse? – David Duong Jun 9 '20 at 12:26

Odds are good that this isn't a missing JS file, but a JS file that is not loaded in the right order and so a dependency that is needed isn't in the DOM at the right time. When i get this error i search in the most common places with:

grep -r "getPreview" app/ vendor/magento/

I just did this and it came back with a few php files that use the same term, so if that is too broad of a search i'll using something like:

find app -name "*.js" | xargs grep -r "getPreview"

which will limit the search to only the app directory and the word getPreview in JS files.

If that doesn't turn up any results, then you might have a call in a CMS page or block with the offending code.

To fix this, it's a little too much to get into here, but i did a write up about the concept here and for more information, always see Alan Storm. But the basic concept is you need to wrap the offending JS in the require statement that will organize the load order, something like this:

    ], function($) {
        // your code goes here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.