0

As we know that Form key feature has been added to new versions of Magento. This affects old themes or modules for adding product to cart, wishlist and placing an order. I faced a situation where a third party module for Brands, users were not able to add the products to cart nor to wishlist. On troubleshooting, I found that, the form key used by the brands module was different than of the normal product listing pages and I also found that the form key used for one category page remains the same for other category pages as well, so its seems it doesn't update for a particular session i guess and our module should has to follow the same.

however, I wrote a piece of code to update form key, in the add to cart url, with valid one using events and hence products were successfully added to cart and wishlist.

My question is:

Is there a general way developed/allowed by the Magento team, so that such third party modules, which are developed to list the products on some basis, are simply forced to follow the valid form key which is used by the default product listings instead of generating a new one?

Edit: The key returned by Mage::getSingleton('core/session')->getFormKey(); for custom product listing is not valid for adding the product to wishlist or cart.

  • Did you ever figure this out? – Nick Rolando Jul 9 '15 at 17:45
1

Need to change the third party module or override the main module because formkey is the key aspect by which any item goes into cart. get it from session and update where third party extension got it.

Mage::getSingleton('core/session')->getFormKey(); 
| improve this answer | |
  • I do use this code, but for third party module the returned form key is different than the one for product listing or product page, and cart controller matches the form key with the one returned for magento pages. Hence add to cart action fails from third party module. – MTM Jul 17 '14 at 13:21
0

Paste this before form closing tag

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

e.g. app/design/frontend/base/default/template/persistent/checkou‌​t/onepage/login.phtm‌​l

See this for more info: Customer Login Doesn't Work in 1.9

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.