Magento 2.2.2 - Adding Product to Wishlist doesn't work when user is not logged in The Next CEO of Stack OverflowMagento 2.2.3 CE unable to add/remove item from wishlist?Best Way of Adding Product to WishlistHow to add product to wishlist after login by guest customer?Returning wishlist item collection for currently logged in userMagento 2 - how to redirect to popup login form while add a product to wishlistmagento 2 - Keep a product in a cart while adding it to wishlistProgrammatically add product to wishlist in Magento 2Magento2 Event 'customer_register_success' or 'customer_login' for adding product to WishlistNot able merge guest cart with logged in user cart from programatically loginMagento 2 whishlist does not update in product listing pageWishlist for guest in cart page not working shows “The requested cart item doesn't exist.'” in magento 2

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

Why did early computer designers eschew integers?

What steps are necessary to read a Modern SSD in Medieval Europe?

Can I calculate next year's exemptions based on this year's refund/amount owed?

Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens

Is dried pee considered dirt?

Audio Conversion With ADS1243

Won the lottery - how do I keep the money?

Is it ok to trim down a tube patch?

How to Implement Deterministic Encryption Safely in .NET

Decide between Polyglossia and Babel for LuaLaTeX in 2019

Airplane gently rocking its wings during whole flight

Help! I cannot understand this game’s notations!

Calculate the Mean mean of two numbers

In the "Harry Potter and the Order of the Phoenix" video game, what potion is used to sabotage Umbridge's speakers?

Redefining symbol midway through a document

Reshaping json / reparing json inside shell script (remove trailing comma)

Man transported from Alternate World into ours by a Neutrino Detector

Strange use of "whether ... than ..." in official text

Aggressive Under-Indexing and no data for missing index

Traduction de « Life is a roller coaster »

How to use ReplaceAll on an expression that contains a rule

Is it okay to majorly distort historical facts while writing a fiction story?

What flight has the highest ratio of timezone difference to flight time?



Magento 2.2.2 - Adding Product to Wishlist doesn't work when user is not logged in



The Next CEO of Stack OverflowMagento 2.2.3 CE unable to add/remove item from wishlist?Best Way of Adding Product to WishlistHow to add product to wishlist after login by guest customer?Returning wishlist item collection for currently logged in userMagento 2 - how to redirect to popup login form while add a product to wishlistmagento 2 - Keep a product in a cart while adding it to wishlistProgrammatically add product to wishlist in Magento 2Magento2 Event 'customer_register_success' or 'customer_login' for adding product to WishlistNot able merge guest cart with logged in user cart from programatically loginMagento 2 whishlist does not update in product listing pageWishlist for guest in cart page not working shows “The requested cart item doesn't exist.'” in magento 2










0















Using Custom Theme, when user is not logged in and try to add a product to wishlist, it is served up the login or create an account screen. Once the user logs in, the item user was trying to add to wishlist isn't appearing under My Wishlist in Account Dashboard and it says You have no items in your wish list. So now user has to go back and add.



Although when user is logged in and then try to add a product to wishlist, its working.



How do I add the product upon login?










share|improve this question
























  • github.com/magento/magento2/issues/11825

    – Slimshadddyyy
    Mar 1 '18 at 11:24















0















Using Custom Theme, when user is not logged in and try to add a product to wishlist, it is served up the login or create an account screen. Once the user logs in, the item user was trying to add to wishlist isn't appearing under My Wishlist in Account Dashboard and it says You have no items in your wish list. So now user has to go back and add.



Although when user is logged in and then try to add a product to wishlist, its working.



How do I add the product upon login?










share|improve this question
























  • github.com/magento/magento2/issues/11825

    – Slimshadddyyy
    Mar 1 '18 at 11:24













0












0








0


1






Using Custom Theme, when user is not logged in and try to add a product to wishlist, it is served up the login or create an account screen. Once the user logs in, the item user was trying to add to wishlist isn't appearing under My Wishlist in Account Dashboard and it says You have no items in your wish list. So now user has to go back and add.



Although when user is logged in and then try to add a product to wishlist, its working.



How do I add the product upon login?










share|improve this question
















Using Custom Theme, when user is not logged in and try to add a product to wishlist, it is served up the login or create an account screen. Once the user logs in, the item user was trying to add to wishlist isn't appearing under My Wishlist in Account Dashboard and it says You have no items in your wish list. So now user has to go back and add.



Although when user is logged in and then try to add a product to wishlist, its working.



How do I add the product upon login?







magento2 product wishlist magento2.2.2 custom-theme






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 22 '18 at 14:20







Slimshadddyyy

















asked Feb 22 '18 at 13:53









