First of all, this is not a duplicate of some other question on Magento SE.

I am working to build a custom requirement of guest wishlists. I have searched for some help on the Internet and also dug Magento's core module of wishlists but still, I am not able to find the right way to start.

I understand that it can be achieved by using cookies, but I am not able to find which changes I would need to make in core Magento tables and which functions should be pluginized or overridden.

I don't want a complete programmatic solution.

I just want to get some guidance to catch the right direction.

Please help.

2 Answers 2


I'm just give some guidelines for guest wishlist :

You can overrite list.phtml and view.phtml file in your module.

Guest wishlist functionality mostly manage by cookies. So, I would like to suggest you make it by using cookies or localStorage.

Add and remove product in cookie by add or remove wishlist and product should be add in wishlist page.

For make it more friendly, display wishlist product in popup to the user and user can remove from wishlist. Cookie also should be expire after 24 hour.

Hope, It may be helpful for you.

  • thanks for the answer. But I want some more detailed guidance. Jul 23, 2018 at 6:00

Add PLugin on



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <type name="Magento\Wishlist\Controller\Index\Plugin">
        <plugin name="guest_wishlist_plugin" type="Vendor\Module\Plugin\GuestPlugin" sortOrder="10"/>

In your php file Add this Code


use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Session\SessionManagerInterface;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;

class GuestPlugin
     * Name of cookie that holds private content version
    const COOKIE_NAME = 'guest_wishlist';

     * CookieManager
     * @var CookieManagerInterface
    private $cookieManager;

     * @var CookieMetadataFactory
    private $cookieMetadataFactory;

     * @var SessionManagerInterface
    private $sessionManager;

     * @var \Magento\Customer\Model\Session
    protected $customerSession;

     * @var \Magento\Customer\Model\Session
    private $customSession;

    private $resultFactory;

    protected $registry;

    public function __construct(
        Context $context,
        \Vendor\Module\Helper\Data $helper,
        ResultFactory $resultFactory,
        CookieManagerInterface $cookieManager,
        CookieMetadataFactory $cookieMetadataFactory,
        SessionManagerInterface $sessionManager,
        CustomerSession $customerSession
    ) {
        $this->resultRedirectFactory = $context->getResultRedirectFactory();
        $this->customerSession       = $customerSession;
        $this->cookieManager         = $cookieManager;
        $this->cookieMetadataFactory = $cookieMetadataFactory;
        $this->sessionManager        = $sessionManager;
        $this->helper                = $helper;
        $this->resultFactory         = $resultFactory;
    public function beforeBeforeDispatch(
        \Magento\Wishlist\Controller\Index\Plugin $coreSubject,
        \Magento\Framework\App\ActionInterface $subject,
        RequestInterface $request) {
        $obj = $request->getParams();
        if (!$this->customerSession->isLoggedIn()) {
            $cookieValue = explode(', ', $this->cookieManager->getCookie(self::COOKIE_NAME));
            if (empty($cookieValue)) {
                $cookieValue = array();
            array_push($cookieValue, $obj['product']);
            $this->set(implode(', ', $cookieValue), 100);
    private function set($value, $duration = 86400)
        $metadata = $this->cookieMetadataFactory

Hope this will Help You Sorry for Late Reply

  • It is not working. It is redirecting to login page for guest user..
    – aravind
    Nov 19, 2019 at 10:04
  • It's not working.. May 18, 2020 at 12:53

Your Answer

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

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