Magento: Import Multiple Images for Products Module

Magento Icon

Update: If you are using Magento 1.5 or higher, please see my Revised Multiple Image Import Module post

I still am confused as to why Magento hasn’t built-in the ability to upload multiple images for each product. After scoping it out, finally, I discovered that the modification was quite simple. I haven’t put the module up on Magento Connect yet (not sure if I will), but here I will lay out how to do it, which for some of you may help you understand how modules work, if you don’t know already.

I’ve seen some solutions out there that modify core code, some that just take a file and move it to your /app/code/local/ retaining the same directory structure, so as to just override the file. I don’t recommend either of these methods (especially the first), as with a true module you are setting up a much better environment over time for this to last. And a module allows you to ONLY override the methods you need to modify, instead of entire classes. Plus, you can easily disable the module right in the admin (Admin >> System >> Configuration >> Advanced).

Be sure you replace all of the “YOURSTUFF” with your name or company name.

I have only tested this with

Step 1:

Create the file: /app/etc/modules/YOURSTUFF_ImportMultipleImages.xml. This file tells Magento that you have this module and where it is located.

<?xml version="1.0"?>

Step 2:

Create the file: /app/code/local/YOURSTUFF/ImportMultipleImages/etc/config.xml. This file is the configuration file for your module. It tells Magento which class we are going to override.

<?xml version="1.0"?>
                    <!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->

Step 3:

Create the file: /app/code/local/YOURSTUFF/ImportMultipleImages/Model/Convert/Adapter/Product.php. Important note: When creating a module, you only want to include the methods that you are actually modifying. As you can see, we are extending the original class, so we’ll have all of the methods from the original, but since we have the saveRow() method in our class, ours will take precedence. We do it this way because when you upgrade Magento, you’ll only need to make sure you check the one method for changes, instead of the entire class.

Again, be sure to replace the “YOURSTUFF” in the class name to your name or company name.

 * Import Multiple Images during Product Import
