How to import Magento 2 product images and swatches

swatch and image import

Lack of decent product content is what prevents ecommerce businesses from booming. The years of industry growth have proved crucial the support of offers with a trustable and detailed visual representation. Thus, your store can deem credible to any visitor. In addition, engaging audio and video, catchy images, and other multimedia themselves can become solid marketing tools. 

To show you how to enrich your site content, below, we are going to discover the ways to create visual/color swatches and to import them as well as product images into a Magento 2 store.

'

Guide to Magento 2 swatches

The configurable products are a great way to provide flexible offers in your store. Product variations help appeal to all types of customers and increase sales significantly. That’s why it is imperative to present masterfully all the options that define configurable products in your store. Visual swatches serve the very illustrative purpose and allow you to support configurable product variations with display images of color, pattern, material, etc. 

Visual swatches in Magento 2 are images and color icons that provide information about product variations. Similar to size, swatches are unique attributes available for configurables that enable frontend selection interactions with such products. 

Swatches assist in enhancing user experience at your store. Swatches of configurable products are visible at the product page and anywhere in the catalog, including layered navigation. Once a customer gets a clear understanding of what they are going to buy and can select the desired option in a few clicks, successful order placement becomes the most plausible result. 

Creating a swatch

New visual swatches can be added to the database at Stores > Attributes > Product > Add New Attribute

You need to give a swatch attribute title and select ‘Visual Swatch’ from the attribute type dropdown.

swatch attribute

By default, swatches can be created in two ways:

  • Select a color out of the palette;
  • Upload a swatch as an image;

Improved Import and Export allows users to import visual/color swatches to Magento 2 via URL. This is the most efficient way as you can retrieve product images right from the manufacturer’s side or relevant web sources without the need to store the images at your own hardware.

If you possess in-depth knowledge of Magento 2 you can configure extra swatch properties for both backend and frontend management.

swatch generation

Keep in mind that Magento 2 supports text swatches as well. The text swatches generation is similar to that of visual swatches. You can transfer them following the steps of the visual swatch import we describe below.

Magento 2 swatch import

Magento 2 visual swatches can be imported following two different logic patterns: as a single color attribute or within additional attributes of a configurable product. Both types allow implementing a swatch via a particular HTML color code or an image URL. 

Swatch import within the color attribute can be run upon defining the base attributes: sku, attribute_set_code, color in the import data table. See the table below for details.

Visit the Sample Google Sheet

Attribute name Reference Values Value example
sku A unique value that is used to identify the product. The only mandatory field. SKU is the first field of the table and canNOT be removed.

Supports letters, numbers, signs “-“, “_”. Can be up to 64 characters in length. Can not contain white spaces. 

Mind the letter case!

You can find SKUs for products already in the catalog at Catalog > Products.

downloadable-1
attribute_set_code Defines Attribute Set assigned to the product. It should look exactly the same as an attribute set name including capital letters (e.g. “Default”, “Man shoes” etc.)

Attribute set name can be found under Stores > Attribute Set

attibute_set_code – is the default value for this column.

This is also a mapping column containing ALL available product attributes, in case you need a quick reference to map data.

default
color An attribute that specifies product color. Any color name, color code, or URL. Can include special signs. Values should be divided by a vertical bar “|”.

Visual swatch as a color attribute value contains extra syntax:

type=1 — defines color code import

type=2 — defines import via image URL

Blue Navy|type=2|value=

https://firebearstudio.com/blog/wp-

content/uploads/2014/10/

Firebear_logo_294x84_quer.png

 

Gray|type=1|value=#ffffff

 

The data table for transferring swatches requires adding the additional_attributes column to the product import table. In this case, the swatch values will have the same syntax as the color attribute during the single swatch attribute import. The base attributes for such import are sku, attribute_set_code, additional_attributes; they must be specified for a successful swatch data implementation.

See the Sample Google Sheet

