1

Magento 2.3.5 getting error on the product detail page of configurable product -

Getting this error -

Uncaught TypeError: Cannot read property 'data' of undefined
    at Object.returnCurrentImages (eval at require.load (VM605 static.js:340), <anonymous>:508:46)
    at $.<computed>.<computed>._onGalleryLoaded (eval at require.load (VM605 static.js:340), <anonymous>:706:62)
    at $.<computed>.<computed>.eval [as _onGalleryLoaded] (eval at require.load (VM605 static.js:340), <anonymous>:102:41)
    at HTMLDivElement.dispatch (eval at require.load (VM605 static.js:340), <anonymous>:5234:27)
    at HTMLDivElement.elemData.handle (eval at require.load (VM605 static.js:340), <anonymous>:4886:29)
    at Object.trigger (eval at require.load (VM605 static.js:340), <anonymous>:5138:13)
    at Object.jQuery.event.trigger (eval at require.load (VM605 static.js:340), <anonymous>:635:22)
    at HTMLDivElement.eval (eval at require.load (VM605 static.js:340), <anonymous>:5868:18)
    at Function.each (eval at require.load (VM605 static.js:340), <anonymous>:378:20)
    at jQuery.fn.init.each (eval at require.load (VM605 static.js:340), <anonymous>:144:18)

Why we are getting this error and how can we solve this ?

0

It sounds like the element [data-gallery-role=gallery-placeholder] does not exist on the page, therefore element is undefined here:

var galleryObject = element.data('gallery');

Which is on line 731 in vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js on the version of Magento I am using.

I can't be 100% sure on that but it's what it looks like based on your error.

2
  • on page 2 div is exist on this div 1 - <div class="gallery-placeholder" data-gallery-role="gallery-placeholder"> 2 - <div class="fotorama-item" data-gallery-role="gallery"> Apr 1 at 14:44
  • Does it exist at the point that JS runs? If you add a breakpoint or console.log(element) above that line?
    – Ben Crook
    Apr 1 at 17:00

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