Magento 2 How to dynamically change custom attributes when click on the color attributes in the configurable product?

by Pavlo Bezuhlij   Last Updated June 01, 2019 21:09 PM

I need dynamically change custom attribute on the configurable page when I click to the swatch color attribute. On this purpose I programmatically created custom attributes with options on the admin panel, where I can save for every product his own custom attributes.

I figure out how to call my custom attributes on simple products but I can't to do this with configurable product.

I see when I change color attribute - price is changed for every simple product(it's default thing), how to do same but with my custom attributes?

I have one idea but I don't know how this one implement. So I know how to get current product id when you clicked on the color attribute(through js code) then I need pass this id data to the controller via ajax. I need to know how exactly to do this, how to pass js data through ajax to controller and then call needed block on the category page every time when I click on the color attribute? ? When I will be know how to do that I get with this id data - custom attribute values and call this template in the needed place.

So main question is: How to dynamically change custom attributes when click on the color attributes in the configurable product? And does it exist another way to achieve this ? But if you have another solutions I ready to apply them.

enter image description here



Related Questions




Change More product images on color swatch select

Updated August 06, 2015 15:04 PM