Magento – Adding products from wishlist to cart is giving me 404

controllersform-validationmagento-1.8

I am using magento v1.8.1 and foundation template as the basic theme/tempalte.

The problem is:
When I make a wishlist and shared it with the magento default functionality(I haven't done anything to change them)everything is good and the customer get's the email. BUT if you try to add the products through the button "Add all items to shopping cart" it takes me to an 404 page.The button "View all wishlist items" is working fine though..

After investigation I find out that magento is using the same technique that it was using for admin on old versions to check the form_key.

So if you go to Mage/Wishlist/Controller/Abstract.php

There is the function public function allcartAction()
and it has the

if (!$this->_validateFormKey()) {
            $this->_forward('noRoute');
            return;
        }

Which is responsible to redirect if the validation fails.If you comment that out the "add to basket" works fine.
So to sum up: How can I pass the form key? Because I guess that's the problem?It doesn't pass the form key..

Thanks

—————- EDIT ————————–
If you do:

$form     = $this->getRequest()->getParam('code');
        Zend_Debug::dump($form);

you can get the form key.But not if you try form_key..

Best Answer

First, make sure that this is present in your theme, as Ronwe said:

<?php echo $this->getBlockHtml('formkey');?>

This seems to be a JavaScript bug that comes in the default theme, and gets copied into custom themes a lot. In \app\design\frontend[YOUR THEME]\default\template\wishlist\view.phtml above

setLocation(url);

I put

url += '&form_key=' + jQuery('#wishlist-view-form input[name="form_key"]').val();

and it fixed the issue. I hope that helps.

Related Topic