There have been numerous issues for some time with the standard .csv import/export functionality of Magento when dealing with images. We’ve spent many hours scratching our heads at Impression HQ, but have found a great solution that fits well with our workflow. When it comes to uploading data into Magento, there are a few options beside premium plugins that have varying levels of success and difficulty. These are;
Magento Import/Export via CSV
Initially, for product imports, the standard importer works very well. You’re able to import every piece of product data that you require, so long as the spreadsheet is setup correctly and you have already done the work on the website to set up your configuration, categories and attribute sets. Magento have provided detailed instruction on this page for users looking to get started with importing products into Magento. The problem appears when it comes to uploading images. Various sources online (plus our experience!) indicate issues around images appearing exclusively on the store view, or the admin panel, or not at all. We’re assuming you’ve already moved your files via FTP to the
media/import directory before getting started. If you have got this far and want to pursue this method, it’s worth checking the following;
- Caches are flushed and disabled – this is standard practise for a development environment
- Indexes are refreshed to ensure correct database information is shown on the store view
- You are referencing relative URLs from media/import in your file name, i.e.
media/import/example.jpgshould be recorded on the spreadsheet as
- The products you are checking in the store view are visible in that view
If you find yourself constantly on Magento’s and Stack Overflow’s website, then it may be time to move on to a different solution.
Uploading product images via the Magento Dataflow
Traditionally, the upload document would be extremely large with different columns for attributes, and images would be tagged on the end. In this method, keep everything the same, but do not add images to the first spreadsheet; instead, create a new one that contains the product’s SKU and image location. Magento allows each product to have a number of images, at different sizes – standard, ‘small’ and ‘thumbnail’. Each of these images may also have a label – some themes use this to help with on-page SEO, but it’s also useful for managing images as your store grows.
Putting this all together in to your new spreadsheet, you should have the following headings:
sku, image, image_label, small_image, small_image_label, thumbnail, thumbnail_label
The next step is to set up your profile within Magento. Navigate to System > Import/Export > Dataflow – Profiles. There will be default profiles already set up, but go ahead and create a new profile from the + Add New Profile button in the top right. You should see the following screen. Set up your profile with the name you choose – it’s only used as a label.
The important settings, everything else can be left as defaults:
- Entity type: Products
- Direction: Import
- Data transfer: Interactive
- Type: MS Excel XML
- Spreadsheet name: (leave this empty)
Then it’s time to set up the mapping, for the following column names. This will pair your file columns with the database rows within Magento.
- sku <–> sku
- image <–> image
- image_label <–> image_label
- small_image <–> small_image
- small_image_label <–> small_image_label
- thumbnail <–> thumbnail
- thumbnail_label <–> thumbnail_label
We’ve opted to use XML files rather than CSV so we don’t need to worry about escaping fields that contain special characters or commas. We had some difficulty initially when using CSV’s, so if you’re experiencing the same, opt for XML. If you’re more comfortable with CSV files, then change that one setting and adjust the two options that appear beneath it. Following this, upload your file on the left hand side, click ‘Save and Continue Edit’, then run the relevant profile from the ‘Run Profile’ option on the left.
When running the profile, you may see “
Skip import row, is not valid value "" for field "type"” – the first of each of these instances is due to the header rows being included, so don’t worry.
Importing with Magento Mass Importer – Magmi
Magmi in tandem with the Image attributes processor plugin is another method of mass importing images. The process is similar, but the file type can again vary, and extra care should be taken when using Microsoft Office products as additional data can be added to CSV files. Images should still be uploaded to
media/import, though in this case, this can be customised. Make sure the Image attributes processor is checked on the Magmi configuration page. Another little nicety is that if you are uploading thousands of images, you can also name the images with SKUs as the filename to speed things up. There’s more information on many of the features on the Magmi Wiki page, here.
Magmi is the most technical solution as it involves the installation of a new directory of folders on the server. The pages are accessible to anyone browsing your website without adding some additional protection to this directory, so be careful when attempting this. Your host or server administrator should be able to assist in setting up some http authentication here.
If you are planning on inserting multiple images into the media gallery at a time, then there is a facility for that too – the
media_gallery column accepts multiple images, semicolon-separated, i.e.
/exampleimg1.jpg;/exampleimg2.jpg. Again, be sure to include the forward slash when referencing a file in the imports directory.
If you would like a walkthrough on how to use Magmi, then see this great blog here by Zurd. Also, credit where it’s due – we solved our Dataflow Profile issues partially after reading this excellent post by Ash Smith.