Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Expert Needed: Universal Images for Multiple Sites


DoctorLarry

Recommended Posts

Quick Intro:

Ok, first of all, keep in mind I'm a self-taught rookie that has learned just enough to be dangerous. :D I think I've done pretty well & come quite a way considering I'd never even touched a computer prior to 3 years ago and have had absolutely no special schooling. Bottom Line: I take pride in self accomplishments & have hundreds of hours worth of trial & error logged as a result. However, this one's got me stumped ! Thus, please be patient while I humbly try to outline the problem for which I'm in hopes the solution will benefit many. Thanks.

 

Scenario:

I've got multiple store's that are basically clones of each other that serve different purposes but share most of the same images. For example, I've got a live store, a test store, & a gallery version of the same store. Each of them exists in independent folders, are uniquely named & have their own database's. I've managed to modify the config files, etc. & define what I like to call my (Image_Vault) such that they all pull their images from the same defined folder including thumbnail's. Problem is that the default image directories are now being bypassed as a result of redefining select php file to echo the (Image_Vault) vs. (DIR_WS_IMAGES). However, when new products are added via the admin, the images are placed into these default directories that are bypassed when displaying the item. Now for those that like the concept so far, and don't have a need to use the default image directories independently, simply change your admin config to upload to your (Image_Vault). However, I prefer to have the option of using either &/or both. Thus, keeping each store truly independent from one another with the exception of the universal images. Advantage: icons, buttons, etc. can still share the same name but be fully customized to their respective stores by being store in their default directories.

 

In a nutshell:

