The built-in import feature in Magento can often be frustrating due to its complexity and less than forgiving nature. In Magento 1, many extensions were created to aid in importing products quickly and easily. With the recent release of Magento 2, there are not many extensions to help with importing products. Documentation is also sparse when it comes to various methods of importing products.
Importing simple type products in Magento 2 isn’t that difficult. You can export a simple product under:
System -> Export
and then look at the format. For configurable products (products that have ordering options like size, color, etc… where a number of simple products are attached to a main configurable product), the import process is much more complicated. You can export a configurable product with its associated simple products, but it may not be obvious what is required to have a successful import.
Here are the steps needed to successfully import configurable products (with associated simple products) into Magento 2:
Prerequisites
Before you perform an import, the following items should be completed beforehand:
- Product attributes should already be created and defined properly. (Stores -> Attributes -> Products)
- The product attributes you plan to import should be assigned to an attribute set. (Stores -> Attributes -> Attribute Set)
- The category/categories these products will go into should already be set up. (Products -> Categories)
- None of the simple products or configurable products should exist in the catalog before importing.
The CSV import file
Magento accepts a valid Comma Separated Value (CSV) text file for import. The file should, by default, use a comma as the field and multiple value separator. You can change these during the import options being selected in the admin panel, but it may cause issues.
There are 5 items you have to take into account when creating the CSV file:
- All simple products should be listed before the configurable product in the CSV file. This is required.
- The “attribute_set_code” field should match the Attribute Set that contains the attributes for each product.
- The “configurable_variations” field should be a pipe separated set of SKU/option combinations for each simple, and be populated only for the configurable product.
- The “configurable_variation_labels” field should correlate the Attribute code to the Label Name, and be populated only for the configurable product.
- The “additional_attributes” field should list the options for each simple product (comma separated if more than one attribute per simple product).
Example Configurable Product
We’ll look at a basic configurable product as an example:
a T-shirt that comes in two colors: Black and Red
In this example, we assume the Product Attribute “color” exists and has defined colors that include Black and Red. We also assume the Color attribute exists in the “Default” Attribute Set. We set the category for the products to “Default Category/Gear/Bags” as an example category.
Here is an example CSV file to import these 3 products (2 simple products and the configurable product):
sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,configurable_variations,configurable_variation_labels,associated_skus shirt-black,,Default,simple,Default Category/Gear/Bags,base,T-Shirt - Black,,,1,1,Taxable Goods,Not Visible Individually,1,,,,,,,,,,,,,,,,1/23/2016 19:45,1/23/2016 19:45,,,Block after Info Column,,,,,,,,,,,,,color=Black,5,0,1,0,0,1,1,1,0,1,1,,1,0,0,1,1,0,0,0,1,,,,,,,,,,,,,, shirt-red,,Default,simple,Default Category/Gear/Bags,base,T-Shirt - Red,,,1,1,Taxable Goods,Not Visible Individually,1,,,,,,,,,,,,,,,,1/23/2016 19:45,1/23/2016 19:45,,,Block after Info Column,,,,,,,,,,,,,color=Red,5,0,1,0,0,1,1,1,0,1,1,,1,0,0,1,1,0,0,0,1,,,,,,,,,,,,,, shirt,,Default,configurable,Default Category/Gear/Bags,base,T-Shirt,,,1,1,Taxable Goods,"Catalog, Search",,,,,,,,,,,,,,,,,1/23/2016 19:45,1/23/2016 19:45,,,Block after Info Column,,,,,,,,,,,,,size=55 cm,0,0,1,0,0,1,1,1,0,1,1,,1,1,1,1,1,0,0,0,1,,,,,,,,,,,,"sku=shirt-black,color=Black|sku=shirt-red,color=Red",color=Color, |
You may also download the sample CSV file.
Key fields include:
additional_attributes:
For the Black T-shirt: color=Black
For the Red T-shirt: color=Red
configurable_variations: For the configurable T-shirt product:
“sku=shirt-black,color=Black|sku=shirt-red,color=Red”
configurable_variation_labels: For the configurable T-shirt product:
color=Color
The import process
Once you have your import file built, you may import it in the admin panel under:
System -> Import
Default options for the import should look like:
Then you can click “Check Data” in the upper right of the screen. This should complete fairly quickly. If it hangs up for a very long time, it’s very likely your import file either has bad header options or is not a properly formatted CSV file.
If the check passes, you may click the “Import” button at the bottom to perform the import. Once it is complete, you should go edit one of the configurable products and make sure that on the bottom of the edit product screen, the list of expected simple products are present in the Configurations section:
If you do not see a list of associated simple products, your import file likely had bad data or formatting in the “configurable_variations” field for the configurable product.
Summary
As you can see from the details above, importing configurable products into Magento 2 requires many steps and proper configuration before-hand. If you follow the guidelines above, you should be able to successfully import configurable products into Magento using the native Import function.