2

I am facing issue adding product in wishlist (magento version 1.9.2.4).

Here is scenario,

Step 1 :- Make sure customer not logged in.

Step 2 :- Go to product list page and click "Add to wishlist"

Step 3 :- it will redirected to login page.

Step 4 :- Now you can check product not added in wishlist.

I have traced patch files and found issue

SUPEE-9767-1.9.2.4\app\code\core\Mage\Customer\Model\Session.php

public function setCustomerAsLoggedIn($customer)
{

$this->setCustomer($customer);
$this->renewSession();
// if we comment following line its working fine
//Mage::getSingleton('core/session')->renewFormKey();
Mage::dispatchEvent('customer_login', array('customer'=>$customer));
return $this;
}

But its not correct solution for it.

Please give better solution than above code.

Thanks,

0

I was provided a custom patch from Magento for this issue, that fixes it for EE 1.14. The only change that I think would be necessary is taking out the check for Enterprise_Pagecache, which I have done in the code below.

The solution is to add an event observer in a local module like the following:

// Model/Observer.php
...
public function replaceFormKeyForWishlistAdd(Varien_Event_Observer $observer)
{

    $formKey = Mage::getSingleton('core/session')->getFormKey();

    $session = Mage::getSingleton('customer/session');
    $beforeWishlistRequest = $session->getBeforeWishlistRequest();

    $beforeWishlistRequest['form_key'] = $formKey;
    $session->setBeforeWishlistRequest($beforeWishlistRequest);

    $newBeforeAuthUrl = Mage::getUrl('wishlist/index/add',
        array('product' => $beforeWishlistRequest['product'], 'form_key' => $formKey)
    );
    $session->setBeforeAuthUrl($newBeforeAuthUrl);
    return $this;
}
...

.

// etc/config.xml
...
<events>
    <customer_login>
        <observers>
            <namespace_module>
                <class>namespace_module/observer</class>
                <method>replaceFormKeyForWishlistAdd</method>
            </namespace_module>
        </observers>
    </customer_login>
</events>
...

Here is the patch, which makes these changes in the core: https://github.com/timciep/magento-tools/tree/master/Patches/SUPEE-10123_EE_1.14.0.1_v1.

  • 1
    Its not worked for me after adding your code wish list issue fixed but raised new issue if you create new customer it will redirect you to wish list page instead of customer dashboard same with login customer – shyam Mar 19 '18 at 7:32
  • @shyam please check your admin setting at Configuration > Customers > Customer Configuration > Login Options > Redirect Customer to Account Dashboard after Logging in. – Tim Cieplowski Mar 19 '18 at 14:27
0

I am facing issue adding product in wishlist (magento version 2.2.3).

Here is scenario,

Step 1 :- Make sure customer not logged in.

Step 2 :- Go to product list page and click "Add to wishlist"

Step 3 :- it will redirected to login page.

Step 4 :- Now you can check product not added in wishlist.

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.