News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

When deleting a product it deletes associated media files

Started by Flyboy522, November 13, 2007, 19:11:30 PM

Previous topic - Next topic

Flyboy522

Description:
I have created 5 child products from 1 main product.  I have a downloadable files directory (unfortunately on my webroot).  I assocaited a MP3 file with each child product.  Due to an issue with cloning (screws up list order of child products), I had to delete some products (and the child products).  I noticed that when I went to add them back, the associated MP3 files were actually deleted from my server.  This happened when I deleted the product.

VirtueMart Version: 1.1.0 beta

Joomla Version: 1.0.13 Stable [ Sunglow *eCommerce Edition* ] 21 July 2007

Steps to replicate:  Add new product.  Add attribute.  Add child product.  Add downloadable file to child product via the "Media" link.  (downloadable file should be from pick list via the associated file directory set up in Configuration menu).  Delete parent product (and child). Navigate to the file directory.  Notice that associated file was deleted along with the product. 

No Live URL Available

This occurs in the Extended Layouts menus

Proposed fix(es):
I have no code fix suggestions.  However, I would suggest that the integrity of the files in the downloadable files directory be maintained.

Bugtracker task #: Pending
Enter the bugtracker task #/url when submitted.

System info: Mac OSX Leopard, Safari 2, Godaddy Servers with shared linux hosting, PHP 4, mysql version 4.1

jenkinhill

I don't see this as a bug. If a product is deleted then I would expect any media files for that product to be deleted as well. Otherwise businesses that regularly change products as some become out odf date or unobtainable would end up with a server full of old and no longer needed files. I believe that when a product is deleted its ID is also removed, so there would be complications in re-connecting with those media files that share the same product ID.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Flyboy522

The problem here is that Virtuemart as a component of Joomla, is DELETING files that are outside of it's "realm."  At a minimum, you should indicate either by a pop up warning, or in the user documentation that if you delete a product (say as part of an update, or maintenance), all associated media files (including revenue generating, downloadable software or MP3 files) will also be deleted from their folder, even though they may not even be within the web root.

In this particular case, it was not a picture of a sweater or a hammer, but a 20 meg MP3 file that then had to be re-FTPed to the directory.

The maintenance of downloadable files should be maintained at the server folder level, not through the addition or deletion of "products" that link those files to the consumer.

Most pay ware shopping cart software consider these linked files as "digital objects" and these digital objects are linked to products.  Say I had a bunch of products that had this MP# as part of the product package, but I had to delete one of the products.  With this current environment, ALL other products that had this file as part of them would now be missing the file, because it was deleted off of the server.

That can be very very bad, and very very time consuming to police, especially with a large inventory.

I implore you to reconsider.  Thanks.



Pjries

Reviving a very old thread, but Flyboy522 makes some important points here and is much more eloquent than I would be.

I ran into this today while setting up a client's store. I mistakenly linked a file twice. When I went to remove the second link, it deleted the file from the server.

It may be that Virtuemart developers are already addressing this - I haven't checked the development/bug reports.  But changing this so that removing a file merely breaks a link between the file and the product would be a great feature.

Thanks for all you do on this project. It can be hard sometimes to find answers to questions, but I recommend and use the cart for all of my Joomla clients and I'm very grateful for all the time and effort you have put in to this.

jlwagner

Quote from: jenkinhill on November 13, 2007, 23:51:55 PM
I don't see this as a bug. If a product is deleted then I would expect any media files for that product to be deleted as well. Otherwise businesses that regularly change products as some become out odf date or unobtainable would end up with a server full of old and no longer needed files. I believe that when a product is deleted its ID is also removed, so there would be complications in re-connecting with those media files that share the same product ID.

This is a bug.  Old photos of old products should never be automatically deleted from the server.

If you don't think it's a bug, then at least please add a parameter that would let the VM user specify whether or not deleting a product would delete the product's images.

There are Joomla plug-ins that insert product images into content.  Old press releases and archived articles include product images and still generate search engine traffic; and now they will have broken images and links. 

Also, many related products might use the same image.  (E.g., same tile or rug in different size.  Or generic "hammer" sketch.)  Deleting one product shouldn't affect others. 

Finally, it's been causing me hassles when using CSVI to bulk upload products:  If anything goes wrong with part of the bulk upload, I may delete some of the uploaded products and run the import again.  Now the import gives weird results because some of the the full-size images are missing. 

When debugging a bulk upload, it's a pain to have to re-FTP a thousand images in between re-running each trial of the bulk upload.

Please add a parameter that would let the VM user specify whether or not deleting a product would delete the product's images.

Thank you.

--- J.
Accordionist.org   |  ElectronicMother.com   |  Nonantum.net
Siddur.org   |   ChessNotation.com   |   ConservativeJudaism.us

icemangs

To prevent the pictures deleted when a product deleted will make following:

In the file /home/www/administrator/components/com_virtuemart/classes/ps_product.php search after /* Prepare product_thumb_image for deleting */ and /* Prepare product_full_image for deleting */.
Among them is the function to delete the images. Either delete or commenting out which is better) thereby is the product completely erased but without the pictures

icemangs

schofieldml

/* Prepare product_thumb_image for Deleting */
if( !stristr( $db->f("product_thumb_image"), "http") ) {
$_REQUEST["product_thumb_image_curr"] = $db->f("product_thumb_image");
$d["product_thumb_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"product_thumb_image","product")) {
$vmLogger->err( $VM_LANG->_('VM_PRODUCT_IMGDEL_FAILED',false) );
return false;
}
}
/* Prepare product_full_image for Deleting */
if( !stristr( $db->f("product_full_image"), "http") ) {
$_REQUEST["product_full_image_curr"] = $db->f("product_full_image");
$d["product_full_image_action"] = "delete";
if (!vmImageTools::validate_image($d,"product_full_image","product")) {
return false;
}
}
return true;

}