PDA

View Full Version : Avoid Product image upload replacing



michael_s
06-30-2011, 04:10 AM
One of the client complained me, once he uploaded a product image with a same file name (but different product) old product image also changed to the newly uploaded image. As this is a practical issue I had to fix this with somehow.

So changed few codes to rename the product image with its product id in it.

eg: if you upload an image file "wp0010.jpg", it will be renamed in server to "wp0010_122.jpg", where 122 is the product id.

Changes:

1. admin/includes/classes/upload.php
1.a.
find: function parse() {
and replace it with: function parse($pid) {

1.b.
replace the line:
$this->set_filename($file['name']);
with:
list($fname, $ext) = explode(".", $file['name']);
$this->pid;
$this->set_filename($fname.'_'.$this->pid.'.'.$ext);

2. admin/categories.php
find the line with:
if ($products_image->parse() && $products_image->save()) {

and replace with:
if ($products_image->parse($products_id) && $products_image->save()) {

That's all!

More... (http://addons.oscommerce.com/info/8071)