Fix add to cart (redirect to homepage) bug
Posted on 12. Sep, 2008 by Fido in Development, Magento
Some people have run into a bug (apparently since version 1.1.3) where (not matter the settings in the backend) the users were getting redirected to the home page after they added a product to the cart.
Naturally this won’t be what most people want. (There is the option in the backend to set “After adding a product redirect to shopping cart” to ‘Yes’ or ‘No’ but this bug is ignoring this).
The fix for this bug that has reported some success is as follows:
In app\code\core\Mage\Checkout\Helper\Cart.php
around line 59 change:
//$continueShoppingUrl = $currentCategory->getUrl(); $continueShoppingUrl = $this->_getRequest()->getRequestUri();
To:
$continueShoppingUrl = $currentCategory->getUrl(); //$continueShoppingUrl = $this->_getRequest()->getRequestUri();
I have not tested this myself (Haven’t run into the bug) but this has been reported to work on the forums.
I want to mention that rather than editing Cart.php directly, you should copy it and it’s file structure to the Local folder so you are not hacking into Core code and can revert back at any time.
So, copy Cart.php, add it to: app/code/local/Mage/Checkout/Helper/ , make your changes to your copy of Cart.php and make sure it’s in that new directory. It will override the Core code.




4 Comments
Greg Wessels
02. Oct, 2008
This just saved me a headache. Thanks a ton for this post! Keep up the good work
Justine
02. Apr, 2009
Hey, thanks so much for this. i thought it was us that stuffed up somewhere! My problem is anyone that comes to the site (they don’t even have to add prodructs to the cart) keep getting sent back to the home page!
Sonassi
12. Dec, 2009
There is a few redirect bugs, we are trying to knock them off our list here:
http://www.sonassi.com/knowledge-base/random-redirect-to-homepage-with-magento/
I’ll be sure to add yours to the list!
Random redirect to homepage with Magento | Manchester Magento web design, development, Magento hosting and aftercare :: sonassi
12. Dec, 2009
[...] Fix add to cart (redirect to homepage) bug Last 5 posts in Knowledge BaseSpeeding up the Magento adminSonassi name server accessMigrate a [...]
Leave a reply