Alle Produktbilder löschen in Magento 2

Löschen der Bilder aus der Datenbank:

TRUNCATE TABLE mage_catalog_product_entity_media_gallery_value;
TRUNCATE TABLE mage_catalog_product_entity_media_gallery_value_to_entity;
delete from mage_catalog_product_entity_media_gallery;
delete from mage_catalog_product_entity_varchar where attribute_id in ( select 
attribute_id from mage_eav_attribute where attribute_code IN ( 'image', 'small_image', 'thumbnail', 'swatch_image', 'media_gallery' ) AND entity_type_id = 4 );

Löschen der Bilder von der Festplatte

# Originale (alles außer placeholder und .htaccess)
find pub/media/catalog/product -mindepth 1 -maxdepth 1 \
! -name 'placeholder' ! -name '.htaccess' -exec rm -rf {} +

Cache-Resizes löschen

rm -rf pub/media/catalog/product/cache/*
rm -rf pub/media/tmp/catalog/product/*

Und Indexe neu machen

maglive indexer:reindex
maglive cache:flush
maglive catalog:images:resize

Schreibe einen Kommentar

Menü schließen