Tips for Upgrading Magento

If you’ve spent any time working with Magento, you know that updates can be a real pain. We recently performed an upgrade for a client going from version 1.5.0.1 to 1.6.2.0. After spending an entire day trying to work through all of the errors, we finally got it working. We spent hours searching the Magento Forums, Stack Overflow, and Google for answers to any and every problem that we had during the process. Fortunately, a lot of the issues were common but there were a few that were unique to our situation. To make things easier for everyone, we’ve put together this list of things that you can try if the upgrade isn’t working.

Ideally, you will do these things before you start the upgrade process. You shouldn’t be performing the upgrade on a production server, so these tips are given under the assumption you haven’t started the upgrade or have the ability to start over should something go wrong. Always perform a back up of the files and database before starting an upgrade.

Disable the Cache and Clear it

This is a no-brainer. Magento is very resource intensive so it tries to cache anything and everything. Login to the admin and go to System > Cache Management. Select all items and choose “Disable” from the drop down menu.

Enable the Default Theme

If you’ve developed a custom theme for Magento, you will almost certainly run into problems when upgrading. In the admin, go to System > Configuration > Design and update your theme to use the Default templates.

Disable ALL Community Modules

This step is one that can be easily overlooked. Head to System > Configuration > Advanced > Advanced and disable all extensions that don’t start with “Mage”. Another way to do this is to open up app/etc/modules and edit each file by changing the <active></active> attribute from true to false. Once you’re done with the upgrade, enable them one by one to test and see if any specific module causes any problems.

Update the initStatements in app/etc/config.xml

There’s a 99% chance you’re going to get an error that looks like this:

SQLSTATE[23000]: Integrity constraint violation:

To fix this, open up app/etc/config.xml. You’re going to change the <initStatements> from this:

[sourcecode language=”xml”]
<initStatements>SET NAMES utf8</initStatements>
[/sourcecode]

to

[sourcecode language=”xml”]
<initStatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initStatements>
[/sourcecode]

Double Check Customization to Magento Core in app/code/local/Mage

If you’ve made changes to the Magento Core files, you hopefully did it by copying the files to app/code/local/Mage instead of modifying them in app/code/core/Mage. The problem with this method is that it can potentially break your Magento installation if those core files are upgraded. There’s a good chance you won’t remember any changes you made to the core files so it’s best to just delete (backup first) app/code/local/Mage before you start the upgrade. We spent hours trying to figure out some upgrade problems when it was our customizations that were creating a bottleneck with the process.

Once you’ve finished the upgrade, make sure you clear var/cache and var/session.

Hopefully some of these tips will save you some time and prevent some nasty headaches that Magento is known to cause.