What I thought would work would be to write a statement such that a catalog page such as product_info.php would run a query to check for the presence of the product's image name in the secondary (Image_Vault) database & then,.. If not found, revert to the primary (active) store's database via something like a }else, if, etc.{ statement to query for the same named image. Again, I'm a rookie, so I'm assuming that any page that calls for the desired images i.e. product_info, product_listing, etc. would have to each be modified to include the statement. However, if anyone thinks it's possible to have it as a global statement/function, don't hesitate to add your suggestion.

 

Just a Guess:

No where close but here's a general outline of my idea :blink:

Case:<?php

? ? if ($product_info_values['products_image'] != '') {

?>

 

Statement-1 to query secondary Image_Vault database:

<?php

? $product_info = tep_db_query_image_vault(DB_IMAGE_VAULT)("select p.products_image,...,...,...")

?>

? ? if ($product_info_values['products_image']) {

echo tep_image(IMAGE_VAULT . $product_info_values['products_image'];

 

? ? } else if {

 

Statement-2 to query the Default_DB

<?php

? $product_info = tep_db_query_default_db(DEFAULT_DB)("select p.products_image,...,...,...")

?>

? ? if ($product_info_values['products_image']) {

echo tep_image(DIR_WS_IMAGES . $product_info_values['products_image']; }

? ? ? ? ? ? ? ?>

 

*Hope That's Clear as Mud :rolleyes: Good Luck ! & Look to hear from you soon.

 

Special Thanks: to all those whom I've used thier contibution to get my site to where it is so far. Especially Linda McGrath ! You Rock ! So Many Great Idea's.. So Little Time.

:P

There is no Peak to the "Learning Curve",..

Only the limits for which we challenge our selves.

The answer dwells within the "MATRIX" of our minds.

My brain hurts from trying to bend the damn spoon !

Link to comment
Share on other sites

Don't know if you thought (or knew) about this.. but if you are using a *NIX platform for hosting, all you really need (if all sites are on the same server or trusted network) is a symbolic link to one of the stores *real* image directories.

Link to comment
Share on other sites

Thanks 4 the interest Zilla !

Not exactly sure how to implement what your suggesting though ? All of my store are Unix & are all on the same server. Could you please give me an example of this symbolic link for which I assume would be defined in the store's config files ?

 

I think perhaps, however, this has already been accomplished in that the already defined (Image_Vault) is a *real* image directory for which all the store's are currently pulling their images from. Thus I've already established the "Universally Shared" image directory. (See Example in Box Below) The problem is that any new product's that I add to the other store's show up as blank images because the pages are looking for them in the (Image_Vault) instead of their own respective image directories. My goal is to have one store or directory that basically supplies default "stock" images for the cloned store's but, at the same time, allow the cloned stores to add uniquely individual product's such that the catalog's product pages look at the "default stock database" first & then, IF the product is not found, it reverts to it's own database and pulls the images from it's own image directory.

 

For example:

We all know that the newly downloaded & installed version's of osCommerce are basically (clones) of each other that all have identical default images stored in their respective image directories & that these store's then require customization to change look & feel including the product's & their images. Now, imagine that rather than having these initial default installed items stored individually in everyone's image directory's that the store's we're originally config'd to pull the "default stock" images from Harold's server. ;) (LOL) Talk about your mega band width !!! Hypothetically speaking, however, let's just assume for a moment that to be the case for the "default stock" item's only. Meaning, that rather than having 50,000 newly installed catalog's (clones) all with 50,000 identical images directories, there would only be just the ONE... Harold's (Image_Vault). Now, assuming we haven't blown up his server as of yet, what's really gonna cook his goose is when those same 50,000 store's start customizing and adding new product's ! Remember, these hypothetical new catalog's are only config'd to pull their images from Harold's (Image_Vault) Thus, the only way you see any new product's images would be to also have the admin side of each store config'd to upload all the new item's to his (Image_Vault) as well ! = BIG PROBLEM'S. :( However, I'm sure we could prevent Harold from having a complete heart attack if the newly installed (cloned) store's were config'd on the admin side to upload new product's & their images to their own respective databases & image directories... just as it already is now. Then have the catalog side configured such that the product pages would simply check for the presence of their new non-default item's in Harold's database=> (Image_vault) & IF NOT found would revert to the uniquely individual cloned store's database & pull the images from their own image directories. Hope that help's explain what I'm trying to accomplish. :rolleyes:

 

Thus, I was thinking a statement something to the effect:

Add to Catalog Config's:

Catalog/includes/local/configure.php

? define('DB_DATABASE', 'Catalog'); // Default Cloned Store

? *define('DB_DATABASE_2', 'Image_Vault'); // Alternate "Stock" Image Vault

 

Catalog/includes/configure.php

? define('DIR_WS_IMAGES', 'images/');? // Default Cloned Store

? *define('IMAGE_VAULT', 'http://imagevault directory location ?'); // Alternate "Stock" Image Vault

 

For All Case Images Catalog Pages:

<?php

? ? if ($product_info_values['products_image'] != '') {

?>

 

Check Image_Vault Database First...

i.e. ( if Harold's_Database; then => (Image_Vault)

<?php

? $product_info = tep_db_query_image_vault's_db ..???

?>

? ? if ($product_info_values['products_image']) {

echo tep_image(IMAGE_VAULT . $product_info_values['products_image'];

 

} else {

 

Then, Check the Clone's Database Second

i.e. ( if Clone_Database; then => Clone_Catalog/image directory )

<?php

? $product_info = tep_db_query_clone's_db..???

?>

? ? if ($product_info_values['products_image']) {

echo tep_image(DIR_WS_IMAGES . $product_info_values['products_image']; }

? ? ? ? ? ? ? ?>

Thanks Again to All !

I'm in hopes someone will be able to help me write this code. I know what I want to do.. just don't know quite enough about the "db_query" language to get it done :( I seem to manage & hold my on as far as altering or hacking mod's in place to suit my needs but am still learning the basic language to create my own codes. No worrys though, I hope to have a couple of contribution's to add as well in the future !

Trial & Error, combined with persistance, eventually leads to success !

There is no Peak to the "Learning Curve",..

Only the limits for which we challenge our selves.

The answer dwells within the "MATRIX" of our minds.

My brain hurts from trying to bend the damn spoon !

Link to comment
Share on other sites

  • 2 weeks later...

What your looking to do is actually rather simple. I'll give a run down example. I run 11 stores, 7 are cosmeticaly the same but different locations thus different contact information etc... The other 4 are different names but have the same product database.

 

For simplicity sake lets assume the following structure to your root web directory.

 

/var/www/html

 

then we have:

 

/var/www/html/store1

/var/www/html/store2

/var/www/html/store3

etc...

 

create a:

/var/www/html/images

 

Now in each of your store's /includes/configure.php

 

change

 

define('DIR_WS_IMAGES', 'images/');

to

define('DIR_WS_IMAGES', '../images/');

 

Now all your stores will head up 1 directory to look for the images saving you disk space, and syndicating your product images.

 

I went a step further on this example and set it up so that my client logs into store1/admin adds his product and it poopulates instantly across all his catalogs. Did you need to know how to do this as well?

 

Ryan

Link to comment
Share on other sites

With the shops that I have online.. I've customized them to the point that the images do not call to the tep_images_directory, I've simply specified the images directory for the website graphics and just keep the product images centralized.

Link to comment
Share on other sites

/var/www/html/store1

/var/www/html/store2

/var/www/html/store3

To get the same effect with a symbolic link, you would (at a unix shell prompt) type
ln -s /var/www/html/images /var/www/html/store1/images /var/www/html/store2/images /var/www/html/store3/images ...

If you don't have access to do this, your host would be able to do so. This would save changing the configure.php files. The first path is the one to which the others will link.

 

Hth,

Matt

Link to comment
Share on other sites

I have multiple stores that do NOT reside on the same servers AND that do NOT share templated images & buttons BUT DO share the actual catalog (products/info/pricing/images).

 

I wondered if anyone knew how to go about this in OSC?

 

Unique Site 1 (server 1), Unique Site 2 (server 2), Unique Site 3 (server 3)

 

all product images loaded on any one of the servers above for all the sites.

 

Actually, I do have a server dedicated to image storage so that would be server 4, not actually using #1, 2, or 3 above. Just wasnt sure if this might complicate it more, perhaps not.

 

Basically I think (uh oh!) that I need OSC to accept an IMAGE URL for the database info instead of requiring me to browse locally & upload an image. This way the image URL info is put into the database. Correct?

Link to comment
Share on other sites

  • 5 weeks later...

Why don't you just do something like this (not tested, and you'd probably have to adapt to your needs):

 

function get_file($path, $filename) {
if ($dir = opendir($path)) {
    while (false !== ($file = readdir($dir))) {
         if (!is_dir($path.$filename)) {
              $image_code = 'Your Image code goes here. (ex, <img src="vault/whatever.jpg>)';
         } else{
              $image_code = 'Your Image code goes here. (ex, <img src="images/whatever.jpg>)';
         }
    }
    closedir($dir);
}
return $image_code;
}

Then call it with:

get_file(DIR_WS_VAULT, $product_info_values['products_image']);

HTH,

-Chris

Chris Sullivan

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...