Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Two front ends from same database different navigation


Rosyweb

Recommended Posts

Hello

 

I'm trying to create 2 front ends - one back end shop.  This is so that I can have the 2nd site showing the products in different categories - so I can have a different navigation menu for each shop showing on the public side, but when we update our products we only have to do it once. 

 

OK so I thought create duplicate tables for those that link products to categories and define what categories they are in:

 

categories

categories_description

products_to_categories

 

2nd copies called:

 

categories_two

categories_description_two

products_to_categories_two

 

and do a full site find and replace for any instance of TABLE_CATEGORIES  ... etc   etc

 

This worked - the 2nd site now has all the correct table names in the code and uploaded.

 

But in the 2nd installation, I log into the admin panel and create a new category.  It creates this fine - but when I look at the SQL database it has put it in the original TABLE_CATEGORIES  not the new TABLE_CATEGORIES_TWO that the code is pointing to.    

 

I check the code again (make sure it uploaded correctly etc) and it is pointing to the new table TABLE_CATEGORIES_TWO from this interface but the action of creating info is still being saved to the original table.  TABLE_CATEGORIES 

 

Anyone any idea why?    I'm banging my head against a wall as this should work.

 

Is it a sessions thing?  I've also turned off cache - incase it was that. 

Both installations are on the same server of course so they can both connect to the same SQL database. 

 

many thanks

 

 

 

 

 

 

Link to comment
Share on other sites

@@Rosyweb

 

Very interesting Ros...I do something similar but went it in a completely different direction and added a site field to the existing product and category tables to control which products and categories are displayed on which site.  I didn't want to maintain duplicate products...a lot of the time I display the same product but on different sites.

 

In any case I think that what you are trying to do is possible....to start I guess I would have a look at what table the sql is using to create the data....maybe output the query to your screen so you can actually see the query that is being generated.   That will presumable show you that it's not picking up the correct table name so you can back track and figure out why.

 

Keep us posted...what you're doing is interesting.

 

Dan

Link to comment
Share on other sites

Thank guys. 

 

OK I found my mistakes and actually after all this time trying to figure it out, it was even easier than I thought.

 

So for my 2nd copy of the store, I created a 2nd copy of the 3 tables: (categories, categories_description, products_to_categories)  in the database that is shared by the 2 stores. 

 

Then in the 2nd store files, I didn't need a site wide find and replace at all.  Just leave the references TABLE_CATEGORIES, TABLE_CATEGORIES_DESCRIPTION, TABLE_PRODUCTS_TO_CATEGORIES  as they are.  You only need to change the table names to match your new table names in the 2 database_tables.php files.

 

So far, does just what I wanted it to do.  If I come up with any conflicts etc I will post it. 

 

I also have the add on:  Hide Categories & Products V1 installed which means that now I can hide whole navigation areas on one store front and leave them showing on the other site.

Link to comment
Share on other sites

Could you run into any problems with a customer active on both stores, where you would have confusion over which product in their cart or order history a certain product ID refers to? That is, duplicate IDs for two different products causing any conflicts?

Link to comment
Share on other sites

Well the product ID's are the same, I'm still using just one 'products' database - shared by the 2 site front ends.  It's just the connection to the categories products_to_categories table and categories and categories_description tables that I have duplicated.   So its simply where on the website the customer views the product, but the product is always the same and has just one ID.

 

So shouldn't cause any conflicts there. 

Link to comment
Share on other sites

@@MrPhil

 

Could you run into any problems with a customer active on both stores, where you would have confusion over which product in their cart or order history a certain product ID refers to? That is, duplicate IDs for two different products causing any conflicts?

 

Phil...I've been doing this sort of thing for a few years now and have not seen any issues at all...I'm also running different configuration files so that I can have different features available on the various sites....it all seems to play nicely together.  In my case the database side is all the same so there really isn't any duplication of customers or products etc.   

 

Dan

