Magento: Revised Multiple Image Import Module (1.5 +)

Back in 2009, I made this post about my first multiple image import module. It was quite popular, and worked all the way up through Magento 1.4.x. With the release of 1.5, it no longer worked due to core changes Magento made.

We finally ran into a client who needed this functionality on 1.5, so I have re-factored the module, and added a couple new features. Instead of just packaging up the module though, like last time, I will walk you through how to create it yourself (so that hopefully some of you will learn a little more about how to create modules).

Note: This will not work on Magento 1.4.x and lower. For a version that works on 1.4.x and lower (which is a little more basic too), please see this post.

What does this module do?

  • Imports multiple images (of course) in addition to the 3 main product images (image, small_image, thumbnail)
  • Allows you to enable or disable (in the system config) excluding any main product images (image, small_image, thumbnail) from showing up in the gallery (the exclude checkbox)
  • Allows you to specify the column name for your multiple images in the system config

How it works: When you do a product import, all you have to do is add a new column to your CSV with the header of your choice (which you can change in the system config under Catalog > Catalog > Import Image Options – By default it’s ‘additional_images’). In that column, you can have as many images as you’d like. Simply separate the image names with a semi-colon: ‘image1.jpg;image2.jpg;image3.jpg’. Just be sure you’ve put the images in /media/import/ like you would normally do.

Enough talk, let’s get to building the module. In my example, I’m using the ‘Prattski’ namespace for my module. You can certainly change that if you would like, just make sure to change it in ever place you see it.

Step 1

Create the file ‘/app/etc/modules/Prattski_ImageImport.xml’. This file tells Magento that your module exists, if it’s enabled or not, and where to find it.

<?xml version="1.0"?>
<config>
    <modules>
        <Prattski_ImageImport>
            <active>true</active>
            <codePool>local</codePool>
        </Prattski_ImageImport>
    </modules>
</config>

Step 2

Now we create our module directory. Create ‘/app/code/local/Prattski/ImageImport/’. This is where our module will reside. Inside that directory, create this file: ‘etc/config.xml’. This file does a number of things: It tells Magento which version your module is, defines your model namespace and directory, rewrites a core model with your own, defines your helper namespace and directory, and sets default values in the system config.

<?xml version="1.0"?>
<config>
    <modules>
        <Prattski_ImageImport>
            <version>0.1.0</version>
        </Prattski_ImageImport>
    </modules>
    <global>
        <models>
            <imageimport>
                <class>Prattski_ImageImport_Model</class>
            </imageimport>
            <catalog>
                <rewrite>
                    <convert_adapter_product>Prattski_ImageImport_Model_Catalog_Convert_Adapter_Product</convert_adapter_product>
                </rewrite>
            </catalog>
        </models>
        <helpers>
            <imageimport>
                <class>Prattski_ImageImport_Helper</class>
            </imageimport>
        </helpers>
    </global>
    <default>
        <catalog>
            <catalog>
                <image_exclude_enabled>1</image_exclude_enabled>
                <multiple_image_column_name>additional_images</multiple_image_column_name>
            </catalog>
        </catalog>
    </default>
</config>

Step 3

Let’s create our module’s helper. This isn’t necessary, but always a good practice to include it, as it is required for locale stuff, and it’s a ready utility if ever needed. In our case, we’ll just create a blank helper. Create this file in your module directory ‘Helper/Data.php’:

<?php
/**
 * Prattski Import Images Module
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com)
 * @author      Prattski (Josh Pratt)
 */
 
/**
 * Helper
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 */
class Prattski_ImageImport_Helper_Data extends Mage_Core_Helper_Abstract
{
 
}

Step 4

Now we will create our system config. This will give us the ability to turn on or off excluding the main product images, and specify the column in our CSV for the additional images. Note: In our config.xml file that we created, you’ll see the ‘default’ tag near the bottom. There we pre-populate our system config fields that we are creating here with data so that they aren’t blank upon module installation. Create this file in your module directory: ‘etc/system.xml’:

