Tutorials Of 4 Simple Steps In Magento 2 Import Products
Vinh Jacker | 08-25-2016
Magento 2.0 allows you to Import Products data to add or update the products, replace existing data and delete entities. This feature helps save a lot of time compared with manually configuring. Actually, almost data in Magento is contained in CSV files (Comma Separated Value file) which appear similar to Excel files but simpler. Therefore, we recommend you become familiar with CSV files to import and export other types of data besides products such as customer data, customer address data and product images. Below is a comprehensive guide to importing products in Magento 2.
The structure of CSV file
2M maximum is often the default size of the import file. Understanding the detailed description of the column in the CSV file structure is necessary for store owners when importing Magento 2 products. Below is a basic list of items in the CSV file:
- sku – an ID used as a key product attribute in the Magento 2 core. It is unique for each product. SKU can contain digits and letters without spaces and is separated with underscores (_) and en dashes (-).
- store_view_code – an associated store view code. The column will have no data if an associated store or website has a single sub-item.
- attribute_set_code – defines the product to a specific attribute set or product template. You need to create and arrange an attribute set before importing products.
- update_attribute_set – defines whether the product set is updated for the product during the Magento 2 import/export product.
- product_type – the type of imported products. Use only lowercase letters (simple, configurable, grouped, etc.). You can learn about Magento product types clearly with the tutorials for beginners.
- categories – Magento 2 product categories are different from Magento 1 ones. In this system, comma-separated category IDs are used, and full names of assigned categories, including full path, are required.
- product_websites – an associated product website code. Use lowercase letters only (e.g., “base”).
- name – a product name
- description – a product description with color, shape, size,…
- short_description – a short description of a product. Description and short description can include valid HTML tags.
- weight – weight of a product. Always use the following format 1.00000.
- product_online – enables or disables products. Use 1 or 0, respectively.
- tax_class_name – a product tax class. Allows using capital letters and spaces, like in Magento 2 backend, e.g., “Taxable Goods”
- visibility – visibility of a product, e.g., “Catalog, Search”, “Not Visible Individually” etc.
- price – a price of a product, e.g.,. 36.000.
- special_price – a special product price
- special_price_from_date – the beginning date when the special price is applied, e.g., ‘2022-01-02 11:22:30’.
- special_price_to_date – the last date when the special price is applied, e.g., ‘2022-05-02 11:22:30’.
- url_key – an URL key of the product. If there is an empty field, a value is set up automatically based on a product name.
- meta_title – a meta title of a product
- meta_keywords – product meta keywords
- meta_description – a product meta description
- base_image – the image of the key product. It should be uploaded to /pub/media/import. For instance, the path of /sample_data/a/b/ab02-gray-0.jpg has the following structure: /pub/media/import/sample_data/a/b/ab02-gray-0.jpg. Moreover, you can use a direct URL of an image, such as http://site.com/images/some_image.jpg.
- base_image_label – a label of a base product image
- small_image – a name and a path related to a small product image. It should also be uploaded to /pub/media/import.
- small_image_label – a label of a small product image
- thumbnail_image – a name and a path associated with a thumbnail product image. The image should be uploaded to /pub/media/import as well.
- qty – denotes the quantity of product that is in stock.
How to Import Products in Magento 2
Step 1: Prepare the Data
First, you have to prepare your data.
- Log in to your Magento 2 Admin Panel, go to
System > Data Transfer > Import
.
- In the Import Settings section, select the Entity Type to import (e.g, products) and upload your prepared CSV file as you are importing product data.
- After selecting the Entity Type, click
Download Sample File
. If you are prompted, clickSave
to start downloading the file.
- Open to view the sample file.
- Make sure that your CSV import file follows the sample file exactly.
- Confirm that the size of your import file does not exceed the limit shown in the message which is usually informed to be 2M.
- If the import data includes paths to product images, make sure that the image files have been uploaded to the appropriate location. The default location on the Magento server is
pub/media/import
. If the images reside on an external server, make sure that you have the full URL to the directory that contains the images.
Step 2: Configure Import Behavior
The Import process includes many requirements. Therefore, you need to configure the behaviors beforehand:
- In the Import Behavior section, choose the action you want when importing data in the Import Behavior field: “Add/Update”, “Replace Existing Complex Data” or “Delete Entities”. Then set the following field to “Stop on Error” or “Skip Error Entries”.
- In the Allowed Errors Count field, enter a number of errors to pause the import process.
- In the Field separator and Multiple value separator fields, leave the default as “,” since the default separator in CSV file is a comma.
- In the Empty attribute value constant field, enter ‘EMPTY__VALUE.’
- Select the Fields Enclosure checkbox if you want to enclose special characters for escape sequences.
Step 3: Specify the Import File
Next, you will upload the file from which you want to import data.
- In the File to Import section, click on the
Choose File
button and choose your import data file, then clickOpen
. - If the import data contains paths to product images, in the Images File Directory field, enter:
- The path to the uploaded images on the Magento server. For example:
var/import
. - Or the full URL of the images on another server. For example:
http://domain.com/images
.
- The path to the uploaded images on the Magento server. For example:
- For Type Local Server, use a relative path to:
<Magento root directory>/var/import/images
.- For example, if uploading product_images, place the files in the
<Magento root directory>/var/import/images/product_images
folder.
- For example, if uploading product_images, place the files in the
- If using remote storage, store the files:
<Remote Storage>/var/import/images/product_images
folder.
Step 4: Check the Data and Finish the Importing
To complete the import process, the imported data needs to be checked:
- In the upper-right corner, click
Check Data
and wait for the process to complete. - If the file is valid, click the
Import
button shown in the Validation Results. Contrarily, correct the problem informed in the message and try again. - When the importing completes, there will be a message to notify you.
3. How to View the Import History
Now, all of the import history can be viewed in the backend:
- Log in to your Magento 2 Admin Panel, go to
System > Data Transfer > Import History
. - The import history detail table will show all import/export actions for you to track.
Common Magento 2 Import Validation Errors to Watch For
Now that you understand how to bulk upload products in Magento 2, let’s explore some common errors you might face during the import process. While some issues can be resolved independently, others may require professional assistance, such as a Magento store audit.
Incorrect Visibility
This issue arises when invalid values are entered in the visibility field. Ensure the field contains valid options such as Catalog, Search, or Catalog and Search, depending on where the product should appear. Double-check and correct the CSV file to prevent this error.
What can you do? When encountering an incorrect visibility error during a product import in Magento 2, follow these steps to fix it:
- Verify the CSV File:
- Open the import file and locate the visibility column.
- Ensure it contains only valid values:
- 1 for Not Visible Individually
- 2 for Catalog
- 3 for Search
- 4 for Catalog and Search
- Correct Invalid Values:
- Replace any incorrect or invalid entries with the appropriate value from the above options.
- Set a Default Value (Optional):
- If the visibility column is missing in some rows, set a default value (e.g., 4 for Catalog and Search) for these products before re-importing.
- Revalidate the File:
- Use Magento’s Check Data functionality under System > Data Transfer > Import to ensure the file is error-free before proceeding.
- Update Visibility Post-Import (If Needed):
- After importing, you can manually adjust the visibility of products via the admin panel:
- Navigate to Catalog > Products.
- Edit the product, set the visibility, and save.
Invalid Separator or Format
This error occurs when the CSV file used for import does not adhere to Magento’s formatting requirements or when the separator character (e.g., comma, semicolon) is incorrect.
What can you do? To resolve this issue:
- Verify the File Format:
- Ensure the file is saved as a CSV (Comma-Separated Values) file.
- Use UTF-8 encoding for compatibility with Magento.
- Check the Separator Character:
- Magento requires commas (,) as the default separator. If the file uses a different character (e.g., semicolon ;), update it to use commas.
- Adjust the separator settings in your spreadsheet editor or use a text editor to replace incorrect separators.
- Match Magento’s Sample File Structure:
- Download Magento’s sample CSV file from System > Data Transfer > Import.
- Compare your file with the sample to ensure all required columns and separators are correctly set.
- Validate the File:
- Use Magento’s Check Data feature under System > Data Transfer > Import to identify any remaining formatting errors before importing.
Different Number of Fields and Product Info
This error occurs when the number of columns in the header row of your CSV file does not match the number of fields in the product rows, leading to a mismatch during import.
What can you do? To resolve this issue:
- Check the Header Row:
- Ensure the first row of the CSV file contains all the necessary column headers.
- Each column in the header row should have a corresponding value in the product rows.
- Validate Product Rows:
- Verify that each row of product data contains the same number of fields as defined in the header row.
- Look for missing values or extra commas that might shift data into incorrect fields.
- Remove Empty or Extra Columns:
- Delete any blank columns that do not correspond to product attributes.
- Ensure there are no extra commas at the end of each row.
- Match Magento’s Sample Structure:
- Compare your CSV file with Magento’s sample import file to ensure all required fields are present and correctly aligned.
- Test with a Small Sample:
- Before importing the full file, test with a smaller sample file to confirm the field alignment is correct.
Invalid Product Type
This error occurs when the product type specified in the CSV file is not recognized or supported by Magento 2. Each product in Magento must have a valid product type, such as simple, configurable, virtual, bundle, grouped, or downloadable.
What can you do? Here’s how to resolve this issue:
- Check the Product Type Column:
- Ensure the type column in your CSV file contains valid Magento product types.
- Common valid types include:
- simple
- configurable
- virtual
- bundle
- grouped
- downloadable
- Correct Invalid Entries:
- Replace any incorrect or unsupported values in the type column with a valid product type.
- Match Attribute Requirements:
- Ensure that the attributes provided in the CSV match the requirements of the specified product type.
- For example:
- A configurable product requires associated simple products.
- A downloadable product needs additional downloadable file information.
- Validate the File:
- Use Magento’s Check Data feature under System > Data Transfer > Import to identify and fix any errors related to product types.
- Test a Small Batch:
- Import a small set of products to verify that the product types are recognized correctly.
Incorrect Value of the Select Fields
This error occurs when the values in the select-type fields (e.g., dropdown attributes) in the CSV file do not match the predefined options set in Magento. Select fields must contain valid values that correspond to the attribute’s available options.
What can you do? To resolve this issue:
- Verify Attribute Values:
- Check the select field attributes in Stores > Attributes > Product.
- Ensure that the values in the CSV file match the predefined options for the attribute.
- Correct Invalid Entries:
- Replace any incorrect values in the CSV file with valid options defined in Magento.
- For example, if the attribute “Color” has options like Red, Blue, and Green, the CSV must use these exact values.
- Use Attribute Option IDs (Optional):
- In some cases, Magento allows using attribute option IDs instead of text values. Refer to your attribute’s settings to find the corresponding IDs.
- Standardize Input Data:
- If your CSV file was exported from another system, ensure the select field values align with Magento’s predefined options.
- Validate the File:
- Use the Check Data feature in System > Data Transfer > Import to identify and correct invalid select field values.
- Create Missing Options (If Needed):
- If your import requires new options that don’t exist in Magento, create them in the attribute settings before importing.
Tips for Successful Magento Product Import
Importing products into Magento 2 requires careful planning to ensure accuracy and efficiency. Here are some practical tips to streamline the process:
1. Customizing Import Profiles
Customizing import profiles lets you define specific settings and mappings for different data types, such as customer information or product attributes. This ensures the imported data matches Magento’s requirements.
- Map CSV columns to Magento attributes (e.g., SKU, price) for accurate data alignment.
- Set default values for fields not included in the import file to save time and reduce errors.
- Configure profiles based on your specific needs to ensure all product data is imported correctly.
2. Preventing Errors and Data Loss
Minimizing errors is critical for a successful import. Follow these steps to reduce risks:
- Match each product to its corresponding attributes to ensure data accuracy.
- Validate your CSV files to check for missing or incorrect values.
- Remove duplicates and ensure all required fields are filled.
- Regularly back up your store data to prevent losses.
- Use Magento’s built-in functionality or dedicated hosting services to avoid interruptions.
3. Choosing the Appropriate Import Scenario
Selecting the correct import method depends on your data size and complexity:
- For smaller catalogs: Use Magento’s built-in import functionality to quickly upload and update product data.
- For larger catalogs or complex data: Utilize a third-party extension for enhanced flexibility and scalability.
- Consider the size of the import file and ensure the chosen method supports seamless integration of your product information.
- Hiring a third-party agency is an optimal solution if you lack expertise and skills. With over a decade of experience in the Magento field, Mageplaza is the ideal choice for you.
The bottom line
Importing products in Magento 2 is a streamlined process that helps store owners efficiently manage their catalogs. By preparing a well-structured CSV file and following the steps outlined above, you can quickly add or update products in bulk. Proper configuration and testing ensure a smooth import process, minimizing errors and saving time.
Magento 2 Product Options supports store owners to assign options to multiple products quickly.
Check it out!Related topics