Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Official Topic For 'change Default Image Directories' Contrib


Guest

Recommended Posts

  • Replies 99
  • Created
  • Last Reply

Top Posters In This Topic

Hi

 

I have managed to build a website using oscommerce and all is working perfectly. We are going to create another one soon but as we have over 200,000 images on our server, your MOD looks like just the thing we are after.

 

I am not an expert at php, but been able over a perod time to create a working site with payment facility. Before I embark on the next project, can you tell me if it is possible for us to use your MOD to show images on the new site from our existing server as there are a lot of images!

 

Thank you

 

Steve

Link to comment
Share on other sites

Hi

 

I have managed to build a website using oscommerce and all is working perfectly. We are going to create another one soon but as we have over 200,000 images on our server, your MOD looks like just the thing we are after.

 

I am not an expert at php, but been able over a perod time to create a working site with payment facility. Before I embark on the next project, can you tell me if it is possible for us to use your MOD to show images on the new site from our existing server as there are a lot of images!

 

Thank you

 

Steve

 

If you mean keep the images on your old server and link to them from the new server, then I'm afraid this mod wont help.

To use my mod all of the images are uploaded into their specific categories and sub-categories, so leaving the images in the catalog/images folder would mean that they wouldn't be read properly. The images would all need to be in their correct folder such as:

catalog/images/categories

 

Seeing as though creating an item or category on oscommerce uploads the image at the same time it should work if you're wanting to store the images on the new server.

 

 

My mod won't move files from the catalog/images folder to their own folder, it will create a new image in the correct folder, so you'll still have the originals in the catalog/images directory.

 

I hope I understood your question correctly.

Thanks

Link to comment
Share on other sites

And what if I have got a lot of sub-categories? For example, my tree look like 'images/products/man/footwer/slides/sandals/'.

Will it work for me, or I should make some corrections to the code?

 

Thanks for support. :)

Thanks a lot for all our community members. It's amazing that we are together and we have opportunity to help each oher.

Link to comment
Share on other sites

And what if I have got a lot of sub-categories? For example, my tree look like 'images/products/man/footwer/slides/sandals/'.

Will it work for me, or I should make some corrections to the code?

 

Thanks for support. :)

 

ah.. I meant for it to work for multiple sub-categories like that, but checking over the code I'm not sure that it will. I'll just check and update the code.

I'll leave a message here when it's done. should be sometime this evening.

Link to comment
Share on other sites

okay, I've sorted the code so it now works for multiple sub-categories, such as:

images/products/man/footwer/slides/sandals/

Thanks to nikita for pointing out that you couldn't before as I'd forgotten to sort it out ;)

If you've already installed the code here's the quick fix:

OPEN: catalog/admin/categories.php

find (about line 115):

// copy image only if modified
$cid = explode('_', $cPath);
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $cid[0] . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);

$subcdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $cid[1] . "' && language_id = '1'");
$subc = tep_db_fetch_array($subcdat);

$categoryfile = $cat[categories_name] . "/";
if($subc[categories_name] != ''){
$subcfile = $subc[categories_name] . "/";
}else{
$subcfile = '';
}

	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $subcfile . $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}
	break;
}
 }

replace with:

// copy image only if modified
$cid = explode('_', $cPath);
foreach($cid as $key => $value){
$cdat = tep_db_query("SELECT categories_name FROM categories_description WHERE categories_id = '" . $value . "' && language_id = '1'");
$cat = tep_db_fetch_array($cdat);
$categoryfile .= $cat[categories_name] . "/";
}

	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $categoryfile);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = DIR_FS_PRODUCTS_IMAGES . $categoryfile . $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}
	break;
}
 }

it also looks neater :P

 

I've tested it on my shop and it works fine.

NOTE: all versions of this contrib from v1.3 have this change included

Link to comment
Share on other sites

How about a couple of screen shots of what this looks like in operation. I think this is something that I have been looking for but I can't be certain. Thanks for your contribution and work.

Link to comment
Share on other sites

Yes, but what about Catalog side?

 

We have changed the default image directories for products, categories and manufacturers only in admin side. It's really work. But we havn't changed the catalog side, the images (for example, category images) actually are in DIR_FS_CATEGORIES_IMAGE but in product listing or on the products_info page they try to be shown from DIR_WS_CATALOG_IMAGES. It happens because we haven't changed the way how images get to the screen in catalog, and they do it from DIR_WS_CATALOG_IMAGES, not from DIR_WS_CATEGORIES_IMAGES.

 

