Skip to content

swatch-renderer-mixin.js is broken PDP #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fernandofauth opened this issue May 25, 2021 · 24 comments
Closed

swatch-renderer-mixin.js is broken PDP #455

fernandofauth opened this issue May 25, 2021 · 24 comments

Comments

@fernandofauth
Copy link

fernandofauth commented May 25, 2021

swatch-renderer-mixin.js is broken PDP when config is undefined

if (_.isUndefined(config.jsonConfig.images)) return create(config, element);

@jordanvector
Copy link

This breaks all config products with a js type error on the page that looks like this

swatch-renderer-mixin.js:11 Uncaught TypeError: Cannot read property 'jsonConfig' of undefined
    at Object.<anonymous> (swatch-renderer-mixin.js:11)
    at new <anonymous> (wrapper.js:78)
    at Function.$.widget (widget.js:75)
    at swatch-renderer.js:1
    at mixins.js:105
    at Array.forEach (<anonymous>)
    at applyMixins (mixins.js:104)
    at mixins.js:129
    at Object.execCb (require.js:1650)
    at Module.check (require.js:866)

@jorgb90
Copy link

jorgb90 commented May 29, 2021

Serious problem.. Any idea how to fix it? We rely heavily on configurable products.

Edit:

For now removed the swatch-renderer-mixin.js from the requirejs-config.js to temporarily solve the above problem.

@jordanvector
Copy link

@jorgb90 We downgraded for now to fix this issue

@vvuksan
Copy link
Contributor

vvuksan commented May 30, 2021

Thanks for the report. We have pulled the 1.2.157 version while we address the issue.

@Lukas713
Copy link
Contributor

Lukas713 commented May 31, 2021

Hi @jordanvector, @fernandofauth , I've added an additional validation. PR

Can you give me example of configurable product that has empty or undefined config object at pdp.
Thanks

@jorgb90
Copy link

jorgb90 commented May 31, 2021

@Lukas713 We literally had it for every configurable product on our website.

@Lukas713
Copy link
Contributor

@jorgb90 is there a chance that you send me a link to a staging server. Or gie me a magento store version.

@Lukas713
Copy link
Contributor

Lukas713 commented Jun 1, 2021

@jorgb90 @jordanvector @fernandofauth

the mixin is tested with Magento 2.3.0 and Magento 2.4.2 with various configurable products. Can you give me scenario where config object is empty but images are rendered.

@pmarki
Copy link

pmarki commented Jun 1, 2021

We have the same issue with latest Magento 2.3.6-p1.

@Lukas713
Copy link
Contributor

Lukas713 commented Jun 1, 2021

Hi @pmarki

I've just tested with magento 2.3.6 using luma theme. Can you give me more info to reproduce the issue.

Thanks

@Lukas713
Copy link
Contributor

Lukas713 commented Jun 1, 2021

Hi @pmarki , @jorgb90 , @jordanvector, @fernandofauth

I've made commit that also validates config object at swatch-renderer-mixin.

I've tested it with magento 2.3.6, 2.4.0 and 2.4.2 with magento luma theme and sample data. It seems that it works as expected.

Can you give any feedback on this. Thanks

@DanilSA
Copy link

DanilSA commented Jun 3, 2021

Please, do not use wrapper.wrap method to extend the jQuery Widget!

https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_mixins.html#extend-jquery-widget

@jorgb90
Copy link

jorgb90 commented Jun 4, 2021

@Lukas713 We are running 2.4.2-p1. I can give you access to a dev environment, if you still want to. We are running configurables with visual and text swatches, not dropdowns.

@Lukas713
Copy link
Contributor

Lukas713 commented Jun 7, 2021

@jorgb90 you can check here. Size and color are text value and swatch value. this.options property is not undefined.

However, I've added additional config validation to the pull request.

@dpotkoc
Copy link
Contributor

dpotkoc commented Jun 7, 2021

Hello @jorgb90 it will be helpful if you could provide us access to dev server, also please send us exactly steps how to reproduce this issue.

Thanks in advance
Domagoj

@dpotkoc
Copy link
Contributor

dpotkoc commented Jun 8, 2021

@pmarki @jordanvector @fernandofauth Please, could you send me exactly steps how to reproduce this issue.

Thanks in advance
Domagoj

@jorgb90
Copy link

jorgb90 commented Jun 9, 2021

@jorgb90 you can check here. Size and color are text value and swatch value. this.options property is not undefined.

However, I've added additional config validation to the pull request.

I dont see any visual or text swatches on your link? I only see dropdowns. You should set the attributes accordingly.

@Lukas713
Copy link
Contributor

Lukas713 commented Jun 9, 2021

Hi @jorgb90 ,

size and color are changed in visual swatch and text swatch. this.options or this.options.jsonConfig properties are still not undefined, neither is config object undefined (if wrapper is used).

You can check here .

@dpotkoc
Copy link
Contributor

dpotkoc commented Jun 10, 2021

Hi @jorgb90 @pmarki @jordanvector @fernandofauth any chance to get steps how to reproduce this issue.

I will be really appreciate.

I am testing on 2.4.2 and I can't get this error. In next days we will make update on swatch-renderer-mixin.js and make it on properly Magento way.

Thanks
Domagoj

@jorgb90
Copy link

jorgb90 commented Jun 10, 2021

Hi @jorgb90 ,

size and color are changed in visual swatch and text swatch. this.options or this.options.jsonConfig properties are still not undefined, neither is config object undefined (if wrapper is used).

You can check here .

You mean its working now with your commits or also without? I havent tested your commits as of yet.

@jorgb90
Copy link

jorgb90 commented Jun 10, 2021

Hi @jorgb90 @pmarki @jordanvector @fernandofauth any chance to get steps how to reproduce this issue.

I will be really appreciate.

I am testing on 2.4.2 and I can't get this error. In next days we will make update on swatch-renderer-mixin.js and make it on properly Magento way.

Thanks
Domagoj

I am not doing anything special just have configurable products in Magento which uses swatches. As I said above I havent tested the commits created by @Lukas713 as of yet, so I guess that will fix the issue?

I havent connected anything to the Fastly service at the moment, but I can try it out today on our dev. Hopefully @pmarki @jordanvector @fernandofauth can also provide some answers.

@jorgb90
Copy link

jorgb90 commented Jun 15, 2021

@dpotkoc @Lukas713 Sorry it took a while but with your commits everything is working as expected.

@vvuksan
Copy link
Contributor

vvuksan commented Jun 21, 2021

Fixed with #457. Will be part of 1.2.158.

@vvuksan vvuksan closed this as completed Jun 21, 2021
@jordanvector
Copy link

I can confirm this is resolved in latest version 1.2.158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants