Magento import multiple images in dataflow csv/xml

Sometimes it’s really annoying that Magento only supports one image per product. On the Magento Commerce forum a solution is found:

Now, what you need to do is open the file
app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php
and go to around line 773 and find

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

and paste the following code right after it
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
);
}

Source: http://www.magentocommerce.com/boards/viewthread/224928/P45/

2 thoughts on “Magento import multiple images in dataflow csv/xml”

  1. Hi, i have done this, but my media gallery images is beeing imported with the “exclude” box ticked, any advise for this?

  2. krzysztof.bielec

    Thx for your post.

    My fixed version for media_gallery separated images by “;”

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

Leave a Comment

Your email address will not be published. Required fields are marked *

en_USEnglish
Scroll to Top