I believe that you have anderstood me. :)

Thanks a lot.

Thanks a lot for all our community members. It's amazing that we are together and we have opportunity to help each oher.

Link to comment
Share on other sites

Yes, but what about Catalog side?

 

We have changed the default image directories for products, categories and manufacturers only in admin side. It's really work. But we havn't changed the catalog side, the images (for example, category images) actually are in DIR_FS_CATEGORIES_IMAGE but in product listing or on the products_info page they try to be shown from DIR_WS_CATALOG_IMAGES. It happens because we haven't changed the way how images get to the screen in catalog, and they do it from DIR_WS_CATALOG_IMAGES, not from DIR_WS_CATEGORIES_IMAGES.

 

I believe that you have anderstood me. :)

Thanks a lot.

 

Um.. I'm not quite sure what you mean. My mod will upload the images to the correct directory, then set that directory as the link to the image wherever it is used on the site. Be it in the admin or in the catalog.

Hope that answers your query

 

 

How about a couple of screen shots of what this looks like in operation. I think this is something that I have been looking for but I can't be certain. Thanks for your contribution and work.

I'll sort out some screenshots later this evening and post them on here for you.

Link to comment
Share on other sites

Okay, here's some screenies to try and show my mod, for anyone wanting to see it before trying it.

Please note that the prices are ficticious ;)

 

fileuploaded_admin.jpg

Unsuccessfull upload of a sub-category image.. Custom error message, if directory doesn't exist

 

showdirectory_admin.jpg

you can see here that the image is in a sub directory, not just one folder in, but 2

 

imageproperties.jpg

and here is the image in the catalog, along with the image properties to show the directory

 

filedirectories.jpg

and finally, here's a view of my directory listing. You can see that I've got several categories and sub-categories for products.

the 'categories' folder contains all of the images for the (sub)categories themselves, although not seperated into individual folders. I saw no point in seperating the icons for categories as their would be less of them.

The 'merchants' folder contains all of my manufacturers images. I've named mine merchants, instead of manufacturers.

If you want to change the folder names, simply change them in includes/onfigure.php

 

 

sorry about the large files..

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

what version of my contrib did you install? was it v1.4?

 

Also do you receive any error messages or have any idea what part is wrong?

Posting the code of the parts you've changed would be great!

Link to comment
Share on other sites

Hi i am still quite a n00b to oscommerce and php getting my head around these contrib.

 

Ive download this contrib verson 1.4 3 days ago and i love for it was all working peferect eg getting image /picture in right folders not just every single one in the image folders

 

But I got little problem at the I cannot add any images to any of my new catagoies that i created

 

I completely foxed with this please help me

 

thanks

 

cyborgt100

Link to comment
Share on other sites

Hi i am still quite a n00b to oscommerce and php getting my head around these contrib.

 

Ive download this contrib verson 1.4 3 days ago and i love for it was all working peferect eg getting image /picture in right folders not just every single one in the image folders

 

But I got little problem at the I cannot add any images to any of my new catagoies that i created

 

I completely foxed with this please help me

 

thanks

 

cyborgt100

 

Hi,

Do you recieve any error messages? The contrib should give you one of those pink errors at the top of the screen if it can't find a certain directory.

