Log in
Helper

Data

Magento\Swatches\Helper\Data

What it does

This helper class provides utility methods for working with product swatches in Magento 2.

Developers use it to retrieve swatch attributes from configurable products, load product variations based on swatch selections, get swatch images and media galleries, and check if products or attributes have swatch configurations.

It's essential when building custom product displays or handling swatch functionality in templates and plugins.

Public Methods

  • assembleAdditionalDataEavAttribute()
  • loadFirstVariationWithSwatchImage()
  • loadFirstVariationWithImage()
  • loadVariationByFallback()
  • getProductMediaGallery()
  • getAttributesFromConfigurable()
  • getSwatchAttributesAsArray()
  • getSwatchesByOptionsId()
  • isProductHasSwatch()
  • isSwatchAttribute()
  • isVisualSwatch()
  • isTextSwatch()