Magento’s ImportExport module has been released for some time now, and has served as a worthy replacement to the old Dataflow profile methods. There isn’t much documentation online to how to import products in Magento using CSV files, so some information about the process will be provided in this post.
It’s always a good idea to first export existing product data from Magento in order to view the column names Magento uses to map its product data. It is also particularly useful to view the column names of any custom attributes that might get added from third party extensions so that you can modify this data if necessary.
To export product data, in the Magento admin head to System -> Import/Export -> Export
, select Products
as the entity type. Skip any columns you deem not necessary to export and export the CSV file.
Below is a CSV example of an export containing a couple of simple products.
You’ll notice that the majority of the columns have been stripped out, and only the required columns have been kept in. These are the columns necessary for a successful product import.
In fact, if you attempt to import this CSV file in the admin within System -> Import/Export -> Import
, you’ll encounter no errors and the simple products will be successfully imported into the system.
Take note of that integer values being used for the status
, tax_class_id
and visibility
columns. You’ll need to find out what text-based option the IDs relate to, and ensure any new products imported are assigned to the correct attribute options as you expect.
In the CSV example file above, the _store
column is blank and _product_websites
contains base
. This is because the export was taken from a Magento store that has only one website and store configured.
By configuring multiple websites within the Magento admin will result in a different website code appearing in the _product_websites
column in the export should you assign any existing products to the new website.
The file below represents an export of products appearing in two different websites.
prod_export_csv_simple_multisite
In addition, Magento gives you the ability to configure product data on a store view level.
When products that have data saved on a store view specific level, an additional row is created in the export. This row specifies the store view code in the _store
column, as well as the data that has changed.
Here is an example export of a product that has had its name
changed on a store view level.
prod_export_csv_simple_multisite_multistore_data
Whilst importing simple products seems easy enough, they need to be accompanied by product images, as well as assigning the products to existing categories.
Again, the advice will be to export products first into a CSV file to view the category and image-related columns that are being used in the import/export process.
Click the below link to download an example CSV file where simple products are exported with their categories.
prod_export_csv_simple_categories
You’ll notice that the products assigned to different categories (on the same category level) are exported on separate rows. Any subcategories are separated with a /
.
Any additional existing categories you want your products assigned to should also be included on a separate row.
As for importing product images, any images should first be uploaded into the media/import
directory within your Magento’s project root. If the import
directory doesn’t exist, create it. The images are then referenced within the CSV file.
An export of simple products with image data exported can be seen by downloading the file below.
There are a few things to note in this export.
gallery
and media_gallery
columns are blank, and don’t appear to be used when importing image data back into Magento.thumbnail
,small_image
and image
columns respectively.SIMP002
in this example, additional image information is added onto a separate row.You’ll also notice that Magento includes the image’s media path in the export, e.g. /i/m/image1.jpg
. As any images to be imported in Magento should reside in the media/import
directory, you need to alter the image path to simply be /image1.jpg
rather than /i/m/image1.jpg
.
An example of what your CSV file might look like to import product image data can be downloaded below.
Whilst there isn’t much documentation on how Magento’s ImportExport
module works and sample CSV files to look at, hopefully this post will provide you with the relevant information necessary to import products in Magento using CSV files.
There are of course more complex scenarios involving importing configurable products, custom product options and tier pricing. This will be covered in a future post, so stay tuned!
Note: This article is based on Magento Community/Open Source version 1.9.