Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default how to prevent image from being deleted when a product is deleted?

    is there a way to prevent this? im on zen cart 1.5.x

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: how to prevent image from being deleted when a product is deleted?

    To my knowledge, the image is not deleted when the associated product is deleted
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default Re: how to prevent image from being deleted when a product is deleted?

    it was deleted in mine, i just tested it using the admin.

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

    Default Re: how to prevent image from being deleted when a product is deleted?

    The image is deleted when a Product is deleted if that image is not used by another Product ...

    About the only way to change this, without customizing the code, would be to change the image on the Product before deleting it with an image you do not care about ... then when the image is deleted it does not matter ...

    If you really need the image after deleting the Product, you could always just FTP that image back to the server ...
    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!

  5. #5
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default Re: how to prevent image from being deleted when a product is deleted?

    which code should i customize and which part?

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

    Default Re: how to prevent image from being deleted when a product is deleted?

    To prevent the deletion of a Product from deleting the image(s) for it you would have to edit the file:
    /your_secret_admin/includes/functions/general.php

    and add the code in RED around line 1362:
    Code:
      
    function zen_remove_product($product_id, $ptc = 'true') {
        global $db;
        $product_image = $db->Execute("select products_image
                                       from " . TABLE_PRODUCTS . "
                                       where products_id = '" . (int)$product_id . "'");
    
        $duplicate_image = $db->Execute("select count(*) as total
                                         from " . TABLE_PRODUCTS . "
                                         where products_image = '" . zen_db_input($product_image->fields['products_image']) . "'");
    
    // ===============
    // =============== CODE CHANGED: TURN OFF DELETION OF IMAGES WHEN PRODUCTS ARE DELETED
    // ===============
        if (false && $duplicate_image->fields['total'] < 2 and $product_image->fields['products_image'] != '' && PRODUCTS_IMAGE_NO_IMAGE != substr($product_image->fields['products_image'], strrpos($product_image->fields['products_image'], '/')+1)) {

    NOTE: Making this change means the images will NEVER be deleted from the server unless you manually delete them
    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!

  7. #7
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default Re: how to prevent image from being deleted when a product is deleted?

    Quote Originally Posted by Ajeh View Post
    To prevent the deletion of a Product from deleting the image(s) for it you would have to edit the file:
    /your_secret_admin/includes/functions/general.php

    and add the code in RED around line 1362:
    Code:
      
    function zen_remove_product($product_id, $ptc = 'true') {
        global $db;
        $product_image = $db->Execute("select products_image
                                       from " . TABLE_PRODUCTS . "
                                       where products_id = '" . (int)$product_id . "'");
    
        $duplicate_image = $db->Execute("select count(*) as total
                                         from " . TABLE_PRODUCTS . "
                                         where products_image = '" . zen_db_input($product_image->fields['products_image']) . "'");
    
    // ===============
    // =============== CODE CHANGED: TURN OFF DELETION OF IMAGES WHEN PRODUCTS ARE DELETED
    // ===============
        if (false && $duplicate_image->fields['total'] < 2 and $product_image->fields['products_image'] != '' && PRODUCTS_IMAGE_NO_IMAGE != substr($product_image->fields['products_image'], strrpos($product_image->fields['products_image'], '/')+1)) {

    NOTE: Making this change means the images will NEVER be deleted from the server unless you manually delete them
    thanks, it worked like a charm

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

    Default Re: how to prevent image from being deleted when a product is deleted?

    Thanks for the update that this worked for you to prevent Product Images from being deleted from the server when you deleted Products ...

    Be sure you do periodic maintenance on the server for images that are no longer needed or they will build up over time ...
    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!

 

 

Similar Threads

  1. v151 Images deleted when entire category deleted
    By jghogue in forum Customization from the Admin
    Replies: 1
    Last Post: 3 Oct 2013, 04:20 PM
  2. v151 Why are "paypal" table records not deleted when an order is deleted?
    By lat9 in forum PayPal Express Checkout support
    Replies: 2
    Last Post: 14 Apr 2013, 08:44 PM
  3. When I add a new product another product in the same category gets deleted!
    By advhealth in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 17 Jan 2013, 01:03 AM
  4. Product contents deleted when i try to edit it
    By marknbrandon in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 23 Feb 2012, 02:21 PM
  5. How to prevent Product Attributes from being discounted?
    By rikahsdesign in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 17 Oct 2008, 07:43 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