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

  • Hi. Did you find any solution for this?
    – mechanic
    Commented Dec 8, 2021 at 10:30
  • Hi, it was few years ago, I guess I figured out how to do this , but I can't remember how. Commented Dec 9, 2021 at 12:33

1 Answer 1


Out of the box, when choosing options, images, price, etc will change, but custom attributes.

In order to display the custom attribute of the selected product, you can create a Plugin (Interceptor) for Magento\ConfigurableProduct\Block\Product\View\Type\Configurable::getJsonConfig() where you need to add missing custom attribute for each simple product.

Switching custom attribute when selecting an option can be implemented in vendor/magento/module-swatches/view/base/web/js/swatch-renderer.js and vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js depending on the type of attribute.

I made free VCT Product Info Switcher module which update some attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.