Magento - Adding multiple images with a product form csv file?
Solution 1
I have not used gallery images, but I'm not certain that's what you really want. If you want to import multiple images in a product detail page here's what you need to do with your CSV file.
1) CSV import in Magento assumes your images are in media/import. So all references in your CSV file should be listed from there. For example if your image to import is:
media/import/image1.jpg
then your image needs to be listed in the CSV file as just /image1.jpg (leading slash required).
2) To add 'media images' use the columns: _media_attribute (seems to default to 77, check an export to confirm) _media_image - this is the name of your image file (e.g. /image1.jpg) _media_lable (notice misspelling is NOT a typo) - This is the image label _media_position - ordering of images (e.g. 1, 2, 3, ...) _media_is_disabled - 1 = disabled, 0 = enabled
Enter multiple images then on multiple rows for one product such as:
_media_attribute _media_image _media_lable _media_position _media_is_disabled
77 /image1.jpg Image 1 label 1 0
77 /image2.jpg Image 2 label 2 0
If you want to designate any of these as your default image, small image or thumbnail, then you need to put these same images and labels in the corresponding columns for (image, image_label), (small_image, small_image_label), (thumbnail, thumbnail_label) respectively.
Hope that's helpful.
Solution 2
Here's how to do it with the DataFlow Importer for Magento 1.6.1, got it from here
- So you don't edit core files, make a copy of app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php into app/code/local/Mage/Catalog/Model/Convert/Adapter/
- Edit app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php and add the following after line 799:
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 ); }
...so you end up with this:
793 $addedFilesCorrespondence = $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
794 $product,
795 $arrayToMassAdd, Mage::getBaseDir('media') . DS . 'import',
796 false,
797 false
798 );
799 /* http://www.magentocommerce.com/boards/viewthread/224928/P30/#t403196 */
800 if (isset($importData['media_gallery']) && !empty($importData['media_gallery'])) {
801 $x = explode(',', $importData['media_gallery']);
802 foreach ($x as $file) {
803 $imagesToAdd[] = array('file' => trim($file));
804 }
805
806 $mediaGalleryBackendModel->addImagesWithDifferentMediaAttributes(
807 $product,
808 $imagesToAdd, Mage::getBaseDir('media') . DS . 'import',
809 false,
810 false
811 );
812 }
If your CSV file, add a column called *media_gallery*, and put your other images in /media/import:
media_gallery
-------------
/s/e/second_image.png, /t/h/third_image.png,/f/o/fourth_image.png
Solution 3
Not sure if this is still correct, but according to this Magento wiki entry it looks like the default data import does not handle importing gallery images correctly.
You can run the SQL script after each import, as suggested on the wiki page, or you could look at using something like Magmi which, I know from experience, handles gallery images correctly...and faster than the default Magento importer
user1188320
Updated on June 12, 2022Comments
-
user1188320 almost 2 years
I need to display multiple product images on details page, so i add i column named
gallery
in the csv file. and add some values like this in a box/hogan/gray1.jpg,/hogan/gray2.jpg,/hogan/gray3.jpg
i put the images into the
import/hogan
file. then import the csv file. but there is no display multiple product images on details page.why?? -
user1188320 about 12 yearsi export an csv file, why there is no _media_attribute _media_image columns. thank you