Magento 2 tutorials

How to CSV bulk import products in magento 2

Pinterest LinkedIn Tumblr

When installing a new Magento 2 website or migrating an existing Magento 2 website to another, you may also want to transfer all products on the old site.

You can manually move product 1 by 1 by using the copy-paste method. However, this is only viable for small stores with not too many products. Fortunately, in Magento 2, we can bulk import product using CSV, all you need to do is to fill into the importing template csv file provided by Magento 2.

This tutorial will guide you step by step through the process of bulk import products to Magento 2 using CSV file.

Step 1: Go to Import section in Magento 2 admin section

You can find Import Section in System > Data transfer > Import

data transfer import

In Entity type, select Product to import product

entity type product

Next, click on Download sample file to download csv template file to bulk import Magento 2 product

download sample csv

Step 2: Prepare CSV file which contains product data

In Import section, you can download a pre-generated CSV file which contains sample placeholder data.  In case you can’t download the file, I uploaded a file here, just click to download:

Note: If you want to specify thumbnails and small images for product, you need to add these fields to CSV file. For example:

base_image base_image_label small_image small_image_label thumbnail_image
/m/b/mb01-blue-0.jpg /m/b/mb01-blue-0.jpg /m/b/mb01-blue-0.jpg
  • Base_image: link main product image
  • Small_image: link to small product images
  • Thumbnail_image: link to thumbnail images
  • image label: image titles, you can leave these fields empty

If you want to import multiple images for a single sku, insert the images in a column named additional_images (add the column to csv file if does not exist), separated by commas. Example: product_image_1.jpg,product_image_02.jpg

In case you import product on a local server, don’t put include the path before the filename in the CSV data if you put image in the default import folder: var/import/images

 

base_image base_image_label small_image small_image_label thumbnail_image
mb01-blue-0.jpg mb01-blue-0.jpg mb01-blue-0.jpg
For example, in case product_images, files should be placed into <Magento root directory>/var/import/images/product_images folder.
This CSV template file contains every information about your product, if you need to make any changes, edit the value in the column/row

working csv file

The file size of CSV file must not exceed file size limit or the process will be failed. (We can increase file size limit later via php.ini file, if you do not know how to do this, just ask for support from hosting provider)

file size limit

If you want to set category for product, use the following format:

Categories
Default Category/Gear,Default Category/Gear/Bags
Default Category/Gear,Default Category/Collections,Default Category/Gear/Bags

If the product has multiple categories, just put a comma as a separator.

 

Step 3: Specify import options

After preparing the csv file for import, go back to import section in admin.

Now we will set import behavior

import behaivor

There are 3 types of import behavior:

  1. Add/update: No data will be remove or replace, new product data from csv file will be added to the existing product data (except SKU field)
  2. Replace: This option will replace new data with existing data if they are the same, old data will be completely removed. The value Magento 2 will look for to determine if the was an existing product is product SKU.
  3. Delete: Use this option if you want to remove existing data, any data that is existed in the database will be removed.

As we are importing product, we will select Add/Update

Next, we will set Validation Strategy for the import process

validation strategy

Select either:

  • Stop on Error: If you want the import process to be stopped when there’re error during the process
  • Skip error entries: The system will skip any errors found during import and continue the import process.

Allow error counts defines the number of errors to stop import process. Set 1 if you want to stop the import process right after the 1st spotted error.

allow errors countField separator define the type of field separtor in your csv file, leave it default if you want to use “,”

Multiple value separator define the type of field separtor in your csv file, leave it default if you want to use “,” (for example: product_image_1.jpg,product_image_02.jpg). Make sure to set this matching with the separator character you use in CSV file to avoid error.

Step 4: Upload csv import file and start import process

The last field is

If you upload images to /var/import/images then input /var/import/images in this field

image file directory

Next, click on browse and select your prepared csv file.

Finally, click on Check Data button to start validating import data. If the csv file has correct setup, the following message will be displayed:

File is valid! To start import process press “import” button

valid import

Import Magento 2 product using CSV video tutorial

In case you find it hard to follow steps in this tutorial, please watch this video to learn to how bulk import product in Magento 2 using CSV file.

Most common import issues

There may be some issues during the import process, I will list out all the issue I encountered and solution for each.

Please make sure attribute (price/shipment_type) is not empty. in row(s): 4

common import error 1

Solution: Check the row as in suggestion and fill in the desired value

Value for ‘msrp_display_actual_price_type’ attribute contains incorrect value, see acceptable values on settings specified for Admin in row(s):1

Value for 'msrp_display_actual_price_type' attribute contains incorrect value, see acceptable values on settings specified for Admin in row

Solution:Go to Stores -> Attributes -> Product and look for the values of the product attribute. Correct these values with the ones specified in CSV file

product attributeCurly quotes use instead of straight quotes in row(s).jpg

curly quotes use instead of straight quotes in row(s)

Solution: This error happens due to wrong separator format in CSV file. Check the separators and double quotes in the CSV file and add the missing values

Url key for specifed store already exists

url key for specifed store already exists

Solution: This error happens because there was a product in your web site having the same URL key as the product in csv file. To fix this add some extra characters to the product URL in csv file.

Product type is Invalid or not supported

invalid product type

Solution: Check if product type is set correctly in CSV file, the product type value should be one of the following: Simple/Configurable/Grouped/Downloadable

Value for visibility attribute contains incorrect value

value for visibility attribute contains incorrect value

Solution: The visibility attribute is not valid. The valid values in Magento 2 are:

  • 1: Not Visible Individually
  • 2: Catalog 
  • 3: Search 
  • 4: Catalog, Search

Store doesn’t exist

invalid store doesnt exist

Solution: Check if store is available, if not create a new store that matches the value in csv file

Cant find required columns

cant find required columns

Solution: The column is missing, go to your csv file and add the required column.

Wrapping up

The process of importing Magento 2 product is very complicated if you have never done it before. After some successful attempts, you will be familiar with the import process. If you have any problems during the import process, please leave a comment below. I will try my best to help you.

In the next article, I will guide you on how to import configurable products, a more complicated process. Stay updated!

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2

2 Comments

Write A Comment