Best Way of Upgrading Magento 1

Magento 1 applications were never made easy to upgrade, whether that was upgrading a minor version (1.9.0 to 1.9.1) or a major version (1.8.0 to 1.9.0). A lot of discussions between users online involved long winded methods, such as copying across product, customer and order data which carried major risks in corrupting the database. The best way of upgrading Magento 1 involves setting up a blank instance of the Magento version you want to upgrade to, with a few simple steps.

This was tested upgrading Magento Open Source 1.6.1 to the latest Open Source version, 1.9.3.6. Version 1.6.1 was chosen because sample data can be downloaded from the Magento website that can be used for this version (sample data for later versions seem to have disappeared).

Although this example didn’t cover moving across much data, custom themes and multiple third party extensions, getting these steps right is a major factor in determining whether you will have a smooth upgrade process, particularly the extensions that add tables and data to your database.

Install the new Magento version

As mentioned, the first step involves creating a vanilla instance of the Magento version you’re going to upgrade to. This simply is a case of running through the install process and specifying a brand new database when prompted to add one. This will be the easiest step, and you’ll be ready to move on when you are staring at the RWD theme of a Magento instance on version 1.9.3.6.

Best Way of Upgrading Magento 1

Copy over Custom Theme Code

The next step is to head back to the existing Magento 1.6.1 store, and move over any custom themes you may have. This should include the code from both the app/design/frontend and skin/frontend directories. Don’t forget to check any theme-related assets that might lie within the js and media directories, although the majority of the theme should reside in the previous directories.

Now would be a good time to check and resolve any potential errors that may crop up. As the theme code will not have made any changes to the database, you are safe to debug and try out fixes. As layout XML and templating hasn’t really changed much over the versions, you probably won’t encounter many errors.

When you’ve finished the above step, move onto the main step: transferring the modules across.

Copy over Modules

It’s important to mention that you only need to move over the third party modules. The Magento core modules (Mage_*) can stay in the Magento 1.6.1 root directory as version 1.9.3.6 will contain them. Depending on how many third party modules you have will depend on the how much testing you will need to do to check that they work on the 1.9.3.6 database. It is advised that you go through each module, understand the functionality that it introduces (whether that’s frontend and/or adminhtml code). You can even copy across one module at a time, test thoroughly, then repeat on the next.

Again, it’s important you make sure to copy across code from both the community and local code pools, and ensure you check other directories, such as js, lib, media and skin.

Switch over the database

All changes undertaken so far have involved the Magento version 1.9.3.6’s database, which is the database that will contain no order, customer or product data because it’s from the new Magento instance set up from the first step. All the data from your existing Magento store will be from version 1.6.1.

Without needing to carry out the long winded process of exporting all the data from Magento 1.6.1, and then importing it into the 1.9.3.6 database, you can simply change the database configuration within the app/etc/local.xml file within the 1.9.3.6 codebase.

Change the <dbname> node in this file to the name of the database being used for the 1.6.1 version, clear the caches and refresh any page on the 1.9.3.6 store.

This will trigger the database upgrade to begin, and will involve all the core Magento modules being upgraded to the versions specified in each modules’ config.xml configuration file.

Depending on how many modules there are (which depends on your Magento version or whether you’re using Magento Commerce edition) depends on amount of time Magento will take to run the database upgrade. It has been known to take a few hours, so sit tight if your Magento store looks like it’s taking forever to load.

After the upgrade has finished, check the website for any errors, and if all is well, your version 1.6.1 database will become a version 1.9.3.6 database, and you won’t have to do any exporting and importing of data within your store!

Conclusion

Although this is a very rough guide on how to upgrade Magento 1, the steps involved are in a logical order, and allow you to crucially fix any issues with custom themes or modules before running the database upgrade.

Upgrading Magento 1 is no easy task, and requires time and effort. Be sure to backup your codebase and database prior to doing so, and take great care when running through the steps!

Note: This article is based on Magento Open Source version 1.9.3.