Are you sure that you've created the directories for the categories you're trying to add images to? (it's case sensative and must include any spaces etc that are in the category name)

 

 

saying that.. maybe I should make a change to the contrib so it checks if the category exists. If not, it creates it.

Link to comment
Share on other sites

Hi,

Do you recieve any error messages? The contrib should give you one of those pink errors at the top of the screen if it can't find a certain directory.

Are you sure that you've created the directories for the categories you're trying to add images to? (it's case sensative and must include any spaces etc that are in the category name)

saying that.. maybe I should make a change to the contrib so it checks if the category exists. If not, it creates it.

 

hi i do get two type of errors

 

Error: Catalog images directory is not writeable: /home51c/sub004/sc34668-YXAE/www/shopping/images/

 

and once tye tried to be upload i get the error

 

IMAGE DOES NOT EXIST

Categoria-Default.gif

 

I have FTP the file in two locations shopping/images/categories and just shopping/images/ and try to upload from local to server location using the OSC admin screen

 

but still no joy

Link to comment
Share on other sites

Great contribution!

Looks like just what we are looking for.

 

I'm getting the same error that is in your screen shot.

 

My error message:

Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: /var/www/html/plugins/vsc/catalog/images/products/

 

the above is from our root directory

 

 

Checked spelling numerous times, everything is identical.

 

Categories structure set up from my admin reads in the top pulldown

Go to: Top

painting

acrylic

 

 

Folder structure is:

catalog/images/products/painting/acrylic

 

 

admin/includes/config.php is:

define('DIR_FS_MANUFACTURERS_IMAGES', 'manufacturers/');

define('DIR_FS_CATEGORIES_IMAGES', 'categories/');

define('DIR_FS_PRODUCTS_IMAGES', 'products/');

 

What am I missing???

 

Please help.

Link to comment
Share on other sites

hi i do get two type of errors

 

Error: Catalog images directory is not writeable: /home51c/sub004/sc34668-YXAE/www/shopping/images/

 

and once tye tried to be upload i get the error

 

IMAGE DOES NOT EXIST

Categoria-Default.gif

 

I have FTP the file in two locations shopping/images/categories and just shopping/images/ and try to upload from local to server location using the OSC admin screen

 

but still no joy

The second error you get is caused by the first. As it says you cannot write to the image directory. This is probably due to chmodding. Try chmod your images directory and the new directories you've created for the categories to 704 and see what you get. If you're not sure how to chmod, just ask!

 

 

Great contribution!

Looks like just what we are looking for.

 

I'm getting the same error that is in your screen shot.

 

My error message:

Error: Destination does not exist.

Error Error: Catalog products images directory does not exist: /var/www/html/plugins/vsc/catalog/images/products/

 

the above is from our root directory

Checked spelling numerous times, everything is identical.

 

Categories structure set up from my admin reads in the top pulldown

Go to: Top

painting

acrylic

 

 

Folder structure is:

catalog/images/products/painting/acrylic

admin/includes/config.php is:

define('DIR_FS_MANUFACTURERS_IMAGES', 'manufacturers/');

define('DIR_FS_CATEGORIES_IMAGES', 'categories/');

define('DIR_FS_PRODUCTS_IMAGES', 'products/');

 

What am I missing???

 

Please help.

I'm not sure why it can't find the folder. Just to check what folder it can't find.. in catalog/admin/includes/languages/english/categories.php

what do you have for the define error message?

it should be this:

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Error: Catalog products images directory does not exist: ' . DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $_SESSION['categoryfile']);

which will tell you exactly what file is causing the trouble. I can't really see a problem, unless you've put in some code incorrectly.

Link to comment
Share on other sites

The second error you get is caused by the first. As it says you cannot write to the image directory. This is probably due to chmodding. Try chmod your images directory and the new directories you've created for the categories to 704 and see what you get. If you're not sure how to chmod, just ask!

 

I'm not sure why it can't find the folder. Just to check what folder it can't find.. in catalog/admin/includes/languages/english/categories.php

what do you have for the define error message?

it should be this:

define('ERROR_CATALOG_PRODUCT_IMAGE_DIRECTORY_DOES_NOT_EXIST', 'Error: Catalog products images directory does not exist: ' . DIR_FS_CATALOG_IMAGES . DIR_FS_PRODUCTS_IMAGES . $_SESSION['categoryfile']);

which will tell you exactly what file is causing the trouble. I can't really see a problem, unless you've put in some code incorrectly.

 

Thanks,

I have that code in the catalog/admin/includes/languages/english/categories.php still get the same error.

 

One other thing that might be interfering is I had previously added the "Customer Add Products" contribution which made changes to the admin/categories.php file??

Link to comment
Share on other sites

Thanks,

I have that code in the catalog/admin/includes/languages/english/categories.php still get the same error.

 

One other thing that might be interfering is I had previously added the "Customer Add Products" contribution which made changes to the admin/categories.php file??

the error message still says:

Error: Catalog products images directory does not exist: /var/www/html/plugins/vsc/catalog/images/products/
?

seems like it can't find the directory... but you're sure that it's correct?

 

What changes did the other mod make? did it change any of the parts around those which my contrib changes?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...