Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Select Product Image Directory & Instant Update For Products


60 replies to this topic

#1 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 25 October 2009, 14:59

Select Product Image Directory & Instant Update For Products
This simple contribution does three things.

  • A drop down is added to the product edit page of sub-folders of the images folder to allow you to select where the product image is to be stored.
  • A field is added to allow you to create a new sub-folder of images to store your images in.
  • A function is added in the product edit page to give a instant update option.Some folders within the images directory can be excluded from the drop down list through an exclude list.
Only one file to edit (categories.php) and only five edits to that!!

Tested on PHP 4 & 5, SQL 4 & 5, osC 2.2 ms2, rc1 & rc2a and is register_globals off compatible.

Contribution is found at http://addons.oscommerce.com/info/7088

Edited by spooks, 25 October 2009, 15:05.

Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#2 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 27 October 2009, 01:13

I`ve spotted that Gustavo has updated this already by making it multilingual [img]http://forums.oscommerce.com/public/style_emoticons/default/thumbsup.gif[/img] , welll done Gustavo, thats an area I`m always lax on. [img]http://forums.oscommerce.com/public/style_emoticons/default/blush.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#3 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 29 October 2009, 16:39

Uploaded new version 1.15

Corrected errors in the language files.
Added directory sort


Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#4 PennyP

  • Community Member
  • 14 posts
  • Real Name:Penny
  • Gender:Female
  • Location:Georgia, USA

Posted 03 November 2009, 19:59

Hi,

I'm hoping Spooks will see this and lend me a hand. I got to the last update of his "Select Product Image Directory & Instant Update For Products" and found that I'm missing the following line of code in Admin/includes/languages/english/categories.php:

define('TEXT_PRODUCTS_MODEL', 'Model:');

I do have a define line that reads: define('TEXT_PRODUCTS_MODEL', 'Products Model:');

I tried inserting the code as instructed below the line as is and got error on that line from osC Admin,
then I tried changing define by deleting the 2nd "Products" so it reads as instructed...got same error in line #.

Can someone (helllooooo SAM) help me??!!?? I would really like for this add-on to work.

Ciao :blink:
Live simply, love generously, care deeply, and speak kindly...

#5 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 03 November 2009, 21:03

View PostPennyP, on 03 November 2009, 19:59, said:


If u download my latest upload (v1.15) you will see i`ve changed the code insertion points to a more logical point (your existing code don`t matter) and fixed the errors in the previous that were causing your problem. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#6 PennyP

  • Community Member
  • 14 posts
  • Real Name:Penny
  • Gender:Female
  • Location:Georgia, USA

Posted 03 November 2009, 21:09

View Postspooks, on 03 November 2009, 21:03, said:

If u download my latest upload (v1.15) you will see i`ve changed the code insertion points to a more logical point (your existing code don`t matter) and fixed the errors in the previous that were causing your problem. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]

Live simply, love generously, care deeply, and speak kindly...

#7 PennyP

  • Community Member
  • 14 posts
  • Real Name:Penny
  • Gender:Female
  • Location:Georgia, USA

Posted 03 November 2009, 21:10

Thank you Sam. I had a feeling but didn't want to ASSume! I'll give it a try... :P
Live simply, love generously, care deeply, and speak kindly...

#8 eva4art

  • Community Member
  • 40 posts
  • Real Name:Eva La Marre
  • Gender:Female
  • Location:California

Posted 26 November 2009, 06:18

Hi Sam,

Thank you for this very useful contribution.
I installed the updated version and it works great. I have multiple subfolders in the image folder. Is it possible to make this work with them? I have folders like this: images/english/holidays/christmas/image.jpg

Thank you for your help.

Eva

#9 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 26 November 2009, 11:33

View Posteva4art, on 26 November 2009, 06:18, said:

Hi Sam,

Thank you for this very useful contribution.
I installed the updated version and it works great. I have multiple subfolders in the image folder. Is it possible to make this work with them? I have folders like this: images/english/holidays/christmas/image.jpg

Thank you for your help.

Eva


I may do an update sometime to allow recursive operation. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#10 bel

  • Community Member
  • 3 posts
  • Real Name:Birgit
  • Gender:Female

Posted 10 December 2009, 10:22

View Postspooks, on 03 November 2009, 21:03, said:

If u download my latest upload (v1.15) you will see i`ve changed the code insertion points to a more logical point (your existing code don`t matter) and fixed the errors in the previous that were causing your problem. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]


#11 bel

  • Community Member
  • 3 posts
  • Real Name:Birgit
  • Gender:Female

Posted 10 December 2009, 11:14

View Postspooks, on 03 November 2009, 21:03, said:

If u download my latest upload (v1.15) you will see i`ve changed the code insertion points to a more logical point (your existing code don`t matter) and fixed the errors in the previous that were causing your problem. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]
Hi
I've tried your add-on which is just what I need i order to get a structure to my images folder. However, I have had many attempts, but it does not work yet. I have copy/pasted all the corrections in the admin/categories.php and the includes/languages/english/categories.php as well as my local language categories.php. Thus no typing errors. When executing, the images folder cannot be found. About line 600 it does not enter the "if ($handle = opendir($root_image_dir)) { ..." but executes the else part. The permissions on the images-folder and sub folders are 777. Among other things I have tried the following code in a separate php-file, and it works, listing the names of folders and files in var/www/catalog/images/.
<?php
$dir = "/var/www/catalog/images/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>
Thank you for any help. I'm experienced in programming, but new to php and I haven't fully grasped the structure of the osCommerse yet.

#12 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 10 December 2009, 11:24

View Postbel, on 10 December 2009, 11:14, said:



