Tutorial: Configuring Magento 2 Swatches

magento ecommerce

While swatches in Magento 1.x were available, they have seen a major usability upgrade in Magento 2 for both CE and EE. The management of configurable swatches has become more clear and straightforward, meaning as a retailer it’s easier to take full advantage of them.

Visual swatches

Firstly, the visual swatch can be used to show a products colour, pattern, and texture. You can configure this as a hexadecimal colour, if the product is a flat colour, or you can upload an image, if the product has a pattern or texture.

Magento Swatches

Text based swatches

Secondly, there are text-based swatches. If a specific image or colour isn’t available for a swatch, the attribute value appears as text. These behave in the same way as a visual swatch. For example, you could use a text-based swatch to show available sizes of a configurable product. If the size isn’t in stock, then it is crossed out.

Magento Swatches

Why use swatches

Using swatches on product pages can really enhance your customer’s experience online. By showing stock availability for attributes such as colour, pattern and fabric options on the product page you not only reduce the number of clicks to purchase, but increase the likelihood of conversion by displaying all available options and variants.

The great thing about Magento’s product swatches is that once implemented, they also become available as a filter in your layered navigation on anchor categories. Improving overall usability, this feature then enables potential customers to filter your product catalog by colour and a range of other attributes to refine their search.

How to configure swatches in Magento 2

Step 1: Create the Swatch

There are two main methods to create swatches;

  • Add a Colour Swatch
  • Upload a Swatch Image

Adding a Colour Swatch

You’ll need to group your products by colour range, for example, all red products together. You’ll then need to select red swatch you want to apply to all red products – write-down the hexadecimal colour value you want to use for each swatch.

Want to use a sample colour from a product? Open your product image in a photo editor such as Photoshop and use the eyedropper tool to identify the exact colour and hexadecimal code.

Magento Swatches

To apply your chosen colour to the swatch, go into your Magento 2 admin panel, Click “stores” and under “attributes”, choose “product” and then open to “colour” attribute.

Set “catalog input type for store owner” to Visual Swatch.

Under “manage swatch”, click on “add swatch”.

Magento Swatches

In the swatch column, tap the new swatch and select “choose a colour”.

In the colour picker, select the # field and enter the hexadecimal colour code you wrote down earlier for 1 of your colours.

Then, to save the new swatch, tap the colour wheel in the lower-right corner of the colour picker.

In the admin column you can enter a label to describe the colour.

Magento Swatches

Repeat these steps for all your colours.

In the “is default” column, you can select a swatch that you want to be the default option where a specific colour swatch has not been applied e.g. multi-coloured. This is not required.

If you want to change the order of swatches you can simply just drag them into position.

Lastly, click “save attribute” and then clear the cache.

Upload a Swatch Image

To capture an image for a swatch, save a smaller square image of the product that shows the colour or pattern you want. Typically this will be zoomed in. The size and dimensions of the swatch is determined by the theme, however, saving an image as a square will help to preserve the aspect ratio of a pattern.

Next, go into your Magneto 2 admin panel, click “stores” and under “attributes”, choose “product” and then open the “colour” attribute.

Set “catalog input type for store owner” to Visual Swatch.

Under “manage swatch”, click on “add swatch”.

In the swatch column, tap the new swatch and select “upload a file”.

Magento Swatches

Choose the file you prepared earlier.

Repeat these steps for all swatch images.

In the admin column you can enter a label to describe the swatch image.

Lastly, click “save attribute” and then refresh the cache.

Step 2: Update Your products

The final step is to open each product in “edit” mode, and update the “colour” attribute with the correct swatch. To update multiple products at the same time see the steps below.

Go into your Magento 2 admin panel, and click “products”, then under “inventory” click “catalog”.

Filter the list by Name or SKU to make sure that only the products you want to apply the swatch to are visible.

Select all products in the grid that you want to apply the swatch to by ticking the checkbox.

Then set the “actions” list to “update attributes”.

Magento Swatches

Scroll to the “colour” attribute and tick the “change” checkbox.

Select the swatch to want to apply, click “save” and refresh the cache.

Do You Need Any Other Magento Help?

If you need any help with regards to your Magento store, we are certified Magento 2 solution specialists, and are happy to help you with anything you need. Why not give us a call today on 01183 805 705, or visit our website.

Find out more