Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    201
    Plugin Contributions
    6

    Default Modify function to NOT delete image on product delete

    This may be a strange question but having been burned too many times when deleting product I would like to ask a question regarding the function "zen_remove_product". If I were to comment out these statements (located in admin/includes/functions/general.php)

    if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image'])) {
    @unlink(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image']);
    }
    if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_medium)) {
    @unlink(DIR_FS_CATALOG_IMAGES . $filename_medium);
    }
    if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_large)) {
    @unlink(DIR_FS_CATALOG_IMAGES . $filename_large);

    would the zen_remove_product function still remove the product but leave the image on the server?

    Here is my reason for the request. I have many product that use the same images and deleting
    one product could cause multiple product to no longer have an associated image. Also, it can be very time consuming (and in my opinion unnecessarily so) to have to reload images every time I delete a product.

    In lieu of modifying the function I suppose I could first upload all the product I want to delete with a dummy image name and then upload the product(s) for delete (using EasyPopulate). However, this does not cover circumstances when I might delete a product using the Zen Cart admin.

    I guess I am just trying to save myself a lot of extra time with having to reload deleted images.

    The BEST solution would be to have a Configuration option that would give the user the choice to delete or not delete an image on product delete. If I knew how to add an option to the Zen Cart admin I would do that and then submit as a mod.

    I appreciate any helpful responses.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Modify function to NOT delete image on product delete

    What version of Zen Cart are you using?

    Testing in the current Zen Cart v1.5, if I have the same image as another Product and delete the Product, the image is not removed because the other product is using it ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Jan 2009
    Posts
    201
    Plugin Contributions
    6

    Default Re: Modify function to NOT delete image on product delete

    The code referred to is in Zen Cart 1.3.9h (and earlier versions). It is not only the issue with images being used by multiple product but other cases as well. For instance, lets say that I want to move several hundred product from multiple categories to other categories (the web site owner gets goofy sometimes). What I normally do is use Easypopulate to delete the products and then reload the products with Easypopulate (putting them in the new categories). Well, doing that deletes all of the images, and if there are several hundred products then I have to spend a lot of time reloading the images. To me that is wasted time. If I can just modify the code, as I asked about in the original question, then I could save myself a lot of time. I would rather have the option of deleting images at my discretion.

  4. #4
    Join Date
    Jan 2009
    Posts
    201
    Plugin Contributions
    6

    Default Re: Modify function to NOT delete image on product delete

    This is really strange. I logged on to my localhost server to try out my idea, which I probably should have done in the first place, and before making any changes found that the images were NOT being deleted when I deleted the product. HMMM ? Something strange going on here. I will figure out the solution. Thanks for the responses. No further responses are needed.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Modify function to NOT delete image on product delete

    Let us know what you discover ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Jan 2009
    Posts
    201
    Plugin Contributions
    6

    Default Re: Modify function to NOT delete image on product delete

    Linda,

    Well, I have not yet figured out why it works differently on my localhost server versus the live site but I have
    found a "work around" for the issue of images being deleted when using Easypopulate to delete product. And it does NOT require any code changes. The method is as follows:

    1. Using Easypopulate, update the all the product(s) to be deleted with a "DUMMY" image name.
    2. Using Easypopulate, you can now delete the product(s) without fear of losing the original image.

    It would still be nice to know the answer to my original question as to whether I can comment out those
    lines of code in the zen_remove_product function and still have the function otherwise work normally.
    I would try it out on the localhost server but images are not being deleted there, so I would not learn anything by changing the code there.

    Thanks for your help. If I discover anything new I will let you know.

 

 

Similar Threads

  1. Replies: 6
    Last Post: 22 Dec 2016, 05:49 AM
  2. Disable "DELETE" - Make certain admin users not able to delete orders
    By vetpro in forum Managing Customers and Orders
    Replies: 0
    Last Post: 12 Nov 2011, 02:01 PM
  3. Delete or modify product paths links
    By thesinner in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 9 Sep 2010, 08:52 PM
  4. Q- Image of product will delete when i delete the product ?
    By kimsonvu in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 2 Feb 2009, 05:58 AM
  5. Delete product image and description edits not saving with FF Mac
    By JackA in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 27 Dec 2007, 06:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg