Magento: Import Multiple Images per Product

Magento: Import Multiple Images per Product

Import Magento multiple product images in one go by extending the product import adapter — full gallery support for every SKU.

Magento add Multiple images to products

Magento add Multiple images to products programmatically

First Go to appcodecoreMageCatalogModelConvertAdapterProduct.php

Open Product.php file and find this Code

<?php 
   $addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
         $product,$arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',false,false);
 
?>

After this put this code in File

<?php

if (isset($importData['media_gallery']) && !empty($importData['media_gallery'])) {
    $x = explode(';', $importData['media_gallery']);
    foreach ($x as $file) {
       $imagesToAdd[] = array('file' =>; trim($file));
    }
 
$mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
     $product,$imagesToAdd, Mage::getBaseDir('media') . DS . 'import',false,false);
}

Now open your Product’s csv file and add column named “media_gallery”

and then add images comma (‘,’) seprated like below

e.g : /s/e/second_image.png, /t/h/third_image.png,/f/o/fourth_image.png

Still on Magento 1? This tutorial is for Magento 1.x, which reached end of life in June 2020 and no longer receives security patches. Our team migrates Magento 1 stores to Magento 2, Mage-OS or Adobe Commerce with your SEO and data intact — see our Magento development services.

Further reading: OpenMage, the community-maintained Magento 1 fork. Need a hand? Our Magento development team can help.

Need a hand?

Stuck on a build?
Let's solve it together.

Our engineers fix, upgrade and scale Magento, WordPress and modern stacks every day.