5

After upgradeing to Magento 2.2.4 there seems to be an error on the product page where the javascript its not working properly (see the screenshot).

I am using Porto. Any ideas?

Javascript error on product page in magento 2.2.4

4
  • The error you refer to is the invalid JSON? Or do you mean the duplicate element IDs? Did you check where that JSON is coming from? May 3, 2018 at 14:05
  • The error is the invalid JSON (Uncaught SyntaxError: Unexpected token , in JSON at position 1206). May 3, 2018 at 14:25
  • 1
    Can you check the source code of this page? Most properly, the issue cames from product name with ' which broken the JSON string.
    – Tiikeri
    May 3, 2018 at 14:43
  • You should post that Tran, so it seems the right answer May 20, 2018 at 8:32

2 Answers 2

6

In

app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/gallery.phtml

replace

"arrows": <?php /* @escapeNotVerified */ echo $block->getVar("gallery/arrows"); ?>,

"showCaption": <?php /* @escapeNotVerified */ echo $block->getVar("gallery/caption"); ?>,

with:

"arrows": "<?php /* @escapeNotVerified */ echo $block->getVar("gallery/arrows"); ?>",

"showCaption": "<?php /* @escapeNotVerified */ echo $block->getVar("gallery/caption"); ?>",
0
0

I found the solution by renaming the following file:

app/design/frontend/mytheme/Magento_Catalog/templates/product/view/gallery.phtml

to

app/design/frontend/mytheme/Magento_Catalog/templates/product/view/_gallery.phtml

After that run all magento commands. Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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