Updating Magento from 1.7 to 1.9
1.9.1.0 Magento version is here since November 2014. One of our recent clients had a shop since 2012 and they hired us this month to check and update their site.
This means we need to update the core. There is complete information about the general process here. In this post we are going to comment our own update step by step.
Backup
First of all, we created a backup of database and current files. There is a fantastic tutorial where the process is explained here, and the basics steps are:
-
Backup the Magento MySQL Database
You can use phpMyAdmin or the mysqldump tool (if you have SSH access). The syntax is as follows:
mysqldump -h HOST -u USER -p DATABASENAME > FILENAME.sql
Important: Sometimes databases can be really big. There are some ways to clean up a bit to reduce their weight, and they are explained here
-
Transfer all Magento Files
You can use a FTP client such as Filezilla. Or using SSH access you can log on your server -> magento installation directory and archive all the files using the following command:
tar -czif ARCHIVENAME.tar.gz
Download the archive and upload it to the new location. To extract it use the following command in the desired destination folder for the Magento installation:
tar -xzif ARCHIVENAME.tar.gz
-
Adjust the Magento Configuration
Now you should alter the configuration file stored in app/etc/local.xml. The lines you need to alter are:
<host><![CDATA[HOSTNAME]]></host> <username><![CDATA[USER]]></username> <password><![CDATA[PASSWORD]]></password> <dbname><![CDATA[DATABASENAME]]></dbname>
-
Restore the Magento Database
It is strongly recommended to add several options in the MySQL backup file prior to uploading it. The following should be added at the beginning of the SQL file:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; SET NAMES utf8;SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;
The next option should be added at the end of the file after all other queries:
SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT; SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS; SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION; SET SQL_NOTES=@OLD_SQL_NOTES;
You can now import the database using phpMyadmin or via a shell command:
mysql -h HOST -u USER -p DATABASENAME < FILENAME.sql
You should alter the entries for the new domain on the core_config_data table. The values you need to change are in the path column. Change the web/unsecure/base_url and web/secure/base_url to match the new domain name by altering the value column for both records.
Note: Some Mac OS platforms have issues with Magento and others Zend based frameworks. If you finished the migration and are having issues take a look at this post.
Updating
Now we have our files and database copied. It's time to update.
- Take a backup of current database and current 1.7 code. Place maintenance.flag file inside 1.7 code folder to put website offline, to do it simply write on a console:
touch maintenance.flag
- Download latest magento from http://www.magentocommerce.com/download
- Remove all folders and files from your 1.7 code except maintenance.flag (but you should have backup somewhere) and place all folders and files from the 1.9.
- Now from your 1.7 merge your following custom folders into the 1.9
- Community: app/code/community
- Local: app/code/local
- Media
- Your theme or package (merge app/design/frontend/default/ and app/design/frontend/base )
- Custom folders from skin/, both for adminhtml and frontend (merge skin/).
- Copy your custom xml files from app/etc/modules/ to current app/etc/modules/
- Copy your custom xml files from (merge app/etc/ and app/locale)
- Any custom admin theme folder from adminhtml/default/yourtheme.
- Copy your custom folders from adminhtml/default/default/ (1.7) to adminhtml/default/default/ (1.9).
- Custom js files if any from app/js/.
- Be sure that var/session and var/cache are empty in both folders. Merge var/
- If you have a custom .htaccess on the root folder, place it here.
- Now go to app/etc/local.xml. Edit database details there with your database username, password and database name.
- Remove maintenance.flag file and check the site in the browser. It is done.
Notes:
- Some issues can happen on the migration.
- Test if you can login as customer on the shop (a customer test account is always recommended).
- Test the basket.
- Try to make a fake purchase.
- Do not forget the encryption key of the old version. When upgrading the site to new installation, be sure to use the same Encryption Key
- And the most important: NEVER TRY THE MIGRATION DIRECTLY ON YOUR LIVE ENVIRONMENT