Let’s learn how to merge two Magento installs! Recently I was tasked with the job to merge two Magento installations. One of our clients had two sites, one for Canada and one for the United States, and wanted each under their own store front & store view within Magento. One of the specifications was to just use the existing skin of the Canadian site, and merge the US one into it. Because this is such a high level view of what actually would be going on, it seemed like an easy task. Maybe it would take two weeks? The reality is, when you have two independent websites, each with order history and unique products, this isn’t always the easiest thing in the world…
One of the reasons for merging two installs may be that you’re on Magento Enterprise and would like to only pay for one annual license and not two. Another reason may be that you’d like your business grouped together on one backend without having to switch between two installations. This may also be a hassle for other reasons like duplicate order numbers, duplicate customer IDs, etc.
That being said, you should first ask yourself if you really need to merge the installs. It is a big task. Can you get by with having / running one or more installations?
Below is a list that I have prepared regarding items that you must remember in order to do the merge.
The nice thing about merging is that you can first create all the configuration changes you need to make before you actually merge the installs on your live environment. Remember to create your new category root, website, store, and store view within the install that will be merged to. For more information, see this guide.
When you’re ready, you can change the configuration scope within System > Configuration to your new website (or store view) and copy over configuration values from your old site / site you’ll be merging.
Static Blocks / CMS Page
Remember to copy the CMS pages and static blocks to the site you’re merging to. For good measure and to make sure nothing conflicts, remember to restrict the blocks and pages to your new install. For our purposes, we were able to copy the CMS pages and static blocks by hand.
Export / Import Products
Luckily in Magento you have the capability to use a built-in module called ‘Dataflow’ which allows you to export and import certain sets of data. If you navigate to System > Import / Export > Dataflow – Profiles. The values which are important here is the ‘Store’ drop down (if you’re migrating from a multisite install, just choose the appropriate store view). It also has a good feature to filter products if you only want to export and import certain products. When you’re ready, click ‘Run Profile in Popup’ and the export file will be placed in the export directory (most likely var/export). You can transfer this file to var/import on the new site and reimport (but wait until you have all of your other files / ducks in a row before doing this.)
Within this file, you should edit a few things:
1. Attribute Set
In the attribute set column, make sure that we’re using the appropriate attribute set on the new site. Just the name of the attribute set needs to go here.
2. Replacing Content
Replace content in the ‘website’ column to match the new website’s ID on the site you’re merging to.
For category IDs, we used a custom module which we will link to at the bottom of the post. It allows you to map all old category IDs to the new one. Now is a good time to create a simple CSV file which maps the old site category ID with the new category ID within your newly created root category. An example may look like this:
Place this file in var/import and call it old_to_new_cats.csv.
Export / Import Product Stocks
This step is very similar to the one above as it has it’s own dataflow profile. All you need to do is export the stocks and then import then after you’ve imported the products. Note that this process won’t create products if it can’t find them, which is handy if you have old, outdated products which you didn’t initially export. You’ll need to replace the ‘store’ column with your store code here.
Export / Import Customers
This step is also pretty straightforward, as there is a dataflow profile for it as well. Note that in our CustomDataflow extension we provide the functionality necessary to export wishlist items as well as store credit balances and history (store credit is only available within Enterprise, so you may need to edit this code for Community). Make sure to edit the ‘website’ column and fill it with your new website code. If you have special customer groups, you may need to migrate these over to the install being merged to for this import to properly map to them.
This was by far the toughest task when migrating a site. Orders in Magento are inherently complex as there’s so many layers of information. We ended up using a paid extension for importing and exporting orders which worked OK – we had to do some heavier modifications to fit our needs. If you can, keep the old site archived for past order lookups and just begin taking new orders on your new website.
Make sure to merge your old media folder with your new one. The most important directories are most likely catalog, category and wysiwyg. Do not just hit “overwrite all” – it’s important to make sure you know which files you’re leaving out or replacing if any.
This goes hand-in-hand with configuration, as you need to remember to migrate your old site’s theme into the new site. You can change this value in System > Configuration > Design. Remember that there’s two parts of your theme: the theme found in design/front-end, and the one found in skin/front-end.
Were there any crons that you had setup on the old server to do any reindexing tasks, or custom scripts? Make sure those are running on the new site. And – if the scripts are custom, make sure they only apply to the new website.
Inevitably, you have installed extensions which add their own custom tables and populate them with data. Please remember to move these individual tables and their data over to the new site if you need to continue using them.
This sums up the basis of what you would need to migrate. If you can, it’s worth taking a copy of your MySQL database and doing a test merge as we did to make sure you have all your ducks in a row.
**Please review this code before you use it. You may need something more custom for your migration as every Magento site is a beautiful, unique snowflake. Demac Media is not responsible for a loss of information / issues with this attached module.