Why invest time in uploading individual products, when we can bulk upload products just at one go! Magento 2 provides an efficient method to import products using CSV (Comma Separated Value file). It allows you to add or update the products, replace existing data and delete entities. All you have to do is follow the standard format of CSV, and you are all set to import products. In this tutorial, we provide step by step guide to import and export products in Magento 2. Let’s get started!
In this tutorial, you’ll learn how to:
How to Create CSV File?
To import bulk product basic requirement is a CSV with product details. You can either create your CSV or use sample CSV provided by Magento 2.
To create own CSV:
- Decide which attributes of product you want to include in CSV as column headings
- Make sure you use Attribute_Code of the attribute you want to include, example: product description has description attribute code
- To check the attributes, go to Stores => Attributes => Products.
- Not all attributes are mandatory fields for adding products. You can keep your CSV minimalistic to keep it straightforward and clear to understand, as you can see the required column in the image above.
- List of Required Fields:
- sku, attribute_set_code, product_type, categories, product_websites, name, description, weight, product_online, visibility, price, url_key, qty, is_in_stock, base_image, base_image_label, small_image, small_image_label, thumbnail_image, thumbnail_image_label.
- Note: Url-key has to be unique. If you skip the URL key, Magento 2 will generate URLs based on the product name.
What is the significance of fields?
- SKU: It stands for Stock Keeping Unit. This value will uniquely identify the product.
- Attribute_set_code: If you have any particular attribute set, you should put the attribute set name here. Assign default, if no other attribute set is present.
- Product_type: Magento 2 allows you to add multiple product types, for example, configurable product, simple product, downloadable product, etc. Mention the product type in this field.
- Product_websites: If you have multiple websites, for example, UK site you will have to put that value here. If you have only one website, write base as value.
- Description: Product description.
- Visibility: Where do you want to list the product? If you want to list product in category as well as display in search result, choose catalog, search.
- Url_key: This value must be unique, skip it to let Magento generate it for you.
- Qty: Number of products available in stock.
- Is_in_stock: Stock Availability.
- Base, small, thumbnail images: provide image path here, relative to var directory.
- Image label: This is the alt text for images.
How to Download Sample CSV?
Magento 2 import provides sample CSV sheet for importing. You can refer that for generating custom CSV.
Step 1: Go to System => Import
Step 2: Click on Download Sample File button to download sample CSV
The sample CSV would look like this:
You can reduce columns, keeping in mind the required fields mentioned in this article earlier.
The final CSV will look similar to this:
How to Import CSV?
Step 1: Go to Admin Panel => System => Import
To import products, select products in Entity Type drop-down.
Step 2: Select import behaviour:
- Add/Update – This will add new data to existing products, or if they don’t already present in the store, it will create new products. The only field that can’t be updated is SKU.
- Replace – New data will replace the Existing data (product already present in the store).
- Delete – Product will be eliminated from the database if product SKU is present in the store.
- Data Validation – Magento 2 performs data validation on the CSV file. You can check your data (dry run) before running the real import or choose whether or not the import process should stop on error.
Step 3: Next, select your Field Separator and Multiple Value Separator.
Default field separator is a comma. Hence you should avoid putting a comma in the category names otherwise it will create a new root category.
Step 4: After completion, select your file and press Check Data.
Step 5: Once Magento has validated your data you should receive a ‘File is Valid’ message, press Import button.
Once completed, you’ll receive the following message ‘Import successfully done’.
Hurray! You have successfully imported your products. Make sure you test your product data thoroughly.
How to Export Products in Magento 2?
In the admin go to System => Export (Select Entity Type = Products) –
The product export page lists all available product attributes for export. By default, Magento will export all 84 available attributes. However, there is an easy way to choose which attributes you want to export selectively.
In the above screenshot, you’ll notice an Exclude column on the left-hand side of the grid. Ticking the box next to a given attribute will exclude this attribute from the product export.
Skimming through one row at the time, remove as many unnecessary attributes as possible. It’s entirely up to you to decide which product attributes are relevant (to you) and which aren’t.
After the optional attributes are selected, click the Continue button to download your CSV file.
Hope this tutorial helps you to utilize power pack import and export functionality. Thanks for reading.