It is always better to work on a separate database while upgrading. And also it is wise to do it in local system first for sure rather than putting the site offline during upgrade process. It is not only because we are not sure but Magento does not have its own formal steps to upgrade. So dump the existing old database and import in new database name.
Steps:
I did the following steps to upgrade Magento 1.4.2.0 to 1.6.1.0:
- - Installed fresh 1.6 Magento with fresh sample data (sample data should also be the latest 1.6 version).
- - Re-indexed all the items from back end of installed latest Magento 1.6.
- - Disabled all the cache from Magento back end.
- - Flushed/deleted all the Magento cache.
rm -rf var/cache/* var/session/* rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
- - Prevent unique check while upgrading by changing file app/etc/config.xml
SET NAMES utf8; To
SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0; - - To trace the errors, I renamed the errors/local.xml.sample to errors/local.xml.
- - Edited the app/etc/local.xml to connect to the old database.
- - I was working in Ubuntu, so in terminal, I ran the following command in the Magento 1.6 installed root directory.
php index.php
(If in case of windows just hit the Magento home URL in the browser and wait till it ends)
The above steps are standard steps for all of the Magento upgrades. But troubleshooting may vary depending upon the Magento system, version, extensions used, data, extra attributes added, etc.
Troubleshooting while upgrading:
Problem:
First of all I encountered the error of it failed renaming the core_url_rewrite table. I don’t know why does it really needed to rename it but the error was on renaming it. I tried several times but I always found the same error with “core_url_rewrite” table. I was almost stopped here. There was nothing except pulling the hair out even after a many times of googling.
The error was with that table and I tried by trunctating the table but no luck. Next I tried by dropping the table but again no luck.
Solution:
I droped the table from old table and imported the structure of the table from new 1.6.1.0 database and tried to upgrade again then it worked for me. You do not have to worry about the data in this table because while reindexing, the data will be filled out again.
Problem:
Secondly, there was an error for customer integrity constraint violation.
Solution:
I compared the structure of customer_entity (of new and old database) and found “website_id and email” should be unique in new structure. Checked if there are duplicate entry with those two fields:
SELECT * FROM `customer_entity` GROUP BY website_id,email HAVING COUNT(entity_id)>1
Found one email address was duplicate for the same website and I deleted one.
Then again ran the command :
php index.php
It took around 1 hour but this time there was no message. That means my upgrade has been done
Then flushed the cache again!
Change the base URLs in the “core_config_data” table for the path “web/secure/base_url” and “web/unsecure/base_url”.
Reindexing:
Before visiting the site, don’t forget to reindex.
php shell/indexer.php --reindexall
Again flushed the cache.
rm -rf var/cache/* var/session/* rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
Then I visited the admin site. I was able to login to the admin with new version of Magento.
I did not stop here. Not to take long breath yet. Now I had to check each and every menus available in Magento back end. All were working fine but product edit page was with fatal error and order detail view page was with broken design but no error found.
After some research and study about modules used in the old database, extra attributes used in old version, I thought I had to delete all the attributes and module related data.
I tried my best to search the modules related data and attributes in the database and remove them. I had removed some attributes, I had updated some attributes which has used models from “eav_attribute” table. And I had to remove the modules setup data from “core_resource” table.
Search:
SELECT * FROM `eav_attribute` WHERE `attribute_code` like 'aw_%'; SELECT * FROM `eav_attribute` WHERE `attribute_code` like 'bcp_%';
Set all the models that attribute calls to NULL and remove the attribute from being System Attribute (`is_user_defined`=1) so that it can be removed from the admin Attribute Manager.
UPDATE `eav_attribute` SET `attribute_model`=NULL, `backend_model`=NULL, `frontend_model`=NULL, `source_model`=NULL, `is_user_defined`=1 WHERE `attribute_code` like 'aw_%';
For another extension:
UPDATE `eav_attribute` SET `attribute_model`=NULL, `backend_model`=NULL, `frontend_model`=NULL, `source_model`=NULL, `is_user_defined`=1 WHERE `attribute_code` like 'bcp_%';
I also removed those extensions entry from “core_resource” table.
DELETE FROM `core_resource` WHERE `code` = 'awall_setup' DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'bcp_setup'
Do not forget to flush the cache again before running the site.
rm -rf var/cache/* var/session/* rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
So in my case, specially the AW extensions and their attributes were the cause of the error in product listing and order view page.
Hope these steps will help the people who are really desparate to upgrade Magento systems and having trouble. I believe at least some of the steps and troubleshooting tips will help someone.
Enjoy!!