3

When I import CSV file for products I got every time duplicate products images.
I must import the CSV file every time with products images value for all products there for I got duplicate products images.

Now, I must remove all products images for a specific store/website before import same products with CSV.

3 Answers 3

0

The following SQL will remove all images and labels from the database

DELETE FROM catalog_product_entity_varchar
WHERE  attribute_id IN (SELECT attribute_id
                        FROM   `eav_attribute`
                        WHERE  store_id = REPLACE_WITH_STORE_ID and attribute_code IN (
                               'small_image', 
                               'small_image_label',
                               'image',
                               'image_label',
                               'thumbnail',
                               'thumbnail_label' )) 

Also run the following to remove the images from the server

rm -rf pub/media/catalog/*

2
  • It's not working.
    – Efex
    Commented Mar 13, 2019 at 0:58
  • The command at the bottom would also remove category images...
    – Imanuel
    Commented Aug 31, 2022 at 15:28
0

If you want to delete store specific images you need to run next sql queries:

DELETE FROM catalog_product_entity_media_gallery_value WHERE store_id=STORE_ID;
DELETE FROM catalog_product_entity_varchar where attribute_id IN (87,88,89) and row_id = ANY (select row_id from catalog_product_flat_STORE_ID);
UPDATE `catalog_product_flat_STORE_ID` SET `image` = NULL, `small_image` = NULL, `swatch_image` = NULL, `thumbnail` = NULL WHERE `attribute_set_id` = 4;

Hope that helps you.

-2

Please try with below query which is remove your primary image.

DELETE FROM catalog_product_entity_varchar WHERE  attribute_id IN (87,88,89) AND entity_id='product_id'

second query here

DELETE FROM catalog_product_entity_media_gallery WHERE attribute_id=90 and entity_id='product_id'

Note : Please verify attribute_id in eav_attribute table like value is base, thumnail, small_image.

3
  • I need it for a specific store.
    – Efex
    Commented Mar 13, 2019 at 0:32
  • please check with 'catalog_product_entity_media_gallery_value' this table. Commented Mar 15, 2019 at 6:11
  • not only are you hard coding foreign key values from other tables but you're not specifying a reference to the store which is the entire purpose of the question. Terrible answer. Commented Mar 10, 2020 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.