View Full Version : Avoid Product image upload replacing

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.


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

replace the line:
list($fname, $ext) = explode(".", $file['name']);

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)