Importing Several Gallery Images per Product in Magento
Magento 1’s standard product import only handles the base, small and thumbnail images. If each product has a full gallery, a small change lets you import extra images from one CSV column.
Step 1: find the import adapter
Copy app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php to the local code pool (never edit core directly), then find this block:
<?php
$addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
$product,$arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',false,false);
?>
Step 2: add gallery handling
Directly after it, add:
<?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);
}
Step 3: prepare the CSV
Add a column named media_gallery and list the image paths separated by commas, for example /s/e/second_image.png,/t/h/third_image.png. Upload the files to media/import before running the profile.
Heads up: this guide applies to Magento 1, which stopped receiving official security updates in June 2020. If your store still runs it, plan a move to Magento 2 or Adobe Commerce soon. We can help with the migration.
Want this done for you? Find out more about our Magento development service.