Magento 2 swatch image is extremely useful when you need to save time on creating and applying swatches to products manually. During import you can both generate new swatches or assign the existing ones to SKUs of configurable data variations in data files. There’s no need to add a parent configurable to an import table, as the functionality matches swatches to specified SKUs.

Magento 2 product image import

Product images in Magento 2 are essential for presenting your products on the store pages and highlighting them in the catalog and search results, during the promotions, etc. 

As an attribute the product image, whether it is base, thumbnail, or any other kind, is tightly connected to product SKU and Attribute Set. These are primary attributes that are needed for composing a data table for product image import.

 

Attribute name Reference Values Value example
sku A unique value that is used to identify the product. The only mandatory field. SKU is the first field of the table and canNOT be removed.

Supports letters, numbers, signs “-“, “_”.Can be up to 64 characters in length. Can not contain white spaces. 

Mind the letter case!

You can find SKUs for products already in the catalog at Catalog > Products.

downloadable-1
attribute_set_code Defines Attribute Set assigned to the product. It should look exactly the same as an attribute set name including capital letters (e.g. “Default”, “Man shoes” etc.)

Attribute set name can be found under Stores > Attribute Set

attibute_set_code – is the default value for this column.

This is also a mapping column containing ALL available product attributes, in case you need a quick reference to map data.

default
Base_image, 

additional_images, 

small_image, 

thumbnail_image, 

swatch_image (in case product image is used as a swatch)

The file names of any additional image or URLs, to be associated with the product. Should be separated with commas.

Image files should be uploaded to  /pub/media/import.

The path of /sample_data/m/b/mb01-blue-0.jpg has the following structure: /pub/media/import/sample_data/m/b/mb01-blue-0.jpg

In addition, you can use a direct URL of an image, such as http://site.com/images/some_image.jpg

http://site.com/images/

some_image.jpg

 

Don’t forget that you can support import images with the following attributes: base_image_label, additional_image_labels, small_image_label, thumbnail_image_label, swatch_image_label to add the alt text to them.

Explore the Master Google Sheets Table

Images are irreplaceable means for product visualization, however, large catalog management can take much longer than one can expect. That’s why Improved Import and Export for Magento 2 has been embued with the ability to apply values to multiple attributes at a time. Maximum automation of product image import helps you to save time and efforts during migrations, synchronizations, and any kinds of database updates.

Import job configuration

As you’ve seen above, the most efficient swatch and image import can be performed only with the help of Magento 2 Improved Import and Export. The extension introduces advanced functionality that enables fast and error-free data transfers following unique logic for each Magento 2 entity. 

Improved Import and Export uses jobs — rules for data extraction and implementation — for transfer configuration. You can find the job grid at System > Improved Import/Export > Import/Export jobs.

With the extension, you can experience both manual and automatic import and export. Set up cron to schedule an import job once and get the updates done by the functionality alone.

Both swatch and product image import are run on the base of the ‘Products’ entity. So you need to select the relevant entity type to let the extension decide on the process logic.

product entity

If you want to create swatches on the spot, specify the ‘Add/Update’ as the import behavior. In case you want to replace existing swatches or product images, choose the ‘ Replace’ option.

Import source selector is another extension feature that allows you to stay flexible during any transfer. You can import data from REST & SOAP API, Google Drive, Google Sheets, FTP/SFTP, URL, Dropbox, or direct file upload

Speaking about the file formats supported, we can’t help but note that Improved Import and Export is the only solution that gives you the ability to manage data the way you are most comfortable with. The swatch and product image import are available for data tables in:

  • CSV, 
  • XML, 
  • XLSX, 
  • ODS, 
  • JSON, 
  • ZIP and TAR.

Once the core features are set up and the data file validated, you can map attributes massively. The mapping functionality supports any kin do modification to attribute values, allows you to translate content, round prices, and even create configurable products on the fly (with the Magento 2 Improved Configurable Products integration).

All in all, you can significantly simplify the database update routine with Improved Import and Export while still reaching out to customers with strong visual content and interactive offers. Try out the extension and see how much you can benefit from a single data management solution.

 Get Improved Import and Export

'