<?xml version="1.0"?>
<config>
    <sections>
        <catalog>
            <groups>
                <catalog>
                    <label>Import Image Options</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>999</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>0</show_in_store>
                    <fields>
                        <image_exclude_enabled translate="label" module="imageimport">
                            <label>Enable Excluded Images</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                            <comment>If the product image is a main product image (image, small_image, or thumbnail), automatically check the exlcude checkbox.</comment>
                        </image_exclude_enabled>
                        <multiple_image_column_name translate="label" module="imageimport">
                            <label>Multiple Image Column Name</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                            <comment>The header in your CSV where you will put your additional images to import. When importing multiple images, separate with a semi-colon: 'image1.jpg;image2.jpg;image3.jpg'</comment>
                        </multiple_image_column_name>
                    </fields>
                </catalog>
            </groups>
        </catalog>
    </sections>
</config>

Step 5

Finally, we’ll create the model that will rewrite the core module to add in our new functionality. You’ll see towards the bottom (at line 230) that I’ve added two code blocks. The first block will exclude (or not) based on the system configuration setting we setup. The second is what imports all the additional images. Create this file in your module directory ‘Model/Catalog/Convert/Adapter/Product.php’:

<?php
/**
 * Prattski Import Images Module
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 * @copyright   Copyright (c) 2011 Prattski (http://prattski.com)
 * @author      Prattski (Josh Pratt)
 */
 
/**
 * Product Import Adapter
 *
 * @category    Prattski
 * @package     Prattski_ImageImport
 */
