Zen Cart Logo
Forums / General Questions / 2 Carts/Shops sharing 1 Database

2 Carts/Shops sharing 1 Database

Views: 1,070

Results 1 to 8 of 8
23 Apr 2011, 9:04 AM
#1
irishshopper avatar

irishshopper

Zen Follower

Join Date:
Apr 2010
Location:
County Down, Northern Ireland
Posts:
302
Plugin Contributions:
0

2 Carts/Shops sharing 1 Database

I wish to have 2 separate ZenCarts/Sites which share the same database. I read somewhere that this was possible but cannot find the article.

Do any of you know how to do this.

Also if say one site had 100 products and the other say 80 out of that 100 it is possible to go in to the ZenCart Control Panel of the site where I want the 80 products and go in and turn off the other 20 and they will not appear in that site but will appear OK in the one that I want 100.

23 Apr 2011, 9:31 AM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: 2 Carts/Shops sharing 1 Database

Yes, and, I think, no.

You can have two Zencart sites share one database by specifying a DB table prefix for each when you install Zencart. I have no idea why you'd want nto do that though.

Doing as I described above essentially creates two different databases in the same DB structure, so the two sites couldn't share products.

https://www.zen-cart.com/tutorials/index.php?article=66

23 Apr 2011, 11:05 AM
#3
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: 2 Carts/Shops sharing 1 Database

Yes it is possible. One code set, one database, two (or more) sites.

Two possible approaches ...

Firstly there's a multisite add-on somewhere in the downloads area that I believe works by separating products for each site into categories, which I guess you could then cross-link between (we've not actually used this mod at kuroi).

Second approach (which we have used) is much more technical and requires a fairly high degree of techncial knowledge of Zen Cart's internals, though the changes themselves are fairly surgical. You'd need a new table (or an extension of the existing product table) to indicate which products were available to which site. Then the listings and search pages algorithms need tweaking to restrict the products displayed to those that are appropriate to the site - we re-wrote the misnamed "hidden wholesale" add-in module to allow this. Then there are admin changes to allow whatever data structure you've implemented to be maintained on the product pages (we actually customised the quick updates add-in to do this).

We took it further too. So the tax treatment is different between the sites: the client has a wholesale site which shows prices ex tax and a retail site that shows them inclusively, which was done by hijacking the display with tax constants and setting them according to the site URL. We also recorded the where the purchase was made in order to brand invoices accordingly. And topped the whole thing off with a multi-domain SSL cert to avoid nasty warnings in browsers.

23 Apr 2011, 5:58 PM
#4
irishshopper avatar

irishshopper

Zen Follower

Join Date:
Apr 2010
Location:
County Down, Northern Ireland
Posts:
302
Plugin Contributions:
0

Re: 2 Carts/Shops sharing 1 Database

Thank you for your answers. Will study those in detail.

As to the question WHY DO WE WANT TO DO THIS ? Simple to avoid having to upload 80 products, descriptions and images on one Database to have to repeat the same exercise on another 2nd database.

For example we have 100 products which sell on one site but then we have a similar site but because of the country it is being targeted at we will be omitting around 20 of the pruducts that are on original site.

Open to suggestions as to the best approach if what I am suggesting is not the best way.

Apart from the duplicate uploading then at a later date if we have to change prices/images etc it would mean double work again if it is two separate ZenCarts/Shops.

23 Apr 2011, 7:57 PM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: 2 Carts/Shops sharing 1 Database

I suspect that you'd find more work setting up and maintaining a multisite than maintaining 80 common products across two sites.

But a lightweight alternative might be to use just the hidden wholesale mod to suppress the 20 based on an IP-lookup evaluation of the country from which the traffic is coming.

25 Apr 2011, 4:14 AM
#6
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: 2 Carts/Shops sharing 1 Database

irishshopper:

Thank you for your answers. Will study those in detail.

As to the question WHY DO WE WANT TO DO THIS ? Simple to avoid having to upload 80 products, descriptions and images on one Database to have to repeat the same exercise on another 2nd database.

For example we have 100 products which sell on one site but then we have a similar site but because of the country it is being targeted at we will be omitting around 20 of the pruducts that are on original site.

Open to suggestions as to the best approach if what I am suggesting is not the best way.

Apart from the duplicate uploading then at a later date if we have to change prices/images etc it would mean double work again if it is two separate ZenCarts/Shops.

imo:
With only 2 websites and around 100 products it will be far quicker to do it manually than to try to set up what you are asking.

To ease initial setup copy the 100 product database to the new database and delete the 20 products from the new database that you don't need.

You should probably spend far more time customising the appearance of the 2 websites than updating a 100/80 product database in 2 websites.

25 Apr 2011, 7:06 AM
#7
irishshopper avatar

irishshopper

Zen Follower

Join Date:
Apr 2010
Location:
County Down, Northern Ireland
Posts:
302
Plugin Contributions:
0

Re: 2 Carts/Shops sharing 1 Database

Thank you for your response. I think this would be the easiest approach and will go with it. Can change files and upload them but just not sure what exactly I need to do to copy the database and delete the products as below.

To ease initial setup copy the 100 product database to the new database and delete the 20 products from the new database that you don't need.

Where do I access the database to copy it ? Once I do manage to copy it do I just go in to the ZenCart Control Panel of the new site and turn off/delete the 20 products there ?

I have a number of new sites to set up which would share the same basic core of products with then some regional variations added to the basic products so it would be great if I knew how to "copy the database over".

THANK YOU.