Saturday , November 23 2024
Home > Magento Tips & News > Magento 2 Tutorials > Catalog > How to Create Color Swatches in Magento: From A to Z

How to Create Color Swatches in Magento: From A to Z

How to Add Magento 2 Color Swatches From A to Z

Magento websites are equipped with a built-in functionality named Magento Color Swatch. This feature enables store owners to gather all the same product’s colors, materials, or textures on a product detail page without navigating through the website dozens of times. You should read this article if you are about to learn how to create a Magento color swatch. 

Alright, let’s get it kicked off.

What are Magento 2 Color Swatches? 

Magento 2 Color Swatch configurable products are selectable color options that are particularly used for configurable products. Simply put, using this functionality, you can display multiple product variants in different colors. Customers can only see the corresponding product image with a single click on any color swatch. 

In addition, Magento 2 Color Swatches can be used in many places on a site, such as product pages, category pages, search pages, and layered navigation. 

Magento 2 color swatches on the product page
Magento 2 color swatches on the product page
Magento 2 Color swatches on the search page
Color Swatches Magento 2 on the search page
Magento 2 Color swatches on the  category page
Magento 2 color swatches 2 on the category page
Magento 2 Color swatches in the layer navigation
Color Swatches Magento in the layered navigation

Many people have misunderstood that Magento 2 Color Swatch is applied to colors only. In fact, eCommerce merchants also utilize this functionality for other configurable swatches like fabric or texture. 

Build a comprehensive catalog for your eCommerce store:
Magento 2 Simple Product with Custom Options vs. Magento 2 Configurable Product
How to Configure Magento 2 Custom Options in Detail
Magento Grouped Product vs Bundle Product: Key Differences

Benefits of Using Magento 2 Color Swatch

As mentioned above, Magento 2 Color Swatch is a solution that makes it much easier for customers to select their favorite among available colors on the same product page. They now don’t have to spend much time wandering around the website, going back and forth between the catalog and product pages, or reloading the web pages thousands of times. Using Magento Color Swatches helps increase customer experience, resulting in a high conversion rate. When shoppers find the variant they like most with fewer clicks, it’s a high possibility that they will make a quick purchase. 

Moreover, swatches offer customers a great picture of what variants are in stock. As a result, buyers don’t need to ask sellers whether or not this variant is available. Convenient, isn’t it? 

Magento 2 Color swatches helps customers know what variants are in stock helps

2 Steps to Add Magento 2 Color Swatches

Oh, wait. Let me outline my plan first so that you’ll find it easier to catch up. Assume I have a configurable product named Gobi HeatTec (Jane Test), which has variants in 3 different colors: black, orange, and red. I want to add an extra color swatch, “Dark Green,” to this product’s detail page. Here are the main steps: 

  • First, we’ll create an additional color swatch, “Dark Green,” in the Color attribute. 
  • Then, we’ll update or assign this swatch to the product in either of the two ways below: 

+ Update the product individually 

+ Update the product in bulk

Okay, let’s start.

Step 1: Create a Magento 2 Color Swatch

Choose one of the two methods below to create swatches for products:

  • Use Colors
  • Use Images

Method 1: Use colors

Preparation: Identify the exact color for a product by using the eyedropper tool. Then, copy the equivalent hexadecimal value and save it for later use. 

  • From the admin sidebar, navigate to StoresAttributesProduct.
Where to find Magento 2 Color swatches
  • You will be redirected to the Product Attributes grid page—type “Color” in the Search box of the first column. Then click on the Color row to edit the attribute.
Where to find Magento 2 Color swatches 1
  • Set the field “Catalog Input Type for Store Owner” to Visual Swatch.
You may also be interested in the following:
Get to Know Magento Attribute Input Types with Examples
Visual Swatch input type
  • If you set “Update Product Preview Image” to Yes, the corresponding product image will be updated when customers select a certain swatch option. For example, if the customer picks the red swatch, the product image will be updated to the red T-shirt (Image 1).

If you set No for this field, the product image remains unchanged regardless of your select swatches (Image 2).

Image 1: Set “Update Product Preview Image” to Yes
Set Update Product Preview Image to Yes
Image 2: Set “Update Product Preview Image” to No
  • Under the Manage Swatch section, click Add Swatch and follow the steps below:
Manage Swatch
  • In the column named Swatch, have a click on the new swatch. Then, select Choose a color to pick the color.
Use Color for Magento 2 Color Swatches
  • In the color picker, enter the hexadecimal value of the new color you prepared. Then, to save the color, click on the multi-color icon below.
