Guest Posted May 7, 2007 Share Posted May 7, 2007 Hi, I'm just wondering how I can change the default upload directory for manufacturer images?? At the moment they are all downloaded to /images/, but I want them to be downloaded to /images/merchants/. Any help? Thanks, Lee Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 anyone? Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Please explain the progress you have made so far. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 um.. none. I just want to change it so when I select an image to go with a manufacturer.. or category, they're uploaded to different directories. I could probably figure it out if I knew which files to look in. I'm still getting my head around how oscommerce is coded. Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Well the first thing would be to check the admin/manufacturers.php file. It's not really a trivial task as you need to modify the a number of sections of code to achieve what you want. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 There is a quick fix so to speak. You could move your images into a sub directory and update the column that contains the image names in the database by adding your sub directory as a prefix. If you put the images in /manufacturers/ you can use an SQL query to UPDATE the correct column. You could alternatively download you manufacturers table and do a text replace (or download in csv format and use a spreadsheet). My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 thanks so much! :) It was actually quite simple for the manufacturers image.. It should be just as easy for the products. I found thiese two lines (roughly lines 41 and 42): 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 . "'"); on the first line I put in the directory to save to as merchants (the .'/merchants/' at the end of the line): if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES.'/merchants/')) { then the second line set what to save the value as in the database, so I changed it to save the /merchants/ as well as the filename: tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = 'merchants/" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); where it says "set manufacturers_image = '" I added the merchants/ directory. This seems to work for every page so far, no glitches. Thanks Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 thanks so much! :)It was actually quite simple for the manufacturers image.. It should be just as easy for the products. I found thiese two lines (roughly lines 41 and 42): 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 . "'"); on the first line I put in the directory to save to as merchants (the .'/merchants/' at the end of the line): if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES.'/merchants/')) { then the second line set what to save the value as in the database, so I changed it to save the /merchants/ as well as the filename: tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = 'merchants/" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); where it says "set manufacturers_image = '" I added the merchants/ directory. This seems to work for every page so far, no glitches. Thanks Well, looks like you found it. I'll try it out and let you know if I see any problems with it. I can't imaging there would be any though. Report back if you've cracked the products too. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 well I've just tried on the categories.. same changes no problem. I haven't had a proper search for products so I haven't checked it. I'm going to put it up as a contribution though as some people might find it useful Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Good idea. Make sure you do the products first. I'm just adding the categories and products myself. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 I've just added it to the contribs. If you figure out products add it! I wasn't sure which file to look in :blush: I had a quick look in products_attributes.php, but couldn't find it. you can find it here: http://www.oscommerce.com/community/contributions,5125 Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 It's in categories.php I've got On-The-Fly Auto Thumbnailer installed and it's not thumbnailing the product images in admin. I'm half working on it while watching the snooker. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 okay, I've got the products working. Might try on seperating them into categories such as /images/products/shirts /images/products/hats /images/products/pens etc Although I don't have the On-The-Fly Auto Thumbnailer contrib so don't know how it would work with that.. here's my edited code on categories.php for product images: // copy image only if modified $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES.'/products/'); if ($products_image->parse() && $products_image->save()) { $products_image_name = "products/".$products_image->filename; } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } break; } } probably better off setting the folder name as a variable or something though. Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Nice one, I'll give that a try. Have you tested it much? Does it work when adding an image in admin? I'd add all the paths to a admin/includes/configure.php and leave off the leading slash. It's not needed if your DIR_FS_CATALOG_IMAGES is correct: define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/'); define('DIR_FS_MANUFACTURERS_IMAGES', 'manufacturers/'); define('DIR_FS_CATEGORIES_IMAGES', 'categories/'); define('DIR_FS_PRODUCTS_IMAGES', 'products/'); My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 yeah good idea. It seems to work fine! Haven't found any problems. I'm just working around setting seperate category folders as well now. Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 okay, I've got the products working. Might try on seperating them into categories such as/images/products/shirts /images/products/hats /images/products/pens etc Although I don't have the On-The-Fly Auto Thumbnailer contrib so don't know how it would work with that.. here's my edited code on categories.php for product images: // copy image only if modified $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES.'/products/'); if ($products_image->parse() && $products_image->save()) { $products_image_name = "products/".$products_image->filename; } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } break; } } probably better off setting the folder name as a variable or something though. That actually works well. As far as I can see it's working perfectly. I've been having problems with the admin side of the thumbnailer anyway. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Can you tell me what happens when you edit a category but don't upload any picture? It seems to not be passing the original image for me meaning that I have to upload a picture for the image to display. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 I found out that it's a bug. This is what I found in the bug reports section: 9 Mar 2006 18:52:04 antonio (AT) marbuendy (DOT) com I fixed this probleme by changing line 97 from if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) { TO $categories_image = new upload('categories_image'); $categories_image->set_destination(DIR_FS_CATALOG_IMAGES); if ($categories_image->parse() && $categories_image->save()) { I can confirm that it works for me like so: $categories_image = new upload('categories_image'); $categories_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_CATEGORIES_IMAGES); if ($categories_image->parse() && $categories_image->save()) { My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 hmmm.. yeah. I just noticed that. not sure why.. Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Well, that's fixed now by making the changes from the bug report. There is one more thing that I'm having problems with. When I add or edit a product it hangs when clicking preview. If I click again it works just fine. I wonder why it is initially hanging. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 7, 2007 Share Posted May 7, 2007 ah, it's too early in the morning here and I've changed something on the categories section and now it's not working... here's my code: $categories_image = new upload('categories_image'); $categories_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_CATEGORIES_IMAGES); if ($categories_image->parse() && $categories_image->save()) { tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . DIR_FS_CATEGORIES_IMAGES . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'"); I think it's the last line.. when I upload the image I get no error message, but it saves the image in the database as categories/ and misses out the filename...I'm too tired. Link to comment Share on other sites More sharing options...
psynaptic Posted May 7, 2007 Share Posted May 7, 2007 Did you make the categories dir? Did you add the define for DIR_FS_CATEGORIES_IMAGES? I guess you must have but you did say it was getting late. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2007 Share Posted May 8, 2007 I think my ftp program failed to upload the configure.php file when I updated, so it was missing or incomplete... I've lost the configure.php with my setting in... <_< could you tell me what I should change these settings to? define('HTTP_SERVER', ''); // eg, http://localhost or - https://localhost should not be NULL for productive servers define('HTTP_CATALOG_SERVER', ''); define('HTTPS_CATALOG_SERVER', ''); define('ENABLE_SSL_CATALOG', 'false'); // secure webserver for catalog module define('DIR_FS_DOCUMENT_ROOT', $DOCUMENT_ROOT); // where your pages are located on the server. if $DOCUMENT_ROOT doesnt suit you, replace with your local path. (eg, /usr/local/apache/htdocs) is the server the hostname of my mysql databse? What's the catalog server? would that be my domain name? I haven't enabled ssl so I don't need to change that. Document rrot.. does this need changing? My root folder on my server is htdocs/ define('USE_PCONNECT', 'false'); define('STORE_SESSIONS', ''); What's PCONNECT? and storing sessions... I think I want that on. It's too late to think for me. Thanks Link to comment Share on other sites More sharing options...
psynaptic Posted May 8, 2007 Share Posted May 8, 2007 Too many questions at such a late hour. Do me a favour and add another reply to this thread tomorrow and I'll fill you in on all your questions. I've got to get some sleep. My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
Guest Posted May 8, 2007 Share Posted May 8, 2007 ah no need to worry. I've sorted my config. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.