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.

1
  • Did you ever figure this out? Commented Jul 9, 2015 at 17:45

2 Answers 2

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(); 
1
  • 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
    Commented Jul 17, 2014 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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