Fixed Knowledge Base

Get all the help you need here.

This is restricted content – not visible to the public.

Magento Migrations

Posted 15th декември, 2018

Magento website migrations are in theory as simple as any other software:

  1. The files must be moved from the old host to the new.
  2. The database must be exported from the old provider and imported to the new provider.
  3. The configuration in /app/etc/local.xml must be updated to tie to the files to the database.

However, there can be a few pain areas.

Clear Cache

Magento's caching can cause much confusion. Before changing config, clear out /var/cache and /catalog/products/cache. Do not clear these out on the old host, in case they were actually cached versions of the site working correctly (and something has been broken on the backend, which will only be exposed once the cache is cleared!).

Database Size

The magento database, especially the log_ tables, is huge. There can be millions of rows. This may break an export and/or import. The database may need to be imported in stages.

Foreign Key Restraints

Because the Magento database has foreign key restriants, it ideally needs to be imported in one go. If that fails, follow the following steps:

  1. Export the database in order as. sql files, a handful of tables at a time to keep you under the import / timeout limit
  2. Upload the files to the destination web server, or to a server that can access the database using cli
  3. Run the following command for each file, in order:

mysql --force -h [hostname] -u [username] [databasename] < filename.sql.

If run like this, you should not see any foreign key errors.

Magento MultiStores

Make sure that the .htaccess has SetEnv variables that look like this:

SetEnvIf Host .*somewebsite.* MAGE_RUN_CODE=ViewA
SetEnvIf Host .*somewebsite.* MAGE_RUN_TYPE=website

SetEnvIf Host .*somewebsite.* MAGE_RUN_CODE=ViewB
SetEnvIf Host .*somewebsite.* MAGE_RUN_TYPE=website

ViewA and website need to be adjusted according to the values in core_store in db.

If the above does not work, you can adjust the index.php by adding the following at the end:

switch($_SERVER['HTTP_HOST']) {
    case '':
    case '':
        $mageRunCode = 'peak_view';
        $mageRunType = 'store';
    case '':
    case '':
        $mageRunCode = 'default';
        $mageRunType = 'store';

The above code goes before the last line of index.php which should look like this:

Mage::run($mageRunCode, $mageRunType);

As always, please make sure you backup before doing anything on the customer files!

Other things to check

  • If using plugins such as Magento 2 Ebay (M2E) ensure that the licence key is updated with the provider. This plugin syncs Magento orders with Ebay, and will not syncronise unless the licence key is valid.