class Prattski_ImageImport_Model_Catalog_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()
            ->reset();
 
        if (empty($importData['store'])) {
            if (!is_null($this->getBatchParams('store'))) {
                $store = $this->getStoreById($this->getBatchParams('store'));
            } else {
                $message = Mage::helper('catalog')->__(
                    'Skipping import row, required field "%s" is not defined.',
                    'store'
                );
                Mage::throwException($message);
            }
        }
        else {
            $store = $this->getStoreByCode($importData['store']);
        }
 
        if ($store === false) {
            $message = Mage::helper('catalog')->__(
                'Skipping import row, store "%s" field does not exist.',
                $importData['store']
            );
            Mage::throwException($message);
        }
 
        if (empty($importData['sku'])) {
            $message = Mage::helper('catalog')->__('Skipping import row, required field "%s" is not defined.', 'sku');
            Mage::throwException($message);
        }
        $product->setStoreId($store->getId());
        $productId = $product->getIdBySku($importData['sku']);
 
        if ($productId) {
            $product->load($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'
                );
                Mage::throwException($message);
            }
            $product->setTypeId($productTypes[strtolower($importData['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, the value "%s" is invalid for field "%s"',
                    $value,
                    'attribute_set'
                );
                Mage::throwException($message);
            }
            $product->setAttributeSetId($productAttributeSets[$importData['attribute_set']]);
 
            foreach ($this->_requiredFields as $field) {
                $attribute = $this->getAttribute($field);
                if (!isset($importData[$field]) && $attribute && $attribute->getIsRequired()) {
                    $message = Mage::helper('catalog')->__(
                        'Skipping import row, required field "%s" for new products is not defined.',
                        $field
                    );
                    Mage::throwException($message);
                }
            }
        }
 
        $this->setProductTypeInstance($product);
 
        if (isset($importData['category_ids'])) {
            $product->setCategoryIds($importData['category_ids']);
        }
 
        foreach ($this->_ignoreFields as $field) {
            if (isset($importData[$field])) {
                unset($importData[$field]);
            }
        }
 
        if ($store->getId() != 0) {
            $websiteIds = $product->getWebsiteIds();
            if (!is_array($websiteIds)) {
                $websiteIds = array();
            }
            if (!in_array($store->getWebsiteId(), $websiteIds)) {
                $websiteIds[] = $store->getWebsiteId();
            }
            $product->setWebsiteIds($websiteIds);
        }
 
        if (isset($importData['websites'])) {
            $websiteIds = $product->getWebsiteIds();
            if (!is_array($websiteIds) || !$store->getId()) {
                $websiteIds = array();
            }
            $websiteCodes = explode(',', $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) {}
            }
            $product->setWebsiteIds($websiteIds);
            unset($websiteIds);
        }
 
        foreach ($importData as $field => $value) {
            if (in_array($field, $this->_inventoryFields)) {
                continue;
            }
            if (is_null($value)) {
                continue;
            }
 
            $attribute = $this->getAttribute($field);
            if (!$attribute) {
                continue;
            }
 
            $isArray = false;
            $setValue = $value;
 
            if ($attribute->getFrontendInput() == 'multiselect') {
                $value = explode(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 = false;
                    foreach ($options as $item) {
                        if ($item['label'] == $value) {
                            $setValue = $item['value'];
                        }
                    }
                }
            }
 
            $product->setData($field, $setValue);
        }
 
        if (!$product->getVisibility()) {
            $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
        }
 
        $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];
                }
            }
        }
        $product->setStockData($stockData);
 
        $mediaGalleryBackendModel = $this->getAttribute('media_gallery')->getBackend();
 
        $arrayToMassAdd = array();
 
        foreach ($product->getMediaAttributes() as $mediaAttributeCode => $mediaAttribute) {
                if (isset($importData[$mediaAttributeCode])) {
                $file = trim($importData[$mediaAttributeCode]);
                if (!empty($file) && !$mediaGalleryBackendModel->getImage($product, $file)) {
                    $arrayToMassAdd[] = array('file' => trim($file), 'mediaAttribute' => $mediaAttributeCode);
                }
            }
        }
 
        /**
         * Added code to enable/disable the exclude checkbox for main product images
         */
 
        $_exclude = (Mage::getStoreConfig('catalog/catalog/image_exclude_enabled')) ? true : false;
 
        $addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
            $product,
            $arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',
            false,
            $_exclude
        );
 
        /**
         * End new code
         */
 
        /**
         * Added code to allow the import of additional product images
         */
        $_column = Mage::getStoreConfig('catalog/catalog/multiple_image_column_name');
        if ($importData[$_column]) {
            $additionalImages = explode(';',$importData[$_column]);
            foreach ($additionalImages as $image) {
                if (!empty($image) && !$mediaGalleryBackendModel->getImage($product, $image)) {
                    $arrayToMassAdd2[] = array('file' => trim($image));
                }
            }
        }
 
        $addedFilesCorrespondence .= $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
            $product,
            $arrayToMassAdd2, Mage::getBaseDir('media') . DS . 'import',
            false,
            false
        );
        /**
         * End new code
         */
 
        foreach ($product->getMediaAttributes() as $mediaAttributeCode => $mediaAttribute) {
            $addedFile = '';
            if (isset($importData[$mediaAttributeCode . '_label'])) {
                $fileLabel = trim($importData[$mediaAttributeCode . '_label']);
                if (isset($importData[$mediaAttributeCode])) {
                    $keyInAddedFile = array_search($importData[$mediaAttributeCode],
                        $addedFilesCorrespondence['alreadyAddedFiles']);
                    if ($keyInAddedFile !== false) {
                        $addedFile = $addedFilesCorrespondence['alreadyAddedFilesNames'][$keyInAddedFile];
                    }
                }
 
                if (!$addedFile) {
                    $addedFile = $product->getData($mediaAttributeCode);
                }
                if ($fileLabel && $addedFile) {
                    $mediaGalleryBackendModel->updateImage($product, $addedFile, array('label' => $fileLabel));
                }
            }
        }
 
        $product->setIsMassupdate(true);
        $product->setExcludeUrlRewrite(true);
 
        $product->save();
 
        return true;
    }
}

Step 6

To recap all the files we have made:

  • /app/etc/modules/Prattski_ImageImport.xml
  • /app/code/local/Prattski/ImageImport/etc/config.xml
  • /app/code/local/Prattski/ImageImport/etc/system.xml
  • /app/code/local/Prattski/ImageImport/Helper/Data.php
  • /app/code/local/Prattski/ImageImport/Model/Catalog/Convert/Adapter/Product.php

Test it out! You’ll be able to see if Magento recognizes your module by going to System > Configuration > Advanced. If you see the module in the list, Magento knows it’s there. You can also go to System > Configuration > Catalog > Catalog > Import Image Options to see the configuration options we setup there.

If all looks good, then you are ready for a test. Setup your CSV import file, including a new column called ‘additional_images’ (or whatever you changed it to in the system config) and populate it with images to import. When ready, go to System > Import/Export > Dataflow – Profiles and select the Import All Products and give it a go!

