1
votes

When a visitor add a product to their basket, they're redirected to their shopping cart. However, this takes a "302 Moved Temporarily" redirect to get there.

If I use Firebug to examine what happens, I cannot figure out where this 302 is needed for. Furthermore, this 302 redirect takes for my server 1 sec (!) to find the new location... Since the whole page is loaded within 4 seconds so 1 second is too much :)

The steps that happen are from the view of a visitor:

1) add to cart

2) http://domain.com/checkout/cart/add/uenc/aHR0cDovL3Rlc3Quc3BlZWwtcGxlemllci5ubC9jaG9jb2xhZGUtZHVpbS1pLWxpa2UuaHRtbA,,/product/6/form_key/vJNUzVWejuquURfw/?form_key=vJNUzVWejuquURfw&product=6&qty=1&related_product= (this gives a 302 Redirect)

3) http://domain.com/checkout/cart/ (this gives a 200 response, which is ok)

Where should I look so I can prevent this 302 redirect? - already checked .htaccess - info.phtml for formkey variable in folder ./template/checkout/onepage/review

Any help would be great ;)

2

2 Answers

1
votes

That url is supposed to give a 302 redirect.
The add to cart action (Mage_Checkout_CartController::addAction) does not have an output itself.
It just adds the product to the cart and then redirects either to the cart page or back to the product page depending on how you set up your magento instance (see what @Rinda put in another answer).
So you cannot avoid this redirect, you can just decide where it should redirect.

In general, this is a good practice for pages that handle a post request. It's not ok to have output when handing a post request. The user might refresh the page and in this case the action will be performed again and you might not want that.
For magento is the same. The add to cart method can be used to add products to the cart via GET or POST (for composite products). So the redirect is needed.

0
votes

You can specify whether to redirect a customer to cart after adding a product to cart via a config setting. Check System -> Configuration -> Sales -> Checkout -> Shopping Cart -> After Adding a Product Redirect to Shopping Cart.

regards