osCommerceCoders.com

Affordable end to end oscommerce solutions with
Search Engine Optimization

Email : osCommerceCoders@gmail.com
Call : +1 818-574-3596 (USA) / +44 (020) 8123-6463 (UK)

Problems with manufacturer image management

Posted by admin On June - 15 - 2010

osCommerce has a problem when editing an existing manufacturer’s information. If a new manufacturer image is not loaded at the same time then the image that was there previously disappears. osCommerce also fails to delete a manufacturer’s image from the server when the manufacturer is deleted.

The solution to the problems is simple. Open the file admin/manufacturers.php

Find the following lines around line 41:

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 . “‘”);
}

Replace them with the following lines:

$manufacturers_image = new upload(‘manufacturers_image’);
$webimgtypes = array (‘bmp’, ‘jpg’, ‘jpeg’, ‘gif’, ‘png’);
$manufacturers_image->set_extensions($webimgtypes);
$manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES);
if ($manufacturers_image->parse() && $manufacturers_image->save()) {
tep_db_query(“update ” . TABLE_MANUFACTURERS . ” set manufacturers_image = ‘” . tep_db_input($manufacturers_image->filename) . “‘ where manufacturers_id = ‘” . (int)$manufacturers_id . “‘”);
}

Find the following around line 77 (line 81 if you’ve made the previous change already)

$image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer[‘manufacturers_image’];

and replace it with the following:

$image_location = DIR_FS_CATALOG_IMAGES . $manufacturer[‘manufacturers_image’];

Save your work and you are done.
Cheers

Sponsors