osCommerce -> Admin -> Manufacturers -> BUG -> Fixed

I’ve been working on the manufacturers page of the osCommerce Admin section to get some “proof of concept” code working.

Whilst working on it, I couldn’t understand why the manufacturers image kept disappearing. On closer inspection I found some buggy code which I have now fixed.

Github Commit.

Basically, the image was uploading nothing, and overwriting the existing image if a Manufacturer was edited (eg, changing the name, adding a URL etc).

If you don’t understand Github, here’s the fix;

Find this:

[php]if ($manufacturers_image = new upload(‘manufacturers_image’, DIR_FS_CATALOG_IMAGES)) {
tep_db_query(“update ” . TABLE_MANUFACTURERS . ” set manufacturers_image = ‘” . $manufacturers_image->filename . “‘ where manufacturers_id = ‘” . (int)$manufacturers_id . “‘”);
}[/php]

Change to this:

[php]$manufacturers_image = new upload(‘manufacturers_image’);
$manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($manufacturers_image->parse() && $manufacturers_image->save()) {
tep_db_query(“update ” . TABLE_MANUFACTURERS . ” set manufacturers_image = ‘” . $manufacturers_image->filename . “‘ where manufacturers_id = ‘” . (int)$manufacturers_id . “‘”);
}[/php]

This bug definitely exists in all versions of osCommerce upto and including the latest Github release of rc3. I have not tested manufacturers in osC v3.

One Reply to “osCommerce -> Admin -> Manufacturers -> BUG -> Fixed”

Leave a Reply

Your email address will not be published. Required fields are marked *