I hope you enjoyed learning how to build this module. If you find any issues or bugs, please let me know. Remember, this is for Magento 1.5.x and probably will not work on 1.4.x and lower.

This entry was posted in Magento. Bookmark the permalink.

59 Responses to Magento: Revised Multiple Image Import Module (1.5 +)

  1. RSmith says:

    I am also getting this message when I try to import

    ” Method “parse” not defined in adapter catalog/convert_adapter_product”

  2. RSmith says:

    I loaded everything and it looks good, I can see it in configuration>advanced>advanced, but I can not in configuration>catalog>catalog?

  3. Cindy says:

    Hey Josh. Thank you very much for the charm plugin. Everything works great in CE1.7.0.2. Just one minor issue. All additional images have no lable. Is there any way to add labels to each additional image? Or at least, share the same lable as primary image? I tried to add “additional_images_label” column, but it didn’t work.

    Thank you in advance to help you look into this.

  4. biggles says:

    Hey thanks dude. Worked first go…. You are a legend :)

  5. dhara says:

    Thanks a lot ,it’s working with magento 1.7 also .
    just make sure that addition_images have ; not ,

  6. After 5 days of moving products and images from another system…. :)
    Even tried magmi, fresh installs, “manual DB”, my own module…
    But this works great. Life saver. :)
    Oh, Magento 1.7..0.2 CE.

    Thank you!

    Best regards from Slovenia, Jernej

  7. Flavio says:

    hi Josh
    I followed the instructions step by step, but I get the same error as described by John :
    Fatal error: Cannot use string offset as an array in …\ImageImport\Model\Catalog\Convert\Adapter\Product.php on line 278 –
    I would appreciate if you wrote the solution

    Thanks !

  8. LilyZhan says:

    HI Josh, Thank you so much for your great job. I follow your article step by step, and it worked like a charm on Magento 1.7.0.2.
    and I so find the reason for those comments “Image does not exist.”, you need to add / before your image file name.
    Before I upload the multiple images by your module, I have already imported all the products with (image, small_image, thumbnail) to Magento. so now I only need to import those multiple images. in the csv file, I only input two columns, one is sku, keep the same name as before. another column is additional_images, here is more trick, first of all, in this column, only put the new image, don’t put the previous main image again. e.g, in my back end, the sku 1440, it has the main image 1440.jpg, now I want to import three more images for this sku, I input “/1440-1.jpg;/1440-2.jpg;/1440-3.jpg” in the column of “additional_images”, here you go, prepare your csv file, then import from the dataflow.

    Thank you again. You save me at least one week.
    BTW, here is my website, http://www.streamlinefurniture.ca, and I spend about 2 weeks to find the way to show the big image when the mouse hover the thumbnail in the category page, if someone wants it, please feel free to contact me at lilyzhanca@gmail.com, I can share it.

    LilyZhan

  9. Good job mate. Worked like a charm on Magento 1.7.0.2 first time round.

    Cheers,
    Michael.

  10. Gerben says:

    Nice job!
    When I put a slash (“/”) in front of an image I get this error:
    Warning: array_search() expects parameter 2 to be array, string given in C:\Program Files (x86)\EasyPHP-5.3.2\www\magento\app\code\local\Prattski\ImageImport\Model\Catalog\Convert\Adapter\Product.php on line 277

    If I don’t put a slash I get the error: “Image does not exist.”
    Just like Terry in March 2012.

    Does anyone has a solution for this?

    Thanks!

  11. Alfonso Urdaneta says:

    Confirmed as not working in 1.7.0.2 Community Edition.

    Image names without preceding slashes cause it to fail with “image does not exist” error. Image names with preceding slashes cause the import to hang forever.

  12. Harchenko says:

    Thank you so much, Josh.
    Work like a charm (Magento 1.6).

  13. Kris Sookma says:

    This does not seem to work in 1.7. The configuration option in configuration –> catalog –> catalog does not appear…

  14. Thomas says:

    Thanks a ton Josh for this awesome module. Tested in 1.5.1.0, works flawlessly. Anywhere we can donate to?

    Thanks again.

  15. Tom says:

    Thanks for this Josh, it’s worked perfectly on Magento 1.7.x (1.7.0.2).

    I was fully prepared to get my hands dirty when I got an error about a missing ::parse() method.

    Turns out, the module filenames are case sensitive.

    • erin says:

      What did you do to fix this? I am getting the same error.

      • erin says:

        Nevermind, it was a stupid user error. I did not have the correct directory structure. Once I went through and actually followed the directions, (and added the leading slash in front of the image names in additional_images column), this module worked like a dream! I am using Magento 1.7 by the way.

        Thanks Josh, you rock and you are a real asset to the Magento community.

  16. Pingback: Uploading multipile items with including images into your Magento CE store | A & G Webtech Blog

  17. Björn says:

    Thanks for this great module. We’ve installed it on Magento 1.5.x and it works just perfect. Is it still necessary when using Magento 1.7.x?

  18. Nirav says:

    Thanks a lot……..

    It works like a charm…….

  19. Jakub says:

    Hale to you allmighty Josh Pratt for making this module and letting others like me using and implementing it themselves. It works gr8 on Magento 1.6.2.0! An I have to add that I don’t know nothing about php so this tutorial is a lifesaver for me.
    I got one error however, the same as John in the reply above from July 30, 2011 at 12:48 pm
    Fatal error: Cannot use string offset as an array in …\ImageImport\Model\Catalog\Convert\Adapter\Product.php on line 278
    The solution made by LuisR worked like a charm :) :
    He has added an isset to workarround the problem:

    if(isset($addedFilesCorrespondence[‘alreadyAddedFilesNames’][$keyInAddedFile])){
    $addedFile = $addedFilesCorrespondence[‘alreadyAddedFilesNames’][$keyInAddedFile];
    }

  20. Laura says:

    I love this module however, I can’t even get the image, small_image, thumbnail to upload. Every time I run an import with an image in it, i get “image does not exist” I am doing nothing different than I was doing previously. If I don’t include any images the 500 products work fine. My image files match my sku numbers but I can’t get the csv or xml file to find the image. Any ideas on what might be the problem.

  21. Terry says:

    Hi,
    After four years of individually loading up extra images I was excited to see this module. However, I’ve spent numerous hours so far, on this and can’t seem to get this module to go on 1.5.0.1. I’ve set up and copied word for word what you have on this page. I’ll get two different error results, depending on whether I add a “/” before the image name or not, but it will not load up the additional image.

    Since creating this site in 2008, the practice back then was to create double folders within the media>import folder.
    For example: If I import a csv file with item which contains a specific ‘image’ “/7/8/78BBQGRILL.jpg”, ‘small_image’ “/7/8/78BBQGRILL.jpg” and ‘thumbnail’ “/7/8/78BBQGRILL.jpg”, these images will be in folder “8″ … media>import folder>7>8. So then when I add the additional image field with one additional image for an item, in the ‘additional_images’ /B/B/BBQTOOLS.jpg”, I’ll get two different error results, depending on whether I add a “/” before the image name or not.
    With a “/”, I get this error: “Warning: array_search() [function.array-search]: Wrong datatype for second argument in /chroot/home/website/website.com/html/app/code/local/Prattski/ImageImport/Model/Catalog/Convert/Adapter/Product.php on line 276″
    Without a “/”, I get this error: No Image Found.
    Even if I put a copy of the image just inside the import folder, (BBQTOOLS.jpg without /B/B) and change the image name in addational_image to either with or without “/”, I get the same results. I’ve even switched the “enable” setting in the admin panel back and forth between “yes” and “no” and there’s no difference. Any ideas?
    Thanks

  22. T says:

    At least you could have responded privately instead of just deleting my post, with out any explanation as to what might be wrong, or why your module’s code doesn’t work on a basic 1.5 install.
    Thanks

    • Josh Pratt says:

      @T – My module works. If it’s not working for you, it most likely is because you did something wrong, or something else is interfering. Loads and loads of people get it to work from my blog post just fine. I get tons of comments – so if I deleted it, it was probably because you put in tons of code or something. I usually don’t delete comments otherwise.

  23. Thomas says:

    I am having the same problem as lily. Using 1.6.1.0. Any advice will be appreciated.

  24. robena says:

    thanks a lot!

    it works fine without any modification on my 1.6

  25. Eady says:

    Wow what a great extension. It worked like a charm and will save us a great deal of time.

  26. lily says:

    Hi, thanks for posting!
    but one quesiton: when i followed your 6 steps and created all those files, I cannot see the module that i set by going to System > Configuration > Advanced, please tell why. but i’ve already created all those files sucessfully. any idea where is wrong??

  27. Anthony says:

    Hmm, I just read about having to clear the cache after making changes like these, and it seems that was the only thing I had to do, I’ll report back :)

  28. Anthony says:

    I know it says this is for 1.5 + but, do you have any ideas/pointers to make it work for Magento 1.6.1?.

  29. LuisR says:

    Nice, Works for me on 1.6 with some modifications.
    Will be nice to add labels for additional images, or to get the base image label for each one.
    After moving to staging whit a new version of php I got the same error of: John says July 30, 2011 at 12:48 pm

    I’ve added an isset to workarround the problem:

    if(isset($addedFilesCorrespondence[‘alreadyAddedFilesNames’][$keyInAddedFile])){
    $addedFile = $addedFilesCorrespondence[‘alreadyAddedFilesNames’][$keyInAddedFile];
    }

    • YES!!! This finally got it working for me! Life-saver… awesome work Josh & friends.

      • Joshua says:

        Hi, I’m really new to PHP and would appreciate if you could point out where exactly should I add or replace the code.

        Cheers!

        • Josh Pratt says:

          Joshua – I very clearly detailed out what you need to do in the article. I gave the location to put the files, and what to name them. No replacing necessary, only new files. If you read it more carefully, you’ll see what you need to do.

  30. PaulyPaul says:

    strange to me that they left this out….

    does this hack work on 1.6?

    tia!

  31. sjolzy says:

    On the line #255 of file “Model/Catalog/Convert/Adapter/Product.php”, you must pre-defined array parameter “$arrayToMassAdd2” like the defined of “$arrayToMassAdd” in line #219;

  32. Jeremaine M. Osia says:

    do this still work with 1.6.1.0?

  33. Laura says:

    Everything worked great! This was just what I was looking for since I used your older version before.
    However, I have one issue, how to get I get the main image to have the “exclude” box to become UNchecked? I have done it before, but can’t seem to find where I did that before.
    If you can help that would be wonderful!
    Thanks again, it worked just like before.

  34. masterperoo says:

    Somehow this module adds same images to the product over and over again on every import. Even the main image.
    Is there any setting anywhere or should i study your code ?

  35. InSmoke says:

    Hi

    Thank you very much for your Article. I managed with it import from OsCommerce with all images!

    thanks!

  36. Meena says:

    Hi, Thanks.
    Was going through a lot of thread and this one made my day!

  37. Jason says:

    Hi,

    Could you pls upload a sample csv ?

    cheers,
    Jason.

  38. Nick says:

    Hello,
    have you a sample of the csv file?

    thank you for this module!

  39. Simon says:

    Hi,
    I get the error “image does not exist”. Then I tried putting in the slash / in front of the image, ,small_image and thumbnail columns but still get same error. Finally it worked putting the slash in front of all image names also in the additional_image column.

    Do you know a way of not having to put the slashes in front of the image names? I’m sure there is a fix in the Product.php file

    Someone found a solution for this in a similar module: http://www.magentocommerce.com/boards/viewreply/185104/
    Maybe it gives you an idea.
    Thanks

    • Josh Pratt says:

      Simon – Why does there need to be a solution for that? It’s not an issue to just put a slash in front of the image names…

  40. magento 1.5.1.0 how to import product Multiple Image and custom options.
    you only say multiple image…

  41. C Thamer says:

    You have an error in your code. The line that starts with:
    $addedFilesCorrespondence .=
    is using string concatenation with an array.

  42. Bofrey Jones says:

    Your naming conventions throughout this post are different at the end than what you use throughout your article. It’s not working for me probably because of that so I’m going to start again :)
    ie
    Prattski_ImportImages.xml vs. Prattski_ImageImport.xml

    • Josh Pratt says:

      Thanks for pointing that out Bofrey. I made the change.

      • John says:

        I’m getting this error message : Fatal error: Cannot use string offset as an array in …\ImageImport\Model\Catalog\Convert\Adapter\Product.php on line 278

  43. Pingback: Magento: Revised Multiple Image Import Module (1.5 +) | Prattski | Magento & Web Development | Magento Training Course