elgentos / LargeConfigProducts

Large Configurable Products workaround for Magento 2
91 stars 28 forks source link

Syntax Error in JSON #11

Closed simonmaass closed 6 years ago

simonmaass commented 6 years ago

Hello,

I installed your module and on some products it works and on some i get the following error:

unbenannt

Any ideas where to start looking? Thank you!

peterjaap commented 6 years ago

What's the content of the JSON? Also read https://github.com/elgentos/LargeConfigProducts/issues/8

simonmaass commented 6 years ago

yeah i read that issue...

seems to be here:

{
    "[data-role=swatch-options]": {
        "Magento_Swatches/js/swatch-renderer": {
            "jsonConfig": null<? /* @escapeNotVerified */ //echo $swatchOptions = $block->getJsonConfig() ?>,
            "jsonSwatchConfig": {"173":{"68":{"type":"0","value":"CCL1","label":"CCL1"},"69":{"type":"0","value":"CCL2","label":"CCL2"},"208":{"type":"0","value":"CCL3","label":"CCL3"}},"93":{"87":{"type":"1","value":"#9c7e5b","label":"Mode"},"92":{"type":"1","value":"#1a212e","label":"Mondscheinblau"},"96":{"type":"1","value":"#ffffff","label":"Wei\u00df"},"97":{"type":"1","value":"#998a61","label":"Bronze"},"99":{"type":"1","value":"#d2a17b","label":"Ros\u00e9"},"200":{"type":"1","value":"#000000","label":"Schwarz"},"265":{"type":"1","value":"#f0b497","label":"Caramel"}}},
            "mediaCallback": "https://shop.meevo.de/swatches/ajax/media/",
            "gallerySwitchStrategy": "replace"
        },
        "Magento_Swatches/js/configurable-customer-data": {
                "swatchOptions": null            }
    }
}

Here: "jsonConfig": null<? /* @escapeNotVerified */ //echo $swatchOptions = $block->getJsonConfig() ?>,

DavidLambauer commented 6 years ago

Hi, I tried to debug the whole thing a little. When I call the product options in the browser to see the JSON, I get a huge response (we have a lot of variants). The response itself is valid json. I couldn't find any syntax issues.

We are running M2 CE Version 2.2.5

peterjaap commented 6 years ago

Maybe remove <? /* @escapeNotVerified */ //echo $swatchOptions = $block->getJsonConfig() ?> after "jsonConfig": null ?

Its weird because that doesn't give me any issues on my installation but seeing as the JSON error states a <, that must be it.

peterjaap commented 6 years ago

Maybe your PHP installation has short tags disabled? That might explain it. Changing <? to <?php might in that case also solve the issue.

DavidLambauer commented 6 years ago

Yeeees! That's the issue! Short Tags were configured for production... Wouldn't be a hard thing to change it in the module, right? Shall I add a PR for that xD

peterjaap commented 6 years ago

Sure :)