SlimshadddyyySlimshadddyyy

61511547




61511547












  • github.com/magento/magento2/issues/11825

    – Slimshadddyyy
    Mar 1 '18 at 11:24

















  • github.com/magento/magento2/issues/11825

    – Slimshadddyyy
    Mar 1 '18 at 11:24
















github.com/magento/magento2/issues/11825

– Slimshadddyyy
Mar 1 '18 at 11:24





github.com/magento/magento2/issues/11825

– Slimshadddyyy
Mar 1 '18 at 11:24










1 Answer
1






active

oldest

votes


















2














I have patch for this issue. You need to override these two files.



  1. vendor/magento/module-wishlist/Helper/Data.php


  2. vendor/magento/module-wishlist/Observer/CustomerLogin.php


Override Data.php and CustomerLogin.php with di.xml




app/code/Vendor/Module/etc/di.xml




<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoWishlistHelperData" type="VendorModuleHelperWishlistData" />
<preference for="MagentoWishlistObserverCustomerLogin" type="VendorModuleObserverWishlistCustomerLogin" />
</config>



app/code/Vendor/Module/Helper/Wishlist/Data.php




<?php

namespace VendorModuleHelperWishlist;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkDataFormFormKey;
use MagentoFrameworkAppPageCacheFormKey as PageCacheFormKey;
use MagentoFrameworkSessionConfigConfigInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;


class Data extends MagentoWishlistHelperData

/**
* Refresh and set new form_key in session and cookie
*
* @return $this
*/
public function refreshFormKey()

$beforeWishlistRequest = $this->_customerSession->getBeforeWishlistRequest();

if ($beforeWishlistRequest !== null)

$formKeyData = ObjectManager::getInstance()->get(FormKey::class);

//form_key is already empty
$formKey = $formKeyData->getFormKey();

$sessionConfig = ObjectManager::getInstance()->get(ConfigInterface::class);
$cookieMetadata = ObjectManager::getInstance()->get(CookieMetadataFactory::class)->createPublicCookieMetadata();
$cookieMetadata->setDomain($sessionConfig->getCookieDomain());
$cookieMetadata->setPath($sessionConfig->getCookiePath());
$cookieMetadata->setDuration($sessionConfig->getCookieLifetime());

ObjectManager::getInstance()->get(PageCacheFormKey::class)->set(
$formKey,
$cookieMetadata
);

$beforeWishlistRequest['form_key'] = $formKey;
$this->_customerSession->setBeforeWishlistRequest($beforeWishlistRequest);
$this->_customerSession->setBeforeRequestParams($beforeWishlistRequest);
$this->_customerSession->setBeforeModuleName('wishlist');
$this->_customerSession->setBeforeControllerName('index');
$this->_customerSession->setBeforeAction('add');


return $this;




Now remove generated folder and flush cache






share|improve this answer























  • Hello, how to add wish-list for guest customer ?

    – Aaditya
    Sep 28 '18 at 8:17











  • @Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

    – Nagaraju Kasa
    Jan 2 at 8:57











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f214643%2fmagento-2-2-2-adding-product-to-wishlist-doesnt-work-when-user-is-not-logged%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I have patch for this issue. You need to override these two files.



  1. vendor/magento/module-wishlist/Helper/Data.php


  2. vendor/magento/module-wishlist/Observer/CustomerLogin.php


Override Data.php and CustomerLogin.php with di.xml




app/code/Vendor/Module/etc/di.xml




<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoWishlistHelperData" type="VendorModuleHelperWishlistData" />
<preference for="MagentoWishlistObserverCustomerLogin" type="VendorModuleObserverWishlistCustomerLogin" />
</config>



app/code/Vendor/Module/Helper/Wishlist/Data.php




<?php

namespace VendorModuleHelperWishlist;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkDataFormFormKey;
use MagentoFrameworkAppPageCacheFormKey as PageCacheFormKey;
use MagentoFrameworkSessionConfigConfigInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;


class Data extends MagentoWishlistHelperData

/**
* Refresh and set new form_key in session and cookie
*
* @return $this
*/
public function refreshFormKey()

$beforeWishlistRequest = $this->_customerSession->getBeforeWishlistRequest();

if ($beforeWishlistRequest !== null)

$formKeyData = ObjectManager::getInstance()->get(FormKey::class);

//form_key is already empty
$formKey = $formKeyData->getFormKey();

$sessionConfig = ObjectManager::getInstance()->get(ConfigInterface::class);
$cookieMetadata = ObjectManager::getInstance()->get(CookieMetadataFactory::class)->createPublicCookieMetadata();
$cookieMetadata->setDomain($sessionConfig->getCookieDomain());
$cookieMetadata->setPath($sessionConfig->getCookiePath());
$cookieMetadata->setDuration($sessionConfig->getCookieLifetime());

