Importing product images with CSV

Last modified by Unirgy on Sun, March 22, 2009 01:49
Source|Old Revisions  |  Back To Group

I’ve seen recently this issue - editing and saving products in admin deleted existing images from frontend.

On evaluation it appeared that the images, while showing on the frontend, did not appear in the admin product edit Images tab at all.

Inspection of the database tables revealed that while EAV records contained image names (used on frontend), the image gallery (used in admin) was missing the relevant entries, so it appears that CSV import does not populate gallery table.

This problem will happen with both new and updated products, when new image names are added with CSV.

I’ve made an SQL statement that will fill the missing records, and which you will need to run each time after importing products with images using CSV:

  1. INSERT INTO catalog_product_entity_media_gallery (attribute_id, entity_id, `value`)
  2. SELECT ga.attribute_id, v.entity_id, v.value
  3. FROM catalog_product_entity_varchar v
  4. INNER JOIN eav_entity_type et ON et.entity_type_code='catalog_product'
  5. INNER JOIN eav_attribute va ON va.entity_type_id=et.entity_type_id AND va.frontend_input='media_image' AND va.attribute_id=v.attribute_id
  6. INNER JOIN eav_attribute ga ON va.entity_type_id=et.entity_type_id AND ga.attribute_code='media_gallery'
  7. LEFT JOIN catalog_product_entity_media_gallery g ON g.entity_id=v.entity_id AND g.value=v.value
  8. WHERE v.value<>'no_selection' AND v.value<>'' AND g.value IS NULL;



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs