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

  • 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? – Arjen Miedema May 3 '18 at 14:05
  • The error is the invalid JSON (Uncaught SyntaxError: Unexpected token , in JSON at position 1206). – LogicHub Development May 3 '18 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 '18 at 14:43
  • You should post that Tran, so it seems the right answer – Raul Sanchez May 20 '18 at 8:32
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"); ?>",
| improve this answer | |
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

| improve this answer | |

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.