ObjectManager::getInstance()->get(PageCacheFormKey::class)->set(
$formKey,
$cookieMetadata
);

$beforeWishlistRequest['form_key'] = $formKey;
$this->_customerSession->setBeforeWishlistRequest($beforeWishlistRequest);
$this->_customerSession->setBeforeRequestParams($beforeWishlistRequest);
$this->_customerSession->setBeforeModuleName('wishlist');
$this->_customerSession->setBeforeControllerName('index');
$this->_customerSession->setBeforeAction('add');


return $this;




Now remove generated folder and flush cache






share|improve this answer























  • Hello, how to add wish-list for guest customer ?

    – Aaditya
    Sep 28 '18 at 8:17











  • @Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

    – Nagaraju Kasa
    Jan 2 at 8:57















2














I have patch for this issue. You need to override these two files.



  1. vendor/magento/module-wishlist/Helper/Data.php


  2. vendor/magento/module-wishlist/Observer/CustomerLogin.php


Override Data.php and CustomerLogin.php with di.xml




app/code/Vendor/Module/etc/di.xml




<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoWishlistHelperData" type="VendorModuleHelperWishlistData" />
<preference for="MagentoWishlistObserverCustomerLogin" type="VendorModuleObserverWishlistCustomerLogin" />
</config>



app/code/Vendor/Module/Helper/Wishlist/Data.php




<?php

namespace VendorModuleHelperWishlist;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkDataFormFormKey;
use MagentoFrameworkAppPageCacheFormKey as PageCacheFormKey;
use MagentoFrameworkSessionConfigConfigInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;


class Data extends MagentoWishlistHelperData

/**
* Refresh and set new form_key in session and cookie
*
* @return $this
*/
public function refreshFormKey()

$beforeWishlistRequest = $this->_customerSession->getBeforeWishlistRequest();

if ($beforeWishlistRequest !== null)

$formKeyData = ObjectManager::getInstance()->get(FormKey::class);

//form_key is already empty
$formKey = $formKeyData->getFormKey();

$sessionConfig = ObjectManager::getInstance()->get(ConfigInterface::class);
$cookieMetadata = ObjectManager::getInstance()->get(CookieMetadataFactory::class)->createPublicCookieMetadata();
$cookieMetadata->setDomain($sessionConfig->getCookieDomain());
$cookieMetadata->setPath($sessionConfig->getCookiePath());
$cookieMetadata->setDuration($sessionConfig->getCookieLifetime());

ObjectManager::getInstance()->get(PageCacheFormKey::class)->set(
$formKey,
$cookieMetadata
);

$beforeWishlistRequest['form_key'] = $formKey;
$this->_customerSession->setBeforeWishlistRequest($beforeWishlistRequest);
$this->_customerSession->setBeforeRequestParams($beforeWishlistRequest);
$this->_customerSession->setBeforeModuleName('wishlist');
$this->_customerSession->setBeforeControllerName('index');
$this->_customerSession->setBeforeAction('add');


return $this;




Now remove generated folder and flush cache






share|improve this answer























  • Hello, how to add wish-list for guest customer ?

    – Aaditya
    Sep 28 '18 at 8:17











  • @Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

    – Nagaraju Kasa
    Jan 2 at 8:57













2












2








2







I have patch for this issue. You need to override these two files.



  1. vendor/magento/module-wishlist/Helper/Data.php


  2. vendor/magento/module-wishlist/Observer/CustomerLogin.php


Override Data.php and CustomerLogin.php with di.xml




app/code/Vendor/Module/etc/di.xml




<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoWishlistHelperData" type="VendorModuleHelperWishlistData" />
<preference for="MagentoWishlistObserverCustomerLogin" type="VendorModuleObserverWishlistCustomerLogin" />
</config>



app/code/Vendor/Module/Helper/Wishlist/Data.php




<?php

namespace VendorModuleHelperWishlist;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkDataFormFormKey;
use MagentoFrameworkAppPageCacheFormKey as PageCacheFormKey;
use MagentoFrameworkSessionConfigConfigInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;


class Data extends MagentoWishlistHelperData

/**
* Refresh and set new form_key in session and cookie
*
* @return $this
*/
public function refreshFormKey()

$beforeWishlistRequest = $this->_customerSession->getBeforeWishlistRequest();

if ($beforeWishlistRequest !== null)

$formKeyData = ObjectManager::getInstance()->get(FormKey::class);

//form_key is already empty
$formKey = $formKeyData->getFormKey();

