how to get rid of all the photo except default ones?
FooLab last edited by FooLab
I’m in the middle of an import from Virtuemart => external service => TB.
I have all the products with multiple images (double/triple/quadruple) caused from something gone wrong with some syncs in the past.
What can I do to delete from every TB products (database and filesystem) all the images except the default ones?
p.s. AFAIK prestools mass edit can’t do that
musicmaster last edited by musicmaster
That depends on how the images have been inserted in the database. If each product has one image that is “cover” then it is relatively simple - assuming you are familiar with mysql and PHP. You get then in pseudocode the following:
SELECT id_image AS myimage FROM tb_image WHERE cover IS NULL
DELETE FROM tb_image WHERE id_image=myimage
DELETE FROM tb_image_lang WHERE id_image=myimage
DELETE FROM tb_image_shop WHERE id_image=myimage
That is the database part. But you will also want to delete the images themselves. You can do that with Prestools (it is a paid addon) or you can program it yourself in the loop above.
If there is not a cover for each product (what means that all cover values are NULL) then the loop will become a bit more complicated. So it is important at the start to check that all products have one image where the “cover” field is ‘1’.