How to Import or Export Products in Magento 2

Adding products one by one from a Magento store can be time-consuming. You can use a CSV product upload sheet or an extension to expedite this process.

This article will show you how to import and export products in Magento 2 by importing a CSV file. We’re using Magento 2.4.1 version for this article.

How to Import Products in Magento 2

Prepare the CSV file

  1. In the Magento admin panel, navigate to System > Data Transfer > Import.

    Import in Magento admin panel
    Go to Import from the Magento admin panel

  2. In the “Import Settings,” select Products from the “Entity Type” dropdown.

    Import Settings on Import page
    Select Products from the Entity Type dropdown

  3. Click Download Sample File hyperlink.

    Download Sample File link on Import page
    Click Download Sample File hyperlink

  4. Open the catalog_product CSV file to view its contents. As you can see, the sample file has column headings with sample products data.

    CSV file
    Open the CSV file

  5. Delete all the sample data except the headings and one example product type for reference.
  6. Add the following column headings in the CSV file if not present:
    thumbnail_image_label(You can skip this step if you don’t want to add images.)
  7. Add product data in the respective rows and columns of the CSV file.
  8. Upload product images to your Magento 2 “var/import/images” folder.Note: Starting from Magento 2.3.2, the default root folder to import product images is “var/import/images.” You can also add a subfolder “var/import/images/product_images” for adding the images. Earlier, you could use a different folder as long as the folder path was specified in the “Images File Directory.”
    If you’re using an external server, upload the images to the allotted folder and make sure you enter the full URL for all images in the right column by image type. For example
  9. Confirm the size of the import file is below 2MB.

Set the Import Behavior

  1. In the “Import Behavior” field, select either Add/Update, Replace, or Delete.

    Import Behavior field on Import page
    Select option from Import Behavior dropdown

  2. Click the Validation Strategy dropdown and choose either Stop on Error or Skip error entries to control what happens if an error occurs when importing data.

    Validation Strategy field on Import page
    Select option from Validation Strategy dropdown

  3. Leave the default value of 10 in the “Allowed Errors Count” text area.

    Allowed Errors Count, Field Separator, Multiple Value Separator, Empty Attribute Value Constant on Import page
    Choose default values of Allowed Errors Count, Field Separator, Multiple Value Separator, and Empty Attribute Value Constant

  4. Similarly, accept the default value of a comma (,) in the “Field separator” and “Multiple value separator” text areas.
    A comma is the default separator in a CSV file. You can use another separator, but you need to ensure that the CSV file data matches the specified separator.
  5. Accept the default _EMPTY_VALUE_ value in the “Empty attribute value constant.”
  6. Select the “Fields Enclosure” checkbox to stop importing special characters found in the file data, such as backlashes, equal sign, and space characters.

    Field enclosure on Import page
    Select the Fields Enclosure checkbox

Add the Import File

  1. In the “File to Import” section, click Choose File to add the CSV file to import.
  2. Leave the “Images File Directory” field blank to use the “var/import/images” folder. If the images are in the “var/import/images/product_images” folder, enter “product_images” in the text area.

    Files to Import on Import page
    Click Choose File to add CSV file. Add appropriate relative path in Images File Directory

Verify the Import Data

  1. Click the orange Check Data button on the top right.

    Check Data button on Import page
    Click Check Data

  2. If the validation process has been completed successfully, you should see the following message:

    Data import validation message
    Data import validation message

  3. Click Import to import the products.
    If the file has errors, you’ll see them listed in the error message. Correct them and import the file again.
  4. Go to Catalog > Products, and check if the products with their images have been uploaded.

    Products on Products page
    Products on the Products page

How to Export Products in Magento 2

  1. Navigate to System > Data Transfer > Export on the Magento admin panel.

    Export in Magento admin panel
    Go to Export from the Magento admin panel

  2. In the “Export Settings,” select Products from the “Entity Type” dropdown.

    Entity Type dropdown on Export page
    Select Products from the Entity Type dropdown

  3. Select the default CSV option from the “Export File Format” dropdown.

    Export File Format and Fields Enclosure
    Select default CSV in Export File Format and tick the Fields Enclosure checkbox

  4. Select the “Fields Enclosure” checkbox to mark special characters as escape sequence so that they are correctly interpreted. This will prevent the export of special characters such as ampersand and pipe, which interfere with data transfer.
  5. Set up export configurations in the “Entity Attributes” section. This section lists all the attributes in alphabetical order. Use the Search and Reset filters to control which attributes are displayed.
    Entity Attributes
    Use Search and Filter to find attributes.

    To remove an attribute from the export, select its corresponding checkbox in the “Exclude” column.

    Exclude checkbox in Entity Attributes
    Use the Exclude checkbox to remove an attribute.

    To export products with specific attribute values, add the value to the “Filter” column. For example, we’ve added “Long Sleeves” in the SKU field to export only long sleeve products.

    Export products with specific attribute values example
    Export products with specific attribute values example

  6. Click on the Continue button in the lower-left corner.

    Continue button
    Click Continue

Once the export is successful, you can save or open the CSV file to edit and export it to another store.

Exported files are located in the “/var/export” folder by default. If the Remote storage module is enabled, the files can be found in “<remote-storage-root-directory>/import_export/export” folder.

Omar is a Digital Marketer and the founder of StartMarketing. He received his Master's degree from Queen's University, Belfast in 2017 and launched many successful web projects for clients since then. His expertise is in SEO, content management and social media marketing.

Leave a Comment