If your having trouble installing the mod, if you download Simple Multi Image Add-on (Un-Limited) with Fancy Popups http://addons.oscommerce.com/info/7008
in that package you will find a categories.php file thats the rc2a version with this added (+ the other) use a file compare tool with that.

I can assure you that this will work fine once correctly installed.[img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#13 bel

  • Community Member
  • 3 posts
  • Real Name:Birgit
  • Gender:Female

Posted 10 December 2009, 16:01

View Postspooks, on 10 December 2009, 11:24, said:

If your having trouble installing the mod, if you download Simple Multi Image Add-on (Un-Limited) with Fancy Popups http://addons.oscommerce.com/info/7008
in that package you will find a categories.php file thats the rc2a version with this added (+ the other) use a file compare tool with that.

I can assure you that this will work fine once correctly installed.[img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]
Hi Sam

Thank you very much. I have made it work now. This is a really super add-on.

#14 Juto

  • Community Member
  • 252 posts
  • Real Name:Sara
  • Gender:Female

Posted 24 December 2009, 19:36

Dear Sam, thank you so much for a very useful contribution.
I have installed it today (what a Christmas eve!).

A short question only:

I would like to have a structure like this, as an example:

public_html/suppliers/HP/products

The folder HP have one image: the logo.png
the folder have the product images, like so: article_number.jpg

Later on I would like to have the product descriptions there as well, like so: language_article_number.html
Where language would be (in my case): english, german, spanish and swedish

Using the html file format would make it so easy to have a very nice product description,
in the most advance case, incorporating a css file for each product, like so: article_number.css
or have a general css files like so: main_category.css where main_category could be for example
hardware or software or DVD... (Refering to a fresh install).

Merry Christmas!

Sara

#15 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 24 December 2009, 19:58

View PostJuto, on 24 December 2009, 19:36, said:



You cannot mix static html pages within your osC site, http://forums.oscommerce.com/index.php?showtopic=330479&hl

You can make your product description full html, then you can have any layout & imagess within the description you want.

Just add a wysiwyg editor like FCKeditor for Product Descriptions etc http://addons.oscommerce.com/info/2900 its an easy install.


Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#16 06voip

  • Community Member
  • 11 posts
  • Real Name:06voip

Posted 24 December 2009, 20:34

Hi Sam,
is possible to work with More Pics 6 ?

Thanks

06voip

#17 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 24 December 2009, 22:42

View Post06voip, on 24 December 2009, 20:34, said:

Hi Sam,
is possible to work with More Pics 6 ?

Thanks

06voip

I sorry, I don't like that one and I made Simple Multi Image Add-on (Un-Limited) with Fancy Popups http://addons.oscommerce.com/info/7008 which includes this. [img]http://forums.oscommerce.com/public/style_emoticons/default/smile.gif[/img]

So u need to ask elsewhere if you want that to work. [img]http://forums.oscommerce.com/public/style_emoticons/default/wink.gif[/img]
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#18 06voip

  • Community Member
  • 11 posts
  • Real Name:06voip

Posted 25 December 2009, 05:44

Hi Sam,
Thanks for your response and I apologize for my English :blush:

I feel it

Merry Christmas! ;)

06voip

#19 Dan Cole

  • Community Member
  • 166 posts
  • Real Name:Dan Cole
  • Gender:Male
  • Location:Ontario, Canada

Posted 14 February 2010, 23:23

I'm having trouble getting this routine to recognize a directory to save images to other then the default image directory.

I want to put my product images under a "skus" directory and then in various sub-directories instead of under the standard "images" directory. I can see where I should be able to specify the new directory by setting the variable $images_dir but for some reason the routine that saves the images seems to ignore the new directory when it saves the image...when I echo the variables $images_dir and $root_images_dir to the screen they show the directory structure I want to use but the image is still being saved to the default image directory.

Anyone know if there is something else that I need to change? I can't seem to find the routine that actually saves the image so I can see what is happening. Any idea?

Dan

#20 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 14 February 2010, 23:57

View PostDan Cole, on 14 February 2010, 23:23, said:



If things don't work as advertised u can be 99% sure its smthg u missed or did wrong, triple check it all again.

The update section is:

 

 // image directory 
  $images_dir = DIR_WS_IMAGES; // default catalog images folder;
  $exclude_folders = array("banners","default","icons","mail","infobox","js"); // folders to exclude from adding new images
  $root_images_dir = DIR_FS_CATALOG .  $images_dir;
  $new_dir = preg_replace('/[^a-zA-Z0-9_.-]/i', '_',$_POST['new_directory']); 
  $dir = (tep_not_null($new_dir) ? $new_dir : $_POST['directory']);
 
// instant update 
   if ($action == 'new_product_preview') {
// copy image only if modified
    	if ($dir && !is_dir(DIR_FS_CATALOG_IMAGES . $dir)) { 
   	if (mkdir(DIR_FS_CATALOG_IMAGES . $dir)) $messageStack->add('Folder ' . $dir . ' created in '. $images_dir . '.', 'success');
    }
    	$products_image = new upload('products_image');
    	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . ($dir ? $dir .'/' : ''));
    	if ($products_image->parse() && $products_image->save()) {
      	$products_image_name =  ($dir ? $dir . '\/' : '') . $products_image->filename;
    	} else {
      	$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
    	}

 if ($_POST['instant_update'] == 'on') { 
   $_POST['products_image'] = stripslashes($products_image_name);
    	$action = (isset($_GET['pID']) ? 'update_product' : 'insert_product');  
                    }
                     }
// EOF instant update &  image directory  


but if you missed later edits then that could also cause failure!!



Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.