Magento upgrade to 1.5.x or 1.6.x
Posted Sat, 07/09/2011 - 3:26am
As many magento users will know, Magento is no fun to work with-- mainly due to poor community support (the developers help paying customers; i.e. Magento Enterprise ... Only payed support there... Great for business but bad for the average or beginning user...)
Anyhow...
So here's how we do it.
MAKE A BACKUP!
You can skip this step all together, however, please make a backup of everything prior to beginning the upgrade.
Create a test environment somewhere on your server (preferably away from your production installation)
- I usually create a subdomain on another domain and put all the files there.
- Create a new database for this sub-domain.
- Make a backup of the current database in SSH via:
$ mysqldump -u user -p DB_NAME > DB-NAME.sql - Dump the backup you just made into your new database
$ mysql -u user -p DB_NAME < DB-NAME.sql - Change the database settings to point to new database
$ vi app/etc/local.xml - Change your magento URLs
In phpmyadmin go to table 'core_config_data' and change 'web/unsecure/base_url' and 'web/secure/base_url' to new location - REMEMBER to update steps 5-6 after the upgrade is done and upgraded files and database are transferred to the production environment.
Upgrade Magento from 1.4.x to 1.5.x
(Upgrade Magento from 1.3 to 1.6 or 1.4 to 1.6 or 1.5 to 1.6 should be the same process)
1. download the latest version of Magento
$ wget http://www.magentocommerce.com/downloads/assets/1.6.2.0/magento-1.6.2.0.tar.gz
$ wget http://www.magentocommerce.com/downloads/assets/1.5.1.0/magento-1.5.1.0.tar.gz #magento 1.5
$ tar xvfz magento-1.6.2.0.tar.gz
$ tar xvfz magento-1.5.1.0.tar.gz #magento 1.5
2. Disallow access to your site if doing the upgrade on a production environment (this is why you should do this on a test environment)
$ mv .htaccess .htaccess-bkp
$ cp magento/.htaccess .
$ cp .htaccess .htaccess-newIn your new .htaccess change the Order Allow to (at the bottom of file):
#Order allow,deny
#Allow from all
Order deny,allow
Deny from all
Allow from YOUR IP ADDRESS Also, up the memory usage (especially if your database backup is over 500MB--hopefully you're running magento on a dedicated server.)
php_value memory_limit 1024M
php_value max_execution_time 450003. Flush all caches
$ rm -rf var/cache/*
$ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*4. Remove the 'downloader' and 'app/design/frontend/base' directory
$ rm -rf downloader
$ rm -rf app/design/frontend/baseThis is the safest bet so mage/pear doesn't upgrade the wrong installation; trust me this happened to me a couple of times, EVEN after doing ' mage-setup'.
As for the 'base' directory, we remove that because deprecated files exist in there that may cause problems. E.g. One page checkout would not work for anon users, but would work for registered users--and this happened even when all the files were overwritten with magento 1.5.1; meaning magento was picking up deperectated files.
You may also want to clear out redundant theme files in
app/design/frontend/default/YOURTHEME/ AND app/design/frontend/default/default/
The following are the only custom template files I use--it's better to use the least amount possible to avoid future upgrade headaches
- app/design/frontend/default/YOURTHEME/layout/catalog.xml
- app/design/frontend/default/YOURTHEME/template/callouts/left_col.phtml
- app/design/frontend/default/YOURTHEME/template/catalog/product/view.phtml
- app/design/frontend/default/YOURTHEME/template/checkout/success.phtml
- app/design/frontend/default/YOURTHEME/template/page/1column.phtml
- app/design/frontend/default/YOURTHEME/template/page/2columns-left.phtml
- app/design/frontend/default/YOURTHEME/template/page/2columns-right.phtml
- app/design/frontend/default/YOURTHEME/template/page/3columns.phtml
- app/design/frontend/default/YOURTHEME/template/page/html/footer.phtml
- app/design/frontend/default/YOURTHEME/template/page/html/head.phtml
- app/design/frontend/default/YOURTHEME/template/page/html/header.phtml
Same goes for app/design/frontend/default/default/. You want to remove any redundant theme files in there as well. Basically, you'll ONLY want to keep any installed modules you may be using; get rid of the rest.
e.g. I only have the following in app/design/frontend/default/default/:
- app/design/frontend/default/default/etc/widget.xml # I probably don't even need this
- app/design/frontend/default/default/layout/vertnav.xml
- app/design/frontend/default/default/template/vertnav/left.phtml
5. Copy 'downloader' and 'app/design/frontend/base' folder from magento-1.5.1.0
$ cp -a magento/downloader .
$ cp -a magento/app/design/frontend/base/ app/design/frontend/6. Install/get 'mage'.
$ cp magento/mage .
$ chmod 750 ./mageWe do this because the 'pear' method doesn't work anymore--it only does an upgrade up to magento 1.4.2; it won't work upgrading any higher than that.
7. Do the upgrade
** IMPORTANT: make sure your Magento Connect Manager 'Preferred State' is set to 'Stable' **
It's located here: https://www.YOURWEBSITE.com/downloader/index.php?A=settings
$ ./mage mage-setup .
$ ./mage sync --force
$ ./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
$ rm -rf var/cache/* var/session/*
$ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
$ chmod 755 mage
$ php shell/indexer.php reindexall
$ ./mage upgrade-all --force
( NOTE: you may skip this 'upgrade-all' step if you just went ahead and did the following:
<code>
$ yes | cp -Rf magento/* . #this copies over all the magento files you extracted over your current installation8. Visit the home page of your upgraded site. This will trigger the magento upgrade process.
This can take anywhere from 2-30minutes, so be patient. You'll also likely get a browser error before the upgrade is done--don't worry about it, it's normal, and keep waiting...
Do the following and watch mysql process until it stops using up high cpu usage--once it does, you'll know the database upgrade is done.
$ top9. Login to the /admin section of your site and mage sure the version number reflects the version you just upgraded to.
10. Change back your .htaccess to original value
$ cp .htaccess-new .htaccess
11. Set the proper file permissions
$ find . -type f -exec chmod 644 {} \;
$ find . -type d -exec chmod 777 {} \;
$ chmod 750 mage
$ chmod o+w var var/.htaccess app/etc
$ chmod -R o+w media
$ chmod -R 777 var/package var/locks var/report var/export downloader
11. You'll probably want to use a file comparison program to see the difference in template files
- download the latest version from magento connect if possible
- if not possible and you made your own template, then the best thing to do is to DELETE all the unecessary custom template files from your custom template directory, and only keep the crucial ones.
- Following use something like Beyond Compare and file compare between the /base/default
app/design/frontend/base/default
and
/app/design/frontend/default/CUSTOM
12. Fix magento URLs
In the admin interface admin/system_config/edit/section/catalog/ set the following under Search Engine Optimization:
- Autogenerated Site Map: enable
- Popular Search Terms: enable
- Product URL Suffix: blank
- Category URL Suffix: blank
- Use Categories Path for Product URLs: yes # or no depends on who you ask
- Create Permanent Redirect for old URLs if Url key changed: yes
- Page Title Separator: -
- Use Canonical Link Meta Tag For Categories : yes
- Use Canonical Link Meta Tag For Products: yes
Now re-index your url rewrite data in admin/process/list/: Catalog URL Rewrites
Or in SSH:
php shell/indexer.php reindexall
Troubleshooting
Now...
If something went wrong (and it probably did) you have several options.
If a newer version 1.6.x-RC is showing then mage installer grabbed the release candidate stuff instead.
The fix:
$ yes | cp -Rf magento/* .
This will copy the proper version of magento overwriting your current installation
The site just hangs after upgrade (keeps loading for minutes on end):
Be patient, use top in SSH and wait for mysql high CPU usage to go down
PHP Fatal error: Call to a member function toHtml()
edit app/design/frontend/default/YOURTHEME/layout/page.xml
or edit app/design/frontend/default/default/layout/page.xml
Change from
<block type="core/profiler" output="toHtml"/>to:
<block type="core/profiler" output="toHtml" name="core_profiler"/>Cannot login to magento
edit app/code/core/Mage/Core/Model/Session/Abstract/Varien.php and comment out the following:
/*
$cookieParams = array(
\’lifetime\’ => $cookie->getLifetime(),
\’path\’ => $cookie->getPath(),
\’domain\’ => $cookie->getConfigDomain(),
\’secure\’ => $cookie->isSecure(),
\’httponly\’ => $cookie->getHttponly()
);
if (!$cookieParams[\’httponly\’]) {
unset($cookieParams[\’httponly\’]);
if (!$cookieParams[\’secure\’]) {
unset($cookieParams[\’secure\’]);
if (!$cookieParams[\’domain\’]) {
unset($cookieParams[\’domain\’]);
}
}
}
if (isset($cookieParams[\’domain\’])) {
$cookieParams[\’domain\’] = $cookie->getDomain();
}
call_user_func_array(\’session_set_cookie_params\’, $cookieParams);
if (!empty($sessionName)) {
$this->setSessionName($sessionName);
}
*/
Cannot add or update a child row: a foreign key constraint fails: googleshopping_setup
The only remedy I was able to find for my case when upgrading from magento 1.3.2 to 1.6.0 was i needed to do upgrade to magento 1.6.1-rc1.
./mage upgrade-all --force Fresh start: in case something went terribly wrong
Go into phpmyadmin and drop all the tables so your database is empty (you'll get errors in phpmyadmin about foreign keys; that's normal, just repeat till all tables are gone) (i prefer this over the SSH method, cause it's too easy to drop the wrong database by accident)
However, there's a good chance phpMyAdmin may run out of resources when doing this, so you may want to checkout this post instead: Drop all tables in MySQL via SSH
Now re-dump your database backup
$ mysql -u user -p DB_NAME < DB-NAME.sql
and copy over a fresh version of magento over your current install
$ yes | cp -Rf magento/* .
$ rm -rf var/cache/*
$ rm -rf downloader/pearlib/cache/* downloader/pearlib/download/* Visit your site again...
Bonus:
Install Google Base (shopping) vis SSH
$ ./mage install http://connect20.magentocommerce.com/community Mage_GoogleShopping --force
To uninstall an extension:
$ ./mage uninstall http://connect20.magentocommerce.com/community Mage_GoogleShopping --force
If you get a permissions error trying to run './mage'
-bash: ./mage: Permission deniedeasy fix:
chmod 750 ./mageLook here for a complete listing of required Google Base attributes for different product categories: http://www.google.com/support/merchants/bin/answer.py?answer=1344057
Comments
To do this via a hosting
by Garratt - 07/26/2011 - 5:26am
To do this via a hosting service would I just ftp and overwrite the files over?
yeah, that should work.
by duntuk - 08/19/2011 - 9:20pm
yeah, that should work.
Huzzah! 1.6 is finally out,
by Magento 1.6 - 08/25/2011 - 11:47am
Huzzah! 1.6 is finally out, can't wait to see what new bugs are awaiting me this time around. It's always a fun scavenger hunt, like an evil Wheres Waldo!
how are you handling the
by Joel - 08/31/2011 - 10:38am
how are you handling the app/etc/local.xml file that has references back to the old database. Would you want to edit that file to reflect the new database you are about to use/upgrade/?
Joel, I think he already said
by Atlanta ecommerce - 09/02/2011 - 10:16pm
Joel, I think he already said that above (step e). You do have to update that file at that step.
Joel, I did the upgrade
by duntuk - 09/23/2011 - 1:22am
Joel, I did the upgrade method several times using different methods:
I prefer the first method of blocking access to the live site (of course for a site that doesn't have any crazy customization; i do this at off peak hours) , this way i don't need to worry about losing orders because the dev database didn't receive the order information the live did during the upgrade... However, if your magento site has heavy customization, then you'll probably have no choice but to do the dev method... e.g. I have one site that I'm dreading on converting to 1.5 or 1.6 simply because the process is going to take several days.
it was the best magento
by magento developer - 10/28/2011 - 11:46pm
it was the best magento upgrade article so far
This was such a life saver I
by Isis CMS - 11/08/2011 - 5:09pm
This was such a life saver I had to post a big THANK YOU! I had a client that was ready to leave me and you saved me thanks. This upgrade protocol worked perfectly for me. Did I say - thanks?
Thank you for posting this.
by Tom - 11/16/2011 - 8:59pm
Thank you for posting this. What a big help.
would the following strategy
by Evan - 12/01/2011 - 1:12am
would the following strategy work?
1. leave the live site running
2. do the upgrade on a staging site, take as long as you need
3. once you are ready, disable access to the live site and move the orders data to the staging site
4. convert staging to live?
Very nice and helpful
by Creare site - 12/08/2011 - 3:27pm
Very nice and helpful article. Great jobs!
Regards,
Creare site
Thanks for the great
by Relja - 12/23/2011 - 4:37am
Thanks for the great tutorial, I followed it up, but unfortunately my shop is stuck - all database installation processes seem to be finished, but when I try to access any page on my shop the following error appears:
Fatal error: Call to undefined method Mage_Core_Helper_Data::useDbCompatibleMode() in /Applications/XAMPP/xamppfiles/htdocs/shop/app/code/core/Mage/Core/Model/Resource/Setup.php on line 309
The Core_Helper_Data class is in its right place, and it contains the mentioned method.
Do you have any idea what could've gone wrong and how to fix this?
Thanks.
This is exactly what I do.
by Amenemha1 - 01/19/2012 - 10:40am
This is exactly what I do. And so far it tis the best strategy, because if something does now work, all I have to do is
# mv store store-new
# mv store-old store
and the site is working accordingly. You will need 2 MySQL databases to do this on a production environment.
This is a great, great
by Amenemha1 - 01/19/2012 - 10:41am
This is a great, great article on Upgrading Magento to the latest version. Thank you.
This worked for me perfectly.
Thanks a lot for this
by Anonymous - 01/27/2012 - 2:07am
Thanks a lot for this article! Really good.
Just one question: I want to upgrade to 1.6.1 (not the latest 1.6.2 – some 3rd party extension seems not to work with 1.6.2). How to do that?
I downloaded the full zip of 1.6.1 and followed your instructions. Checking in admin, the version is 1.6.2. I then run the command
yes | cp -Rf magento/* .
Now, in admin, the version is 1.6.1. But in Magento Connect "Mage_All_latest" showing 1.6.2 installed ??
Regards, Magnus
Followed this one for a
by Ari - 01/28/2012 - 6:44am
Followed this one for a Magento update, as a reference, and it worked flawlessly. Thanks.
Getting "An error occurred while saving the URL rewrite" in Index Management, everything else great.
I did a "TRUNCATE" on the
by Anonymous - 01/28/2012 - 10:13am
I did a "TRUNCATE" on the table core_url_rewrite – that solved that problem for me. Manage to do a reindex in admin after that.
thanx for this article man. I
by Babymatras - 02/10/2012 - 2:49am
thanx for this article man. I hope I will find my gutts to do an upgrade soon. Im now having 1.4.1 and I m afraid I will mess everything up so these kind of articles are nice!
What is the best way to make a backup?
I am trying to update my
by Fetch Designs - 02/20/2012 - 2:59pm
I am trying to update my Magento store from version v1.4.0.1 to v 1.6.2, but I got stuck on Step 8. When I went to the URL in the browser and after a long time loading I got this error…
Error in file: "/Applications/XAMPP/xamppfiles/htdocs/mysite.local/app/code/core/Mage/Customer/sql/customer_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php" - SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0-147' for key 'UNQ_BY_CUSTOMER'
I tried accessing the site again and it took another chunk of time loading and now all I get is this error…
Error in file: "/Applications/XAMPP/xamppfiles/htdocs/mysite.local/app/code/core/Mage/Catalog/sql/catalog_setup/upgrade-1.6.0.0.1-1.6.0.0.2.php" - SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '27-General' for key 'UNQ_MAG_EAV_ATTR_GROUP_ATTR_SET_ID_ATTR_GROUP_NAME'
Any ideas?
To answer my own question...
by Fetch Designs - 02/20/2012 - 7:56pm
To answer my own question... I tracked this down to the fact that several of my attributes groups with the name "General" were set with a default id of "0". Apparently Magento doesn't like that. I ran the SQL statement below and refreshed the browser and the upgrade continued without a hitch. Thanks for this fantastic walk-through! It was very helpful.
UPDATE `mag_eav_attribute_group`
SET `default_id` = 1
WHERE `attribute_group_name` = "General" AND `default_id` = 0
Excellent article saved us
by Michael Tamesis - 02/21/2012 - 11:05pm
Excellent article saved us from customer wrath! Hit a frustrating problem, though: the mage install script kept hitting a 33MB memory limit part-way through and aborting. After much tweaking of PHP memory limits in php.ini and .htaccess, which made absolutely no difference, I solved the problem by editing the mage script to change the PHP memory limit on the command line PHP call: the last-but one line of "mage" changes from:
-d auto_prepend_file="" -d auto_append_file="" \
to:
-d auto_prepend_file="" -d auto_append_file="" -d memory_limit=512M \
Obviously, change the memory limit value to whatever makes sense for you. I guess this might not work if your hosting configuration prevents the memory limit being over-ridden, but it might be worth a try.
@Ari try this:
by duntuk - 03/03/2012 - 10:02am
@Ari try this: http://www.duntuk.com/magento-cant-reindex-data-through-admin
@Fetch Designs Thanks for the
by duntuk - 03/03/2012 - 10:03am
@Fetch Designs Thanks for the followup. It will probably help someone.
@Michael Tamesis, thank you
by duntuk - 03/03/2012 - 10:05am
@Michael Tamesis, thank you for figuring this out. This will come handy on a shared hosting enviroments where system resources are limited.
This page was a great help to
by Tjark - 03/04/2012 - 9:52am
This page was a great help to me!
@Fetch Designs regarding the SQLSTATE[23000]: Integrity constraint violation error:
I solved mine with this from http://brentwpeterson.blogspot.com/2011/08/magento-errors-sqlstate23000-integrity.html
If you are upgrading your Magento store and you have received this error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
The solution is to modify your /app/etc/config.xml file with the following:
Original statement
SET NAMES utf8
Modified statement
SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;
I also had to do something when I imported the SQL database on a test server:
Add a the beginning of your SQL:
SET AUTOCOMMIT=0;
SET FOREIGN_KEY_CHECKS=0;
And at the end:
SET FOREIGN_KEY_CHECKS=1;
COMMIT;
SET AUTOCOMMIT=1;
DUNTUK - I'm having tons of
by Todd - 03/04/2012 - 3:06pm
DUNTUK - I'm having tons of issues with trying to get this to function (1.4.2 to 1.6.2). Would you like to do this for us? What do you charge? Contact me on info@toggle.co.nz. Cheers, Todd.
@Todd, emailed you from my
by duntuk - 03/05/2012 - 9:24am
@Todd, emailed you from my kakuzen.com email.
Hello duntuk. We have just do
by Lawat - 03/07/2012 - 1:35pm
Hello duntuk.
We have just do update from 1.4.0.1 to 1.6.2.0 and that's fine.
But we have two problems :
First, we can't reindex "Product price"
Second, we can't open a url rewriting in the url rewritting management.
We received this error : Can't retrieve entity config: catalog/product_attribute_group_price
You know that ?
Can you help me ?
sorry for my bad english
Hello duntuk. We have just do
by Lawat - 03/07/2012 - 1:40pm
Hello duntuk.
We have just do update from 1.4.0.1 to 1.6.2.0 and that's fine.
But we have two problems :
First, we can't reindex "Product price"
Second, we can't open a url rewriting in the url rewritting management.
We received this error : Can't retrieve entity config: catalog/product_attribute_group_price
You know that ?
Can you help me ?
sorry for my bad english
Rehello An other
by Lawat - 03/07/2012 - 1:51pm
Rehello
An other problem.
When i want to modify a product, i can't because :"Can't retrieve entity config: catalog/product_attribute_group_price"
You know that problem ?
Thanks a lot for your help
Quentin
I think I may have overlooked
by jason - 03/23/2012 - 9:17am
I think I may have overlooked the preferred setting to stable and did the upgrade. For some reason it was set to beta and now I'm getting a conflict error during the upgrade. How can I fix this?
Hi duntuk I have a online
by jfco - 03/28/2012 - 3:26am
Hi duntuk
I have a online magento 1.4.1.1 and I want to upgrade to latest version of magento. We have some estensions ( WDCA Sweet Tooth Rewards, Amasty Customer Attributes, WEBSHOPWORKS Accordion Menu, WYOMIND Simple Google Shopping).
Could you do the update for us? Price? Time for upgrading?
Thanks and regards.
Michael Tamesis, you saved my
by rami - 03/29/2012 - 9:48pm
Michael Tamesis, you saved my life. after hours and hours. thanks!
Glad it was helpful,
by Michael Tamesis - 04/04/2012 - 10:51pm
Glad it was helpful, Rami.
The production site update hit another snag (apart from taking many, many hours to grind through the logs that were stored in the database, and don't appear to have been regularly cleaned)...
The install script eventually kept failing with an error "SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'report_viewed_product_aggregated_daily' already exists". Solution was to drop the three tables:
report_viewed_product_aggregated_daily
report_viewed_product_aggregated_monthly
report_viewed_product_aggregated_yearly
And then it worked. It seems the script needs all three of these tables to be dropped together: if you drop one, it recreates the others, errors on the one that is missing, and next time around errors on the ones it created last time... sigh :)
It also upgraded to 1.7 RC1 (maybe this had been tagged as Stable?), which was most unhelpful, and while duntuk's comment above to re-copy the 1.6.2 files was helpful, the other half of the story is fixing the resulting database conflicts... see http://www.magentocommerce.com/boards/viewthread/274602/#t381255 and http://www.magereverse.com/diff-version/magento-database-structure-comparison/version/1.7.0.0.beta for assistance.
Hmmm, I'm doing a 1.4.2 ->
by Chris K - 04/07/2012 - 5:18pm
Hmmm, I'm doing a 1.4.2 -> 1.6.2 upgrade and I know that I had stable selected but the
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
command caused the dlownload of several 1.7.0.0-rc1 files as well as other -RC1 files of an older version, example:
Package installed: community/Lib_Js_Calendar 1.51.1.1-rc1
Is this normal?
As I went along, was getting PDO errors when trying to run shell/indexer.php ... I found a reference for when this happens, a website can use a pre-compiled php5-cgi binary. More info: http://www.magentocommerce.com/knowledge-base/entry/installing-magento-on-a-php4-server
Now I'm currently visiting the homepage to get the site updated... It's taking quite a while. Much more than 20 minutes. Then again our database backup was 2.7G uncompressed. :P
I have recently experienced
by twistedindustries - 04/11/2012 - 9:06am
I have recently experienced some of the issues other users here are reporting with the upgrade jumping to RC1 when I made sure 'stable' was selected before I started the upgrade. I have used this method before in the past and it worked just fine. I am trying to upgrade from 1.5.0.1
I did an update to 1.7.0.0
by Ari - 04/30/2012 - 1:23pm
I did an update to 1.7.0.0 following this guide and had some issues with DB update scripts which I simply renamed and let it continue. Other than that, was like silk.
1.7 - Download link: http://www.magentocommerce.com/downloads/assets/1.7.0.0/magento-1.7.0.0.tar.gz
Post new comment