Link to comment
Share on other sites

@@multimixer

 

Take a look to here: http://2me.gr

 

2 store fronts, common admin, common database, common login, common shopping cart

 

Didn't find the time to write a proper post about

 

So George are you going to tell us a bit about it or are you going to leave us hanging.  :-

 

Dan

Link to comment
Share on other sites

  • 1 month later...

I've now completed my 2 different store fronts, both with different navigation, different looks but using the same product database.  So products and product stock only needs to be updated once on either site and they feed into the same database.   

 

Both stores point to the same SQL database.  I created duplicate tables of:

 

configuration

configuration_group

 

categories

categories_description

products_to_categories

 

then linked the new re-named tables to the 2nd site through the 2 database_tables.php files. 

 

I ran into 2 problems along the way.

 

1st - was when I created a new product in one site, it was not viewable in the other site as the other sites navigation was on a separate products_to_categories table. 

 

So in the file admin / categories.php I added a line of code under:

      tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");

 

I added:

      tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES2 . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . 111 . "')");  

 

and added a table name of TABLE_PRODUCTS_TO_CATEGORIES2 to the two database_tables.php files and linked that to the 2nd copy of the products_to_categories table.  I did this for both sites and each site linked to the other sites products_to_categories table. 

 

 

What this in effect does is put the new product in the category you are creating it in on the site you are creating it in (as it normally does) but then links the new product in just one folder on the 2nd site.  You choose which folder - mine was number 111.   Then in the 2nd site I can at least access the product and then decide which navigation categories I want it under. 

 

2nd problem - what to do about images.  I didn't want to have 2 lots of images sitting on the server in different locations and have to upload then and update them twice.   The image reference needs to link to a folder within the site.    Probably the easiest solution would be to sym link the images folders.  My hosting complany would not do this, so I nested one site within the other and the top site linked to the images folder in the nested site.

 

So I'm pleased with it and it seems to work as intended - so far.  Hopefully this might help someone trying to do the same? 

Link to comment
Share on other sites

@@Rosyweb

 

 

Ros, as you might have read in the earlier posts in this thread I've been doing this sort of thing for a few years now but I took a slightly different approach regarding the products....I added a field to indicate what site a product should appear on...site1, site2 or both. I then reworked the product queries to read in the extra field and use that to determine if the product should be displayed or not.   Having only one product, not two, avoids any additional work in creating a second product or storing images etc.

 

Seems there are always multiple ways to skin a cat...

 

Dan

Link to comment
Share on other sites

Sounds great.  I've only got one product also. 

 

But how do you get your two sites to have a different navigation tree with the same products, without any duplication of these tables?   

 

categories, categories_description, products_to_categories  ?

Link to comment
Share on other sites

Link to comment
Share on other sites

But how do you get your two sites to have a different navigation tree with the same products, without any duplication of these tables?   

 

In my case I sell pet supplies so I have lets say Reptile and Aquarium Supplies and of course all of the products are in sub-categories under the respective Reptile or Aquarium Supplies top level categories so I just display the categories belonging to the top category # assigned to Reptiles on the Reptile site and for Aquarium Supplies anything assigned to the top level category # assigned to the Aquarium Supplies is displayed on the Aquarium Supplies site and so on and so forth.  You can actually set up any combination you like doing it this way. 

 

Dan   

Link to comment
Share on other sites

So I'm presuming you hide the top category name "Reptile" or "Aquarium Supplies" on the site that doesn't display those products.     

 

How do you hide it for just one of your sites - bearing in mind they are both using the same categories table?   Or did you add a field to the categories table also to tell it which site to appear on? 

Link to comment
Share on other sites

@@Rosyweb

 

Morning Ros...

 

If you set the top level category it just displays those sub-categories that are under it....there is no need to do anything but I did add a field to the categories table to give me even finer control in case I want to hide a sub-category for some reason.

 

Dan

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...