Tips for Importing Product CSV Files in Magento 1

As a freelance Magento developer, I've become accustomed to performing various customisations on Magento stores. For example, many merchants require a blog, help with setting up website analytics and theme and module development work.

However, when it gets nearer the time for merchants to upgrade to Magento 2, use a later version of Magento 1 or perhaps move to Magento from a different ecommerce platform, a common request from the client is to re-import their product data into the new version. This saves them (or us) the time taken to manually re-add the products in the Magento admin.

The main problem with exporting and importing data seems to be the lack of documentation on the web on how to do this, how to handle product options, which import export tool to use in Magento and more.

After many failed attempts at importing product data into Magento 1 using various methods, I've shared some of the my recommendations when attempting to import products.

Use Magento's Import/Export Tool

There are a few areas in the Magento admin that allow for importing and exporting data. These include:

  • System -> Import/Export -> Import
  • System -> Import/Export -> Export
  • System -> Import/Export -> Dataflow - Profiles
  • System -> Import/Export -> Dataflow - Advanced Profiles

Although the Dataflow - Profiles area can allow both CSV and XML file imports, the Import and Export sections originate from Magento's Import/Export module and are considered more updated methods than their Dataflow siblings.

Therefore, if you need to import product data such as configurable products, custom product options and more, use the Import/Export tool as these features are covered by default. There isn't a need to purchase a third party extension unless you're looking to include custom functionality built on top of the Import/Export module.

Export Data First

It's definitely worth looking at a CSV export so that you can view the column names and see how product data is mapped in the CSV files.

If you're only interested in importing simple products into Magento, generally an export of the products in the CSV file from one system can be seamlessly imported into another. This doesn't work fully when dealing with product images and configurable products which I'll explain below.

To further your learning, I would recommend creating some products within the Magento admin, then heading to System -> Import/Export -> Export and exporting a sample CSV. This will show you how the product data needs to be arranged in the CSV file.

In addition, if you've installed any third party extensions that add custom product attributes, these are also exported. This will allow you transfer over any custom data save against products.

Remember, any attributes that you are not interested in changing can be stripped out of the CSV file. Just because

Product Images

When exporting product images, the path for the images will be prefixed with a couple of directories, e.g /s/a/sample.jpg. In order to successfully import product images, the images should first be uploaded to a /media/import directory located from your Magento project root. If this directory doesn't exist, create it and upload all of the product images to this location.

Secondly, the images need to be 'referenced' within the CSV import file, so that the products can be assigned their correct images.

Assuming the product image names have been kept the same from the export, remove the two prefixed directories from the image path name. For example, /s/a/sample.jpg becomes /sample.jpg.

Now when importing the products, the images should correctly save against the products.

If assigning multiple images to a product, take care when deciding which images should represent the image, small_image and thumbnail. These are the attributes which decide which product image to show on the main web pages such as the category, product and cart page. Ensure that you populate the columns with the correct image paths.

Importing Configurable Products

It was always thought that Magento did not natively support import configurable products, however it does, but just needs some tweaking in regards to the CSV file.

When you export a configurable product from Magento in a CSV file, the configurable product's data will appear in a row above its associated simple products. What needs to happen for a successful import is that the configurable product row needs to be below the associated simple products.

This is because of the _super_products_sku column in the CSV file. This column is used by configurable products and is a populated with SKUs of the associated simple products on separate rows.

If the configurable product data is included above the associated simple products, Magento will read the data from the _super_products_sku column and error because the associated product SKUs do not exist in the system yet. Therefore, add the associated simple products above the configurable.

If you've got a test Magento environment where you are happy to add/delete products in the system, I would recommend creating a configurable manually in the admin, and exporting the product in System -> Import/Export -> Export so you can view the columns associated with importing a configurable product.

The key columns to look at are _super_products_sku, _super_attribute_code, _super_attribute_option and _super_attribute_price_corr.

Conclusion

Mastering the import and export process is no easy feat, and can require a lot of trial and error testing. Coupled with very little documentation on how you should go about constructing the CSV file, it can take a few attempts to get it right.

If you've followed my recommendations above, you should be able to conquer most import scenarios. Hoever as always if you need any assistance or have any questions, feel free to contact your local Magento Developer in Sussex and I'll do my best to help.