Zen Cart Logo
Forums / Bug Reports / Delete Product - does not delete Attribute Images from server

Delete Product - does not delete Attribute Images from server

Views: 2,014

Results 1 to 7 of 7
27 Apr 2015, 4:26 PM
#1
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Delete Product - does not delete Attribute Images from server

To reproduce:

Working

  • Create a product
  • Upload an image to the product
  • Delete the product and the image deletes from the server

Not Working

  • Create a product
  • Upload an image to the product
    - Add Attribute with Attributes Image Swatch
  • Delete the product and the image deletes from the server...** but none of the additional attribute images will delete.**

Server hit 10,000 images in the images folder and got grumpy. Then this bug was found.

28 Apr 2015, 8:45 PM
#2
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Delete Product - does not delete Attribute Images from server

twitchtoo:

To reproduce:

Working

  • Create a product
  • Upload an image to the product
  • Delete the product and the image deletes from the server

Not Working

  • Create a product
  • Upload an image to the product
    - Add Attribute with Attributes Image Swatch
  • Delete the product and the image deletes from the server...** but none of the additional attribute images will delete.**

Server hit 10,000 images in the images folder and got grumpy. Then this bug was found.

If you delete the attribute options & values do the images get deleted at that point?

29 Apr 2015, 2:08 AM
#3
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Delete Product - does not delete Attribute Images from server

Isn't that default behaviour as attribute images are often used by multiple products with those attributes, so they are not actually tied to the image as such.

The attribute image is tied to the attribute, what happens when the attribute is deleted?

as to 10,000 images in the images folder, are these all in the root images folder or the total of all images in various subdirectories?

Years ago I wrote a script (no longer have it now as that site is defunct) that set a new default images subdirectory every month (kind of like wordpress does) for images uploaded via the admin products page

21 Dec 2016, 8:12 AM
#4
muteyaar avatar

muteyaar

Zen Follower

Join Date:
Oct 2007
Posts:
134
Plugin Contributions:
0

Re: Delete Product - does not delete Attribute Images from server

nigelt74:

Isn't that default behaviour as attribute images are often used by multiple products with those attributes, so they are not actually tied to the image as such.

The attribute image is tied to the attribute, what happens when the attribute is deleted?

as to 10,000 images in the images folder, are these all in the root images folder or the total of all images in various subdirectories?

Years ago I wrote a script (no longer have it now as that site is defunct) that set a new default images subdirectory every month (kind of like wordpress does) for images uploaded via the admin products page

Hi, I want to delete images for all the deactivated products collectively. is there any way to do so?
If I delete a product from the admin area, it deletes only the main image of the product. The additional images are still there on the server and are using a lot of disk space.

Also, is there any way that i can delete all the deactivated products collectively? I have thousands of products which have been decativated now and want to make some disk space on the server.

Can anyone hep me in this regard please?

thanks in advance.

muteyaar

21 Dec 2016, 3:42 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Delete Product - does not delete Attribute Images from server

muteyaar:

Hi, I want to delete images for all the deactivated products collectively. is there any way to do so?
If I delete a product from the admin area, it deletes only the main image of the product. The additional images are still there on the server and are using a lot of disk space.

Also, is there any way that i can delete all the deactivated products collectively? I have thousands of products which have been decativated now and want to make some disk space on the server.

Can anyone hep me in this regard please?

thanks in advance.

muteyaar
So, there is an image plugin that is intended to identify a discrepancy of image with product and I guess allow deletion from the tool or matching with a product, whichever the case. I believe that would help with the additional images files.

As to deletion of products to make file storage space, well the two aren't quite directly linked that way. The image part, okay, get that. But the content seen by customers/entered to describe the product is not really taking disk space like you may be thinking about as its all in the database.

As to performing bulk action on the database, there's EasyPopulate V4 which could be used to 1) identify the path to the primary image for the product 2) delete the product following standard ZC product deletion process, 3) with the information about the image could perform further actions/investigation into what images need to be removed.

Be sure though that if you decide to go down the product deletion path that you will still have a good way for visitors that did have a link to the now deactivated product to be handled when the product no longer exists in the database.

22 Dec 2016, 12:39 AM
#6
muteyaar avatar

muteyaar

Zen Follower

Join Date:
Oct 2007
Posts:
134
Plugin Contributions:
0

Re: Delete Product - does not delete Attribute Images from server

mc12345678:

So, there is an image plugin that is intended to identify a discrepancy of image with product and I guess allow deletion from the tool or matching with a product, whichever the case. I believe that would help with the additional images files.

As to deletion of products to make file storage space, well the two aren't quite directly linked that way. The image part, okay, get that. But the content seen by customers/entered to describe the product is not really taking disk space like you may be thinking about as its all in the database.

As to performing bulk action on the database, there's EasyPopulate V4 which could be used to 1) identify the path to the primary image for the product 2) delete the product following standard ZC product deletion process, 3) with the information about the image could perform further actions/investigation into what images need to be removed.

Be sure though that if you decide to go down the product deletion path that you will still have a good way for visitors that did have a link to the now deactivated product to be handled when the product no longer exists in the database.

Dear mc12345678, thanks for replying to my query.

I understand well that the product description does not take much space on the server. But I have around 3 or 4 images per each product and the images are of 1MB size approximately each. So, it is taking big space. I could not find any plugin which can delete the additional images for multiple products. If there is any plugin which can delete just the additional images only and keep the main image intact, that will be the best option for me. I will in that case may not delete the old products and will be able to make some space on the server.

Deleting the additional images through cpanel file manager one by one is very time taking process. So, I was thinking of some easier way of doing this collectively for multiple products.

I hope to receive a helpful reply.

Many thanks.

22 Dec 2016, 4:49 AM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Delete Product - does not delete Attribute Images from server

muteyaar:

Dear mc12345678, thanks for replying to my query.

I understand well that the product description does not take much space on the server. But I have around 3 or 4 images per each product and the images are of 1MB size approximately each. So, it is taking big space. I could not find any plugin which can delete the additional images for multiple products. If there is any plugin which can delete just the additional images only and keep the main image intact, that will be the best option for me. I will in that case may not delete the old products and will be able to make some space on the server.

Deleting the additional images through cpanel file manager one by one is very time taking process. So, I was thinking of some easier way of doing this collectively for multiple products.

I hope to receive a helpful reply.

Many thanks.
Not entirely sure you understand the difference between the space taken by the product and the space taken by the image. The product information including the path to the image(s) is in the database. The files are on the server.

Now that said, there is a image purge utility that likely still works even on newer versions of ZC. I haven't used it, but it is one way I can see approaching the issue: https://www.zen-cart.com/downloads.php?do=file&id=1690

So, from the download page it looks like the images are scavenged and a "database" match is determined. If the image(s) don't fit some pattern that is expected by ZC then they could/would be deleted. So, thing is, for that to come up true (suggest testing on a backup of your site), then the database record for images of disabled product would need to be "cleared". So, you could either use one of the mass upload/download products to support making a backup of the product information (specifically the image path) before wiping that information, or can run a sql command to clear the products_image path for all product that have products_status = 0 or any other set of constraints. Once there is no record in the database for the images to be deleted, then the above plugin should be able to be run and the additional images deleted. Again, assuming that I understood the content of the description correctly.