1

I have my swatches working on configurable products, they are working well to add product in the cart, but I have an odd behaviour, only the photos of the first products are returned by the Ajax request.

Let's say I have 4 variations : Black, Blue, Red, Green

With the photos :

  • Configurable : Photo10, Photo11
  • Black : Photo20, Photo21, Photo22
  • Blue : Photo30, Photo31, Photo32
  • Red : Photo40, Photo41, Photo42
  • Green : Photo50, Photo51, Photo52

When I load the page, the gallery contains : Photo10, Photo11, Photo20, Photo21, Photo22 as expected.

But then, no matter which swatch I click, I always get the Black photos in return and my Gallery updates to Photo20, Photo21, Photo22.

I had a look at the ajax request using the Firefox debug tool and all requests seem to be fine sending different attributes value, but the response is always the same, giving me the photo list of the first variation.

Is there a setting somewhere that dictates this behaviour or is that plain outright bug?

Add information 2016-10-11 : If I change my attribute "Color" to be dropdown, then it all works perfectly. I also have a linked issue : I added a price block somewhere else in the page. With the swatch, only the one in the addtocart form updates, with the dropdown, both update properly.

Further update 2016-10-11 : When observing the requests, it appears that when it is a dropdown, there is no request except for the images themselves, when it is a swatch, then it has a first POST request for the image list, then for the images themselves. Why can't it use the local data like the dropdown does?

P.S. If it can help, my dev server is on Nginx and runs "behind" another Nginx server that redistribute the requests based on their subdomain.

  • What are the parameters being sent on the request, are they different on every call? – Goku Oct 4 '16 at 6:07
  • yes, parameters sent are different everytime, but the response is same. – Memes Oct 4 '16 at 8:58
  • the answer from this post actually solved my problem. magento.stackexchange.com/questions/126697/… – Memes Oct 11 '16 at 10:24
0

after further digging, the reason was that my server was too slow, it seems that the browser was getting a cached version of the AJAX call which was wrong because with other parameters. As all the data are in the initial JsonConfig object, the Ajax call is useless, so using the trick of this answer solved the issue.

-1

/app/design/frontend/{Vendor}/{theme}/etc/view.xml

Change these to false:

<vars module="Magento_ConfigurableProduct">
    <var name="change_only_base_image">false</var>
</vars>
<vars module="Magento_Swatches">
    <var name="change_only_base_image">false</var>
</vars>
  • This is done and anyway not related to my problem. See my edited initial post (I explain more). – Memes Oct 11 '16 at 2:23

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.