Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Solution to Manufacturers, category images lost when editing info in Admin Maybe


travtele615

Recommended Posts

Posted

I'll preface this with I know very little about php.

 

For 2 days I've been reading (well mostly searching) for a solution to this problem.

 

You enter info and images into admin area for manufacturers and categories. If you then go back and edit info and don't upload the image again , the original image location is overwritten with blank data in the DB

 

looking through the admin categories.php with emphasis on the last line after }else{ I find:

// copy image only if modified
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}

further down is code for a hidden field in the case 'edit' section of categories.php

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>

 

going back to admin manufacturers.php the original code for the image update is:

 

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 . "'");
	}

 

Using this code I found as a possible (and was reported as a bug fix) solution to this problem I get no change. Image location in DB is still being wiped blank

$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 . "'");
   }

 

I can't find any code with a hidden field to the effect of 'previous_manufacturers_image' anywhere in admin manufacturers.php. Could this be the reason product images remain in the database while category and manufacturer's images are being over written with nothing when updating the info for those items.

 

 

Thanks for any help

Travis

Posted

Trav ... do you have the categories_description_MS2_1.9_1 mod installed .. or any other mod that modifies image handling in categories.php.

 

If so I had the same problem with categories_description_MS2_1.9_1

 

I had to change some code that was further down that was added by categories_description_MS2_1.9_1.zip

 

then my images weren't being wiped out.

Posted
Trav ... do you have the categories_description_MS2_1.9_1 mod installed .. or any other mod that modifies image handling in categories.php.

 

If so I had the same problem with categories_description_MS2_1.9_1

 

I had to change some code that was further down that was added by categories_description_MS2_1.9_1.zip

 

then my images weren't being wiped out.

 

Can you please post what you had to change for our reference as I'm also having the same problem

Posted
Trav ... do you have the categories_description_MS2_1.9_1 mod installed .. or any other mod that modifies image handling in categories.php.

 

If so I had the same problem with categories_description_MS2_1.9_1

I have this problem with both categories and manufacturers. I've been working on the manufacturers side just because it seems a little more isolated where the categories are tied into products etc.

 

I've got the "header tags controller" contribrution and one called "All manufacturers". but not the one you mention. nothing for categories.

 

I grabbed the latest download of OSC yesterday and uploaded the manufacturers.php from the admin section there and experienced the same problems which is not to say that I don't have an issue in another file but I don't think that's the case.

 

$manufacturers_image = new upload('manufacturers_image');
	$manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($manufacturers_image->parse() && $manufacturers_image->save()) {
	  $manufacturers_image_name = $manufacturers_image->filename;
	} else {
	  $manufacturers_image_name = (isset($HTTP_POST_VARS['manufacturers_previous_image']) ? $HTTP_POST_VARS['manufacturers_previous_image'] : '');
	}

....more code here
<!-- this generates the image form field when "editing" including a hidden field-->

$contents[] = array('text' => '<br>' . TEXT_MANUFACTURERS_IMAGE . '<br>' . tep_draw_file_field('manufacturers_image') . '<br>' . $mInfo->manufacturers_image . tep_draw_hidden_field('manufacturers_previous_image', $mInfo->manufacturers_image));

 

 

Right now I've modified the above code taken from categories.php product section and using it I can see the hidden field being generated for the images with the correct value for a given manufacturer IE: "artists/adams-ansel.jpg". when viewing the html source the script spits out.

I don't understand completely what the 1st chunk of code (above ...more code here) does. But am pretty sure that all I'm lacking is if an image is entered in the Image box upload it or if the image field is blank check the hidden field and upload the value of it into the DB.

And I can't seem to figure out where the DB update takes place with this code above stolen from the categories section.

 

Thanks for any and all help

Travis

Posted

Also,

 

I might be completely off basis with what I think is going on.

 

when you edit a product you get a preview step before saving to DB

 

In manufacturers and cats editing sections you don't have that step, but where is the code that is holding the image location if we've already uploaded previously?

Before I started trying to solve this problem I was getting the image location written out under the upload file box but didn't have it assigned anything. It was simply just a line of text. With the hidden field I've added from the categories.php code there's at least some way to reference that later. Am I thinking correctly here?

 

Travis

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...