$sessionConfig = ObjectManager::getInstance()->get(ConfigInterface::class);
$cookieMetadata = ObjectManager::getInstance()->get(CookieMetadataFactory::class)->createPublicCookieMetadata();
$cookieMetadata->setDomain($sessionConfig->getCookieDomain());
$cookieMetadata->setPath($sessionConfig->getCookiePath());
$cookieMetadata->setDuration($sessionConfig->getCookieLifetime());

ObjectManager::getInstance()->get(PageCacheFormKey::class)->set(
$formKey,
$cookieMetadata
);

$beforeWishlistRequest['form_key'] = $formKey;
$this->_customerSession->setBeforeWishlistRequest($beforeWishlistRequest);
$this->_customerSession->setBeforeRequestParams($beforeWishlistRequest);
$this->_customerSession->setBeforeModuleName('wishlist');
$this->_customerSession->setBeforeControllerName('index');
$this->_customerSession->setBeforeAction('add');


return $this;




Now remove generated folder and flush cache






share|improve this answer













I have patch for this issue. You need to override these two files.



  1. vendor/magento/module-wishlist/Helper/Data.php


  2. vendor/magento/module-wishlist/Observer/CustomerLogin.php


Override Data.php and CustomerLogin.php with di.xml




app/code/Vendor/Module/etc/di.xml




<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="MagentoWishlistHelperData" type="VendorModuleHelperWishlistData" />
<preference for="MagentoWishlistObserverCustomerLogin" type="VendorModuleObserverWishlistCustomerLogin" />
</config>



app/code/Vendor/Module/Helper/Wishlist/Data.php




<?php

namespace VendorModuleHelperWishlist;

use MagentoFrameworkAppObjectManager;
use MagentoFrameworkDataFormFormKey;
use MagentoFrameworkAppPageCacheFormKey as PageCacheFormKey;
use MagentoFrameworkSessionConfigConfigInterface;
use MagentoFrameworkStdlibCookieCookieMetadataFactory;


class Data extends MagentoWishlistHelperData

/**
* Refresh and set new form_key in session and cookie
*
* @return $this
*/
public function refreshFormKey()

$beforeWishlistRequest = $this->_customerSession->getBeforeWishlistRequest();

if ($beforeWishlistRequest !== null)

$formKeyData = ObjectManager::getInstance()->get(FormKey::class);

//form_key is already empty
$formKey = $formKeyData->getFormKey();

$sessionConfig = ObjectManager::getInstance()->get(ConfigInterface::class);
$cookieMetadata = ObjectManager::getInstance()->get(CookieMetadataFactory::class)->createPublicCookieMetadata();
$cookieMetadata->setDomain($sessionConfig->getCookieDomain());
$cookieMetadata->setPath($sessionConfig->getCookiePath());
$cookieMetadata->setDuration($sessionConfig->getCookieLifetime());

ObjectManager::getInstance()->get(PageCacheFormKey::class)->set(
$formKey,
$cookieMetadata
);

$beforeWishlistRequest['form_key'] = $formKey;
$this->_customerSession->setBeforeWishlistRequest($beforeWishlistRequest);
$this->_customerSession->setBeforeRequestParams($beforeWishlistRequest);
$this->_customerSession->setBeforeModuleName('wishlist');
$this->_customerSession->setBeforeControllerName('index');
$this->_customerSession->setBeforeAction('add');


return $this;




Now remove generated folder and flush cache







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 28 '18 at 10:00









Prince PatelPrince Patel

14.4k65481




14.4k65481












  • Hello, how to add wish-list for guest customer ?

    – Aaditya
    Sep 28 '18 at 8:17











  • @Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

    – Nagaraju Kasa
    Jan 2 at 8:57

















  • Hello, how to add wish-list for guest customer ?

    – Aaditya
    Sep 28 '18 at 8:17











  • @Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

    – Nagaraju Kasa
    Jan 2 at 8:57
















Hello, how to add wish-list for guest customer ?

– Aaditya
Sep 28 '18 at 8:17





Hello, how to add wish-list for guest customer ?

– Aaditya
Sep 28 '18 at 8:17













@Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

– Nagaraju Kasa
Jan 2 at 8:57





@Prince patel can you please help me on this magento.stackexchange.com/questions/256222/…

– Nagaraju Kasa
Jan 2 at 8:57

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f214643%2fmagento-2-2-2-adding-product-to-wishlist-doesnt-work-when-user-is-not-logged%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Sum ergo cogito? 1 nng

419 nièngy_Soadمي 19bal1.5o_g

Queiggey Chernihivv 9NnOo i Zw X QqKk LpB