WooCommerce-REST-API-Client-Library icon indicating copy to clipboard operation
WooCommerce-REST-API-Client-Library copied to clipboard

updating product w/ same images causes image duplication

Open kg4nds opened this issue 8 years ago • 2 comments

This is really a 2 fold problem.

The first is that when I do a basic product update with images the api doesn't check to see if those images are the same or not. instead of just overwriting the file that already exists, it creates a new image file set. That would be just fine except that there is NO way to delete images or image (sets) from the API which is my #2 line item. #2 there is no way to delete images via ID. I can hard code a file delete but the "placeholder" on woocommerce still exists but only shows that the image link is broken because the file is no longer on the server.

Any thoughts on this would be VERY helpful

kg4nds avatar Mar 17 '16 19:03 kg4nds

well, Finally, I have found something on this issue with the following link; http://stackoverflow.com/questions/33299862/woocommerce-rest-api-updating-images-issue

it still doesn't cover the delete issue. we have a need to be able to delete product image files via the API.

kg4nds avatar Mar 18 '16 15:03 kg4nds

This is an issue deeper in WC, I believe. The same thing happens when setting up products from CSV using any of the CSV importer plugins for WC. This is especially a problem with variable products, where each variation could have a bunch of identical images.

What I have had to do on some larger sites, is remove all the duplicates and relink the originals to where the duplicates were removed. That process starts by scanning all images linked to products, then generating a hash from the source image file. That hash can then be compared to other hashes to find the identical images. I wrote a plugin to do this some time ago, but never got around to releasing it.

judgej avatar Mar 24 '16 14:03 judgej