class YOURSTUFF_ImportMultipleImages_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
     * Save product (import)
     * @param array $importData
     * @throws Mage_Core_Exception
     * @return bool
    public function saveRow(array $importData)
        $product = $this->getProductModel()
        if (empty($importData['store'])) {
            if (!is_null($this->getBatchParams('store'))) {
                $store = $this->getStoreById($this->getBatchParams('store'));
            } else {
                $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
        else {
            $store = $this->getStoreByCode($importData['store']);
        if ($store === false) {
            $message = Mage::helper('catalog')->__('Skip import row, store "%s" field not exists', $importData['store']);
        if (empty($importData['sku'])) {
            $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
        $productId = $product->getIdBySku($importData['sku']);
        if ($productId) {
        else {
            $productTypes = $this->getProductTypes();
            $productAttributeSets = $this->getProductAttributeSets();
             * Check product define type
            if (empty($importData['type']) || !isset($productTypes[strtolower($importData['type'])])) {
                $value = isset($importData['type']) ? $importData['type'] : '';
                $message = Mage::helper('catalog')->__('Skip import row, is not valid value "%s" for field "%s"', $value, 'type');
             * Check product define attribute set
            if (empty($importData['attribute_set']) || !isset($productAttributeSets[$importData['attribute_set']])) {
                $value = isset($importData['attribute_set']) ? $importData['attribute_set'] : '';
                $message = Mage::helper('catalog')->__('Skip import row, is not valid value "%s" for field "%s"', $value, 'attribute_set');
            foreach ($this->_requiredFields as $field) {
                $attribute = $this->getAttribute($field);
                if (!isset($importData[$field]) && $attribute && $attribute->getIsRequired()) {
                    $message = Mage::helper('catalog')->__('Skip import row, required field "%s" for new products not defined', $field);
        if (isset($importData['category_ids'])) {
        foreach ($this->_ignoreFields as $field) {
            if (isset($importData[$field])) {
        if ($store->getId() != 0) {
            $websiteIds = $product->getWebsiteIds();
            if (!is_array($websiteIds)) {
                $websiteIds = array();
            if (!in_array($store->getWebsiteId(), $websiteIds)) {
                $websiteIds[] = $store->getWebsiteId();
        if (isset($importData['websites'])) {
            $websiteIds = $product->getWebsiteIds();
            if (!is_array($websiteIds)) {
                $websiteIds = array();
            $websiteCodes = split(',', $importData['websites']);
            foreach ($websiteCodes as $websiteCode) {
                try {
                    $website = Mage::app()->getWebsite(trim($websiteCode));
                    if (!in_array($website->getId(), $websiteIds)) {
                        $websiteIds[] = $website->getId();
                catch (Exception $e) {}
        foreach ($importData as $field => $value) {
            if (in_array($field, $this->_inventoryFields)) {
            if (in_array($field, $this->_imageFields)) {
            $attribute = $this->getAttribute($field);
            if (!$attribute) {
            $isArray = false;
            $setValue = $value;
            if ($attribute->getFrontendInput() == 'multiselect') {
                $value = split(self::MULTI_DELIMITER, $value);
                $isArray = true;
                $setValue = array();
            if ($value && $attribute->getBackendType() == 'decimal') {
                $setValue = $this->getNumber($value);
            if ($attribute->usesSource()) {
                $options = $attribute->getSource()->getAllOptions(false);
                if ($isArray) {
                    foreach ($options as $item) {
                        if (in_array($item['label'], $value)) {
                            $setValue[] = $item['value'];
                else {
                    $setValue = null;
                    foreach ($options as $item) {
                        if ($item['label'] == $value) {
                            $setValue = $item['value'];
            $product->setData($field, $setValue);
        if (!$product->getVisibility()) {
        $stockData = array();
        $inventoryFields = isset($this->_inventoryFieldsProductTypes[$product->getTypeId()])
            ? $this->_inventoryFieldsProductTypes[$product->getTypeId()]
            : array();
        foreach ($inventoryFields as $field) {
            if (isset($importData[$field])) {
                if (in_array($field, $this->_toNumber)) {
                    $stockData[$field] = $this->getNumber($importData[$field]);
                else {
                    $stockData[$field] = $importData[$field];
        $imageData = array();
        foreach ($this->_imageFields as $field) {
            if (!empty($importData[$field]) && $importData[$field] != 'no_selection') {
                if (!isset($imageData[$importData[$field]])) {
                    $imageData[$importData[$field]] = array();
                $imageData[$importData[$field]][] = $field;
        foreach ($imageData as $file => $fields) {
            try {
                $product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . $file, $fields);
            catch (Exception $e) {}
		 * Allows you to import multiple images for each product.
		 * Simply add a 'gallery' column to the import file, and separate
		 * each image with a semi-colon.
	        try {
	                $galleryData = explode(';',$importData["gallery"]);
	                foreach($galleryData as $gallery_img)
					 * @param directory where import image resides
					 * @param leave 'null' so that it isn't imported as thumbnail, base, or small
					 * @param false = the image is copied, not moved from the import directory to it's new location
					 * @param false = not excluded from the front end gallery
	                        $product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . $gallery_img, null, false, false);
	        catch (Exception $e) {}
		/* End Modification */
        return true;

Step 4:

Test it out! This is how it works: Use the Magento product import functionality (Admin >> System >> Import/Export >> Profiles >> Import All Products). Add a column to your CSV called ‘gallery’. In that column, simply put all the images you’d like that product to have, separated by semi-colons. The same exact rules apply for these images as do the ‘image’, ‘small_image’, and ‘thumbnail’ columns, in that if you are putting all your images in the /media/import/ directory, you’ll have to include the forward-slash in the image names. Here’s an example (be sure to leave out any spaces):

Your gallery column could look like: /image1.jpg;/image2.jpg;/image3.jpg

These images will all show up just as if you were to go into the product edit in the admin and upload them. They’ll be copied from the /media/import/ directory into the proper media directory structure, and they’ll show up as thumbnails below your main product image on the product view page.

Comment if you have any questions. Enjoy!

This entry was posted in Magento, PHP. Bookmark the permalink.

106 Responses to Magento: Import Multiple Images for Products Module

  1. Sukumar says:

    Thanks. Its great. Working fine for me!!!!

  2. Din says:

    Does this extensios work with Magento 1.7?

  3. Pingback: Add Product Images via CSV | Joomla Magento Wordpress Prestashop blog posts from around the web

  4. Pingback: Add Product Images via CSV | Open Source Blog posts from around the web - JoomVision.Com

  5. Ahamed Sha says:

    can’t thank you enough for these codes. saved me alot of trouble. i import items in 1000s and 100s at a go. this has been a real time saver and the format used to seperate images is rather much better than the many paid extensions that are available in magento connect.
    i use followed the code and a change mentioned in the comments and got it working. thanks again. – Sha

  6. Pingback: Add Product Images via CSV, Magento Blog and E-Commerce

  7. vaL says:

    It does not work with nor with

    In the stable release notes they say:

    * Due to a design flaw we are removing alternative image storage feature from this release. It will be redesigned and released in our upcoming releases

    The current version is now but still they do not say anything about additional images.

    I have been on the PC for 12 hours now trying to implement the solution mentioned in this blog post along with several other alternatives + digging into the magento core code but none worked.

    Anyone have a solution or advice for that?

    • Josh Pratt says:

      vaL – I haven’t tested this with 1.5.x yet, but given they changed up the import functionality quite a bit, it isn’t surprising at all that it no longer works. I can’t see myself getting to it anytime soon (unless the need comes up with any of my projects to do it).

  8. saurabh says:

    Josh Pratt
    M new in magento.I have import .csv of my products.Bt how can i import 1500 images at once with its respective product details according to magento standard.I have tried a lot.Pls help me out.

  9. lin says:

    it works in

  10. Max says:

    Thanks for posting the code, Josh.

    I can confirm that it works on

    As someone had already mentioned, be careful if you copy/paste the line 203 fix; the quotation marks do not render correctly.

    Also, for some odd reason, changing to “YOURSTUFF/yourstuff” to your name with all lower case letters did not work, changing the first letter to capital worked perfectly.

  11. Harsh says:

    Thanks a lot

    i have implement it in magento also

    it’s work perfectly

    Thanks bro

  12. moghant says:

    Confirm that it works in Magento! Thank you, Josh!

    Here is another minor issue – in, although images in gallery column can be uploaded successfully, it seems that by default these images are set as EXCLUDE on Admin > Catelog > Manage Products > (selected product) > Image tab. I have to manually uncheck EXCLUDE for every image, in order to show them on web page.

    Is there anyway to set EXCLUDE as unchecked by default while loading multiple images?

  13. seanjacob says:

    Josh thankyou for your code.

    Can I suggest updating what versions you have testing your code with. I was unsure about using this code with 1.4 as I missed your comment saying you had this working with 1.4. Thanks again!

  14. Ankit Patel says:

    I m using magento and i tried this module that’s working on local machine perfectly but not working on linux server with magento

    Will you plz help me?


    • Josh Pratt says:

      Ankit – Sorry, can’t really help you. There are way too many things that could make it not work properly. If it works locally with the same version, it should work on your server. You must have done something different.

  15. Balazs Meszaros says:

    Hi Josh,

    Thank you for the idea and the code also. I am a magento newbie, switching from oscommerce to something better and trying magento to work with according to good feedbacks of it.
    I was surprised how soon ran into some major issues that could effect my decision to select magento. The first was the import feature. After some googling found your solution which was very useful for me. First I was happy that it is not only a Magento connect downloadable module, because its much better to know what happens behind the scenes and it is better not to be a dummy GUI clicking user. Second I tried to think how can I adopt this code to my specific problem, which is a little bit different, but the same base problem.
    I would like to have import multiple picture per product BUT many of them from an external URL from manufacturer sites, wholesaler’s sites, etc. Thorough the import profile the script should download the remote images from the external URL given in the csv and copy it into Magento’s own image hierarchy.
    Please tell me if it is possible to modify your code with not too much effort to extend it with this external URL feature and I will try to do it.

    • Josh Pratt says:


      You can definitely make the code do pretty much whatever you want. Most things are possible, it just depends on how difficult it is, and how long it will take you to figure it out. If you know how to write php to get an external file, then you should be able to re-factor my code.

  16. Tommy says:

    I read through the comments and your instructions, but this is something that is stock in Magento… I’ve been importing multiple images per product for a couple years. Simply use the standard import profile and upload a CSV or XML to the correct import local. In it, place the following two columns (sku and image):

    sku image
    SKUX /image1.jpg
    SKUX /image2.jpg
    SKUX /image3.jpg

    This of course works AFTER you have a product in the DB but it is simple…


    • Josh Pratt says:

      You are correct Tommy, but that process is tedious, and doesn’t Magento assign the main image to be the last image that you imported? So while it works, you still need to create loads and loads of extra import rows, and you need to put the image that you want to be the main image for the product last.

    • Ben says:


      Thanks for this. I’m pretty handy with excel, so generating all those records was pretty quick. With reference to the “Exclude” checkbox on the Catalog -> Manage Products -> Images screen, is there a way to use your solution and set this to false? ie I want all these additional images to appear in the “More Views” section on the front end.

  17. Florian says:

    Hi there,

    I am also using this script but encounter a strange problem and looking for a sloution for 2 full days now.

    Magento 1.4.1

    Import works well, base, thumbnail and additional gallery images.
    Somehow the pictures are only shown on the product page (gallery) the base image thumbnail is not shown in the categorie listings.

    After checking in the admin panel (in the storeview I used during import) the the specific picture is there and base, small and thumbnail are selected for it.

    No matter what changes I make in the storeview, the thubnail image wont show up.
    After switching to Standard Storeview saving anything inside the image section and turning back to my specific storeview EVERYTHING works.

    Anyone got an Idea why all values on the specific storeview are correct in the admin panel but wont be used in frontend?

  18. Muzafar says:

    Thanks for providing this module. Works perfectly in…


  19. eric says:

    any chance that you’ll make a post for the same thing for version
    or a list of changes to implementation?

    • Josh Pratt says:

      Eric – I actually just tried it out earlier this week. It still works fine on 1.4.x. The only thing I had to change is to convert the two instances of split() with explode() inside the csv model due to my recent upgrade to php 5.3.

      • eric says:

        oh awesome! i’m about to try it! thanks josh!

      • eric says:

        also, i’m running 5.2.13, so i’m pretty sure i’ll be good with using split() still, correct? in this case, passing a reg ex vs. a delimiter are similar?

  20. Vovan says:

    Thanks for the description. The question often arises as to how export additional images for products in Magento store. Answer here

  21. Matt Ogborne says:

    Oh and pretty please release it as a extension, its unbelievable that Magento does not have this by default, I was shocked when I could not readily add images in mass, Magento is fab, but silly things like this lets it down.


    • Josh Pratt says:


      There is no need to release this as an extension. It would be no different than the code I posted. I did it this way to help teach people how modules are created and how they work.

  22. Matt Ogborne says:

    I could not get this to work as an extension in (I suspect this is caused by the config.xml file), however altering the file ‘app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php’ directly works

    • Josh Pratt says:


      [Removed all your code. Sorry.. Don’t want huge comments cluttering the post]

      Modifying core code is never a good idea. At least move that file to app/code/local/Mage/…. instead. Best method is to put that into an actual module though.

  23. Dan says:

    I tried what Edward suggested, but it still does not work. I see only one image.

    I am using Magento ver.

    I am thinking I am not understanding what needs to be replaced for “YOURSTUFF”.

    I have replaced “YOURSTUFF” with my first name – does it have any correlation to some variable in store or can it be any thing random as long as it is consistently named everywhere?

  24. ryan says:

    looks like your blog software converts apostrophes into quotation marks, so my post is also incorrect.

    apostrophes ≠ quotation marks

    so to anyone reading, just manually add the false, false parameters rather than copying the line of code out of these comments.

  25. ryan says:

    Yes it was just the capitalization for the class definition. I went with pratthost so that in the future I would have a clue where I got the module from.

    regarding edward’s line 203 fix – the base image small_image thumbnail would always default to no image when this module was installed with the fix outlined. I figured it out for anyone who like me, copies and pastes the line of code rather than doing the simple manual edit.

    the correct code:
    $product->addImageToMediaGallery(Mage::getBaseDir(‘media’) . DS . ‘import’ . $file, $fields, false, false);

    code as posted:
    $product->addImageToMediaGallery(Mage::getBaseDir(‘media’) . DS . ‘import’ . $file, $fields, false, false);

  26. Ryan says:

    And it was something simple, when replacing YOURSTUFF I always replaced it all in lowercase ie “mystore”, “test”, when replaced with “Pratthost” it worked.

    • Josh Pratt says:


      My assumption is that you may have missed something when trying with mystore or test. It certainly doesn’t need to be “Pratthost”. Perhaps it just needed a capital letter first? Or, there was a mismatch somewhere. Glad to hear it’s working now though.

  27. Ryan says:

    Thanks for providing this module. I have been trying to get this to work for a couple hours, I’m sure I am just missing something very simple. I install the code, clear my magento cache, and then run the inventory import.

    My skus get created but only with one image, no errors are shown. I am using a single magento installation that is running 2 websites, I made sure the module is enabled at default, and by both sites.

    screen shots of my code and directory structure

    my media/import directory and csv files, tried to create 2 skus at a time, wasn’t sure if you need the main image added to gallery or not, with and without trailing semicolon in the gallery field

  28. J says:

    running works perfectly. very nice extension.

  29. optical says:

    I tried all the mentioned methods here but still couddn’t get images to appear in the frontend. I’m using Tried Andreas’ as well as Josh’s, no go.

    • Josh Pratt says:


      You must be missing something then. It works fine if you’ve set it up correctly. Also, you really shouldn’t be running There’s a major security issue with that version. Be sure to upgrade to The upgrade does not effect any template files, so unless you’ve modified core code (which you absolutely shouldn’t ever do), it will be quick and easy.

  30. Andreas Reiser says:


    I think the preferred solution strongly depends on your data source. Most of the time, I’m using XML data sources. Therefore, mapping image paths to comma separated element data doesn’t make much sense. In XSLT you would probably prefer to map each image path to a new data row.

  31. Andreas Reiser says:


    thanks for your work. However, you can also import multiple images with the built-in Magento import tool!!!
    All you have to do is:
    – duplicate the row in your import file,
    – change the image name,
    – leave the fields “small_image” and “thumbnail” blank. Only the last row should contain the information for small_image and thumbnail.

    From a database point of view, this approach keeps the file at least in the first normal form.

    Andreas Reiser

    • Josh Pratt says:


      While your method can work, it does not provide the flexibility that this module does. You don’t have to create multiple lines per product, and you can choose how you want the additional images to come in (specific settings). It also takes longer, as you are increasing the number of rows that Magento has to process.

      But, you are correct. It can be done without installing any modules. I just wouldn’t prefer it (at this point in Magento’s life at least). Thanks for the input though.

  32. John says:

    Hi Josh,

    Can you please tell me how to run the php script? I mean how do I execute it?


    • Josh Pratt says:


      I don’t mean to be rude in any way, but there’s no way you should be asking that question if you actually read the entire post.

  33. Leo says:

    Just wondering if you could fix a problem where one item is excluded, can you force thumbnail image to be excluded from main product view in standard import.
    Either via hardcoding the parser or by adding another field to/like gallery
    Hope I’m not deviating off this great solution.

    • Josh Pratt says:


      I’m not going to work on it now, but you easily could. The settings are all there in the code. You can probably even add a column to the CSV, and flag the exclude or not based upon the column’s value.

  34. RepoUK says:


    Just to confirm that this (with Edwards line 203 amendment) worked fine for me with a fresh install of Magento 1.4.01.

    I had already used Josh’s solution with great successs in a production environment.

    Gav aka RepoUK

  35. Edward says:

    Hi again,

    I have solved the problem that the first image is put on exclude. To prevent this the line 203 in the Producht.php should be changed to:

    $product->addImageToMediaGallery(Mage::getBaseDir(‘media’) . DS . ‘import’ . $file, $fields, false, false);

    I hope this information will help others also.


  36. Edward says:

    I can confirm that it works on I want to begin with a new shop, so the products that I upload have not been uploaded before. When I try this it puts the first image on exclude for some reason. The second image is listed below, whitout the ecxlude mark.

    If I go to the product on the front, it shows the first image and not the extra image.
    When I deselect the exclude option from the first picture it will show both pictures on the front. Then everything is okay.
    Is ther something I can do about this? Example:

  37. Edward says:

    Hi, anyone already tested it with the version
    Would be great if it worked….

  38. Tom F says:

    Not working on…Same situation as Dave B, shows enabled in Admin, import goes fine, get small, thumb and image as normal, no errors on import, but no gallery images…everything set as above…any ideas?

    • Josh Pratt says:


      It could be any number of things. All I can tell you at this point is that I, and many others have used this module on with no problems. In fact, I just used it today on on a project I’m working on. It has to be something you are missing…

  39. Josh,

    Thanks for your post.

    Does this module works with XML?

    Do you have a model CSV file to only update this field?

    I tried here but the process stops at the warning to not close the browser window.

    Any Help on This?

    • Josh Pratt says:


      No, it does not work with XML. No CSV model needed. Just take your standard product import script and add a column called “gallery”.

  40. manish says:


    Thank you so much its working for me.

    but i seen that when i importing images they goes to respective directories created by magento.
    ex : my image name 123.jpg then its goes to catalog/product/1/1/123.jpg but when i uploading same image its become catalog/product/1/1/123_1.jpg

    Problem with disk space. because all time new image created on image place holder but not deleted or unlink from system.

    how can i remove old image before upload new image or how can i stop new image creating by magento.

    please help me to sort out this thing.


    • Josh Pratt says:


      You’ve definitely found an area of Magento that can be frustrating. There is no good way to remove unused images for deleted products, or images that you’ve removed from the product in the admin. There is unfortunately no good way to do it. You could certainly write a script to parse through all your images and check against the database to see if it is used, but other than that, it will have to be a manual process.

  41. Stefan says:

    No need to publish lates comment! found out that it actually was that costum option import thing. Got both to work by simple diff the Product.php files and merged them into one working thingy.
    Dont know what it was that made me that blind – propably the fact that I spend just too much time messing around with this at last simple issue.

  42. Stefan says:

    Hi Josh, I spend about three hours googling for solution like this one. I was so happy to find me not alone with the multiple-image problem. So I created all three files triple-checked the spelling of the directories put that gallery column in my csv-file and… – nothing. No images, no error message, just nothing.
    I use this local hack to import custom options as well:
    I deleted this hack tried it without – no diffrence.

    The secondary images should be used as “values” for image-type attributes. I’m using magento

  43. Lee says:

    when i put the directory app/code/local/LEE as capitals i get the error below, if i do it in lowercase i dont get the error, but then it only imports one image and not the gallery images.

  44. Kohai says:

    Ok, I solved my problem. When you replace YOURSTUFF with your company name, it must start with a capital. I did my company name all lowercase and it didn’t work.

  45. Gerry says:

    Works exactly as specified on

    Saved me a lot of time + learnt a bit about packaging magento modules in the bargain.

    For those having trouble, pay particular attention to the capitalisation of files and folders – follow instructions explicitly.

    Many Thanks Josh

  46. Kohai says:

    I’m missing something…. My data gets uploaded but my “gallery” images never get processed. The images from the base, thumb, etc, get loaded.

    It seems like the module as outlined above doesn’t run. Is it active by default or do I need to enable it? I don’t see it listed under “Admin >> System >> Configuration >> Advanced” as described above.

    • Josh Pratt says:

      Kohai, It definitely works. If you don’t see anything in your “Advanced” config, then you either have done it wrong, or your cache is not turned off (or, you are using an older version of Magento)

  47. Stephanie says:

    Hi, I would love to have this module to work.
    Have install as above but when I want to clear cache or refresh it give the error below:-
    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser error : Opening and ending tag mismatch: quadraVision_ImportMultipleImages line 4 and quadravision_ImportMultipleImages in /home2/quadravi/public_html/lib/Varien/Simplexml/Config.php on line 510
    #0 /home2/quadravi/public_html/lib/Varien/Simplexml/Config.php(510): mageCoreErrorHandler(2, ‘simplexml_load_…’, ‘/home2/quadravi…’, 510, Array)
    #1 /home2/quadravi/public_html/lib/Varien/Simplexml/Config.php(498): Varien_Simplexml_Config->loadString(‘

    What am I doing wrong?

  48. Joris Bots says:

    Dear Josh,

    Thanks, smooth install, top solution for our 1.600 extra product images (next to standard base, thumb etc.)!!

    Saves us weeks!

  49. Hello sir

    through your module i got the gallery images but i am not getting how to import and export image label

    so can u plz help me out

  50. Jord says:

    Works like a charm!
    I only have one question.
    All the imported images are not set as base image, small image or thumbnail.
    Now i have activate all base images for every product.
    Is there a way to automaticly enabled/set the base image?



    • Josh Pratt says:

      Jord: My module only imports secondary images. You still need to utilize the “image”, “small_image”, and “thumbnail” columns as normal on your import sheet.

  51. Dave B says:

    Just saw you said it did work with Wonder what i did wrong. The module shows up fine in admin. Just dont get any gallery pictures, only the regular image, small_image, and thumbnail

  52. Dave B says:

    Just wondering if anyone had this working with ? I think i have done everything correctly, but still dont get any gallery pictures after my upload. Thanks in advance for any help.

  53. Rich Y says:

    Any thoughts on how to assign the first of all these newly imported product images as the Base, Small, Thumbnail image on a mass scale?

    I’ve imported 1400 images into the gallery collectively for all my products, but none of them are assigned as the main image for the product.

    I don’t want it to re-import the image file (making a duplicate). I just want to assign one of the current images for the product main image display… import the path to the newly imported product filenames.

    • Cam B says:

      This is EXACTLY what I’m trying to hunt down. I can do the import of images just fine, but none of them are being automagically set as Base, Small, Thumbnail…

      Anyone find anything? I’ll keep digging…

  54. Rich Y says:

    Works perfectly in… thanks a bunch!

    I can only imagine the other people having issues are not paying attention to how local modules are done. Correct Paths, correct capitalization of file names and directories, changing YOURSTUFF to your own custom naming.

    If people don’t understand the building of local modules in Magento, they probably shouldn’t be messing with this stuff. Thankfully Josh has provided some good info.

    One note…. some issue in the display of Step 3 in Safari on this page. Broken tag or something. It makes all the Code be ALLCAPS. Just a warning.. copy/paste code using Firefox.

  55. haltabush says:

    Good stuff, thank you!

  56. manoj ninave says:

    Helo sir

    thank you very much for reply..
    as per client request i have to put gallery image in galerry1,galerry2,galerry3,galerry4…..etc

    that is means instead of putting all the images in one column “gallery” , each image will put in seperate column viz.. galerry1,galerry2,galerry3,galerry4…..etc

    sir, what changes should i have to do in this file product.php
    please help me..
    could you please give me your linked in URL?

  57. Manoj Ninave says:

    Thank you very much sir,
    I was looking just exactly something like that.

    It is working fine all the images imported successfully.

    But i’d like to ask one question that,how can i delete gallery images.

    actually here i want delete privious gallery images,then new images should be added.

    also i disable this module from admin site and imported new products it worked using this module,actually as disable this module gallery images should not inserted .

    so why we gave facility to enable and disable it through admin side.

    But Thanks sir.

    you are very great..


    Manoj Ninave

    software Engineer

    • Josh Pratt says:

      Manoj: This script isn’t super well rounded, but then again, it’s not meant to be. It’s a very easy way to learn how to create a module, and an easy way to import multiple images. If you want to create it to have more functionality, go for it. I’m sure you can modify the module to recognize a particular word or something that will delete the gallery images for a product or something.

    • Enrique García says:

      To delete the existing images you must:

      $product = Mage::getModel(‘catalog/product’);
      $productId = $product->getIdBySku($productInfo[‘sku’]);
      if ($productId) {
      $attributes = $product->getTypeInstance()->getSetAttributes();
      if (isset($attributes[‘media_gallery’])) {
      $gallery = $attributes[‘media_gallery’];
      $galleryData = $product->getMediaGallery();
      foreach ($galleryData[‘images’] as $image ) {
      if ($gallery->getBackend()->getImage($product, $image[‘file’])) {
      $gallery->getBackend()->removeImage($product, $image[‘file’]);

  58. Johan Siemons says:

    @ Manish,

    There is extension called “Defcon” that will clear your images. Look for it in MagentoConnect


  59. manoj says:

    Fatal error: Call to a member function GETPRODUCTMODEL() on a non-object in D:\manoj_projects\magento\app\code\local\Mage\ImportMultipleImages\Model\convert\adapter\product.php on line 235

    • Josh Pratt says:

      manoj: You can’t use the directory /app/code/local/Mage/. That is reserved for overriding files without making modules. Change that directory to something else, and update your code accordingly.

  60. manish says:

    hi Josh Pratt,

    Thanks for your reply,

    How can i clear images of gallery and Base Image, Small Image,Thumbnail programatically from DB?

    Thank you.

  61. julian says:

    Hey Josh I appreciate the mod. It works great, but for me it excludes the products so I have to uncheck each of the items before they appear in the gallery. It has still saved me tons of time. I can confirm it works for too.

  62. manish says:

    I am running the script but I found that each time the script is run a new identical image is added to the product.
    Is there any way to avoid adding all this images to the product?
    A new image should be added only if different from the image already present in the DB.

    Thank you

  63. Johan Siemons says:

    It works great ! Thanks. Only, the filenames are now showing in the “Additional Information” field on the frontend, like: /filename1.jpg;/filename2.jpg. How can i disable this ?

  64. manish says:

    its working fine but i have little issue with this module….the issue is when i will upload same product twise then product getting update but image will not update but it will insert into same product…twise

    • Josh Pratt says:

      When you import products that already exist, Magento has to assume that if you have put images in the CSV, that you want to add new ones. You have to clear out the image (and gallery) columns, then it won’t re-import them.

  65. Bryan says:

    I like this idea and Ive tried to implement it, and I am getting this error:

    Fatal error: Class ‘BRYAN_ImportMultipleImages_Model_Convert_Adapter_Product’ not found in /home/carste6/public_html/app/code/core/Mage/Dataflow/Model/Convert/Action/Abstract.php on line 185

    Any idea what this means?

  66. Junk says:

    Couldn’t get it to work. Not sure what I was doing wrong. does it matter where you add the new “gallery” field on the data csv? Just to clarify, put the images to be imported into the media import directory? thanks

    • Josh Pratt says:

      Junk: No, it doesn’t matter where you add the column in the csv. Yes, put the images in /media/import/ just like you do for the other images.

  67. Gareth Shaw says:


    I get the following error message on

    Any thoughts?

    # Fatal error: Call to undefined method Wallshaw_ImportMultipleImages_Model_Convert_Adapter_Product::setProductTypeInstance() in /home/smiletoy/public_html/app/code/local/Wallshaw/ImportMultipleImages/Model/Convert/Adapter/Product.php on line 80

    • Josh Pratt says:

      It could be that broke this functionality a bit. I’ll have to check it out when I get a chance and make the changes accordingly. It’s either that, or you did something wrong.

  68. Alex says:

    Hey, thanks for doing this. If you haven’t made it into a module yet, I would like to combine it with a few other changes that I’ve collected through the Magento forums (one in particular that allows the import of associated products). Is this something you would be open to?

    • Josh Pratt says:

      Alex: This is a module, fyi, unless you are refering to actually putting it up on Magento Connect. That I haven’t done, and I don’t plan on doing at this point. I like to teach people how to do things on their own, which ultimately helps the community better, which is why in this post I walk people through creating a real module to do this.

      What is it you are wanting to do?

  69. DavidDWQ says:

    Marvelous, it works so great! I was looking just exactly something like that, thank you so much for this one.