Can anyone explain to me how color swatches work when changing images? And where it is done? I want to know where in code it change images.

1 Answer 1


Magento uses attributes as swatches. That means that "color" is just the label you have for your swatch, but it could really be anything.

The basic idea is to enable this option under System > Configuration > Catalog > Configurable Swatches.

The next step is to create the configurable product using the attribute set you want. Then, under Images tab, you add new images with the same label used in the attributes page.

Here is a good tutorial with images and more details: https://sherodesigns.com/tutorial-configurable-swatches-in-magento/

About the code, you can find it under app\code\core\Mage\ConfigurableSwatches\Block\Catalog\Layer\State\Swatch.php but it is not recommended to change anything there.

  • Well that all depends. Does your theme have swatches already attributed to products? If not you would have to create an attribute for this manually. You can also look for an extension that will do this for you.
    – DevAnd
    Aug 7, 2017 at 18:24

Your Answer

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

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