<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch_wishlist_index_index">name="wishlist_add_item">
<observer name="MyObserverName" instance="Vendor\Module\Observer\MyObserver" />
</event>
</config>
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
class MyObserver implements ObserverInterface
{
protected $customerSession;
public function __construct(
.................................................
.................................................
\Magento\Customer\Model\SessionFactory $customerSession,
.................................................
.................................................
) {
.................................................
.................................................
$this->_customerSession = $customerSession->create();
.................................................
.................................................
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($this->_customerSession->isLoggedIn()) {
$cusomerid = $this->_customerSession->getId();
print_r($cusomerid);
exit();
}
}
}