Zen Cart Logo
Forums / Customization from the Admin / merge 2 store databases

merge 2 store databases

Locked

Views: 1,941

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
17 Aug 2012, 9:11 PM
#1
richardtuttle avatar

richardtuttle

New Zenner

Join Date:
Dec 2011
Location:
Boise, ID
Posts:
28
Plugin Contributions:
0

merge 2 store databases

We have two ZC sites currently setup and running, but would like to move over to just one but, in order to do so, we'd like to keep all of our customer information (address, order history, etc.) together.

So, I'm writing in hopes that someone can enlighten me on how to merge the information from two databases into the one. I don't need to merge the store configuration or the product information, just the customer stuff and histories.

I've searched the ZC site and documentation and cannot see where there has been discussed before.

We're running version 1.5 for both sites.

Thanks for any advice in advance!

18 Aug 2012, 12:53 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: merge 2 store databases

Mangling the data to do as you're asking is an intense exercise that should only be done by someone knowing quite a bit about databases and the Zen Cart database structure/schema and table relationships.

Zen Cart v1.x treats order numbers and customer numbers based on the assumption that there's only one store in the database. As such, order numbers start at 1 and move up.

So, you likely have two stores with an order number 1, and a number 2, etc.
And your customers have order-confirmation emails containing messages like "Your order number is: 1 and to view it click here: www.__.com/???order=1"

If you try to "merge" all the data from Store B into Store A, it will require finding out the last order number in Store A, then rebuild all the orders from Store B starting at that new order number, until all the orders are done. It will also completely break all the links in the old emails those customers have received and their order numbers won't match the text or printed invoices they've received. Then you'll need to do the same with all the customers and their addresses etc. (actually you'd need to do the customers+addresses first, before the orders).Fortunately the customer "number" is less important in terms of emailed history etc.

Are you okay with that? Is your accountant okay with that? Are your customers okay with that?

18 Aug 2012, 1:00 AM
#3
richardtuttle avatar

richardtuttle

New Zenner

Join Date:
Dec 2011
Location:
Boise, ID
Posts:
28
Plugin Contributions:
0

Re: merge 2 store databases

Actually, yes we are okay with having the links in the emails sent to customers being a little incorrect. And I would be okay with getting someone to do the database merging, I would just like to know which tables within the database would need to be merged in order to do this. From your reply, it sounds like the ad customers and addresses would have to be done first (and separately) from the orders and their history.

Is there an overview anywhere on this?

Thanks!

18 Aug 2012, 1:07 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: merge 2 store databases

You'd need to first re-number all the customers and their addresses, and then renumber the address records for the customers (there's a two-way relationship to maintain). And then you need to renumber all the customer ids in all the orders to use the new numbers. And then you need to renumber all the orders. And in all those cases there are multiple tables having multiple IDs that need maintaining all the way through. And then copy all those records over.

I'm extremely reluctant to just "hand over a list of tables" because I'm scared that you'll just run off and break everything. To be honest, if someone is asking the questions you're asking, then you're definitely not the person who should be tackling this exercise. Nevertheless, the list of tables is here: http://www.zen-cart.com/wiki/index.php/Developers_-_Database_Schema

30 Sep 2012, 8:17 PM
#5
petleyj avatar

petleyj

Zen Follower

Join Date:
Jul 2009
Location:
Norwich, UK
Posts:
122
Plugin Contributions:
0

Re: merge 2 store databases

This is how I did mine.

I had a rather large site, and wanted to build another site.

The way I did it was I have one database, 2 sites, 1 site up and running, the other spare.

I completed the other build and then added the two sites into one database.

Simple if you know MYSQL for a living.

But to explain it in a simple term, you need to re-build your less popular store from fresh and add the database you have into it.

Simple, then add images ect. Job's a good'un!

If you need more help, im sure I can help.

But as for merging, well it's a rather complicated process.

James