Use Color for Magento 2 Color Swatch 1
  • You can enter the translated color name in the store’s language if you are running several stores.
  • Select the default swatch in the front store in the column named Is Default.
  • If you want to change the swatches’ order, drag them and drop them in your desired position.
Change the order of Magento 2 color swatches
  • After you’ve finished, hit Save Attribute. Don’t forget to clear the cache.

Optimize Your Magento Store With Powerful Extensions!

Looking for fast, efficient, and well-coded extensions to build or optimize your Magento stores for sales-boosting? Then visit the Magezon website and grab the necessary add-ons for yours today!

Method 2: Use images

First, you need 3 product images representing the colors, patterns, or textures. Ensure you save the images in square format to maintain the aspect ratio. 

  • From the Admin sidebar, navigate to Stores → Attributes. Then, choose Product.
  • You will then be redirected to the Product Attributes grid page. Type “Color” in the first column and edit this attribute.
  • Select Visual Swatch for the field “Catalog Input Type for Store Owner.”
  • In the “Update Product Preview Image” field, select Yes if you want the corresponding product image to be updated when customers select a particular swatch option. If not, choose No.
  • Under the section Manage Swatches (values of your attribute), follow the steps below:
  • In the column named Swatch, click on the new swatch. Then, select Upload a file.
Use Image
  • Select the swatch image that you prepared in advance and then upload it. Next, repeat these steps for the other files. 
  • Drag the swatch if you want to change the order of the swatches.
  • After finishing, click Save Attribute. Remember to clear the cache.

Step 2: Update the Products

  1. Update the product individually
  • From the Admin sidebar, go to the Catalog → Products.
  • Open the product in edit mode. 
  • Scroll down to the Configurations section. Then, click on the Edit Configurations button.
Update the product
  • Select the attributes that you want to apply to this product. In this case, I choose the attributes: Color and Size. Then, click Next.
Update the product 1
  • I still keep everything as initially except tick the checkbox of Dark Green.
Tick the checkbox of Dark Green.
  • Click Next to move on to the next step: Bulk Images, Price, and Quantity. In this example, I will only set up Images so that the corresponding image will appear when customers select a particular color swatch. (You can customize Price and Quantity if you want).

In this case, I choose to Apply unique images by attribute to each SKU

 Apply unique images by attribute to each SKU

In the Select Attributes field, choose Color. Then, upload the corresponding images for each color swatch.

Apply unique images by attribute to each SKU 1

Click Next. And lastly, hit Generate Products. Then, you will be returned to the product edit page. Click Save and check the result on the front end. 

Magento 2 Color Swatches on the frontend

Note: If you haven’t seen the new color swatch after the steps above, you need to check the stock status of the configurable product and its child products (In stock, Out of stock).

Let me explain. If you set the Display Products Availability in Stock on the Storefront field to Yes, it means, only products that are in stock will appear on the storefront (Image 3).

Read more: How to configure Magento 2 inventory management in detail

 Display Products Availability in Stock on Storefront

If the configurable product or its child products are set to Out of Stock on their product edit page, they will not be shown on the front end.

  1. Update the product in bulk
  • From the Admin sidebar, navigate to Catalog. Then, choose Products.
  • In the Product grid, tick the checkboxes of products to which the swatches are applied.
  • Set the Actions to Update Attributes
Update the attribute 1
  • After that, you will be redirected to the Update Attribute page. Scroll down to the Color. Mark the Change checkbox and select Dark Green to assign this swatch to the product.
Update the attribute
  • After you’re done, click Save, and don’t forget to clear the cache.

And, let’s check Magento 2 Color Swatches on the front end.

Magento 2 Color Swatches on the frontend 2

Wrap It up

That’s all about Magento Color Swatch that you need to know. I hope this helps. If you need further clarification, feel free to leave a comment right below. To learn more about Magento 2 knowledge and keep yourself updated with the latest news on Magento Tips & News.

If you are searching for extensions that help skyrocket the sales for your store, visit the Magezon website to pick your wish one.

Optimize Your Magento Store With Powerful Extensions!

Looking for fast, efficient, and well-coded extensions to build or optimize your Magento stores for sales-boosting? Then visit the Magezon website and grab the necessary add-ons for yours today!

About Nga Dong

Nga Dong
A content writer and marketer in Magezon

Check Also

Magento 2 Simple Product With Custom Options vs. Configurable Product

When selling products in different colors, sizes, and materials to select, you need to use …

Leave a Reply