Observer/Customer/RemoveWishlistItem.php
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $wishlistItem = $observer->getEvent()->getItem();
            $emailWishlist = $this->emailWishlistCollection->create()
                ->getWishlistById($wishlistItem->getWishlistId());

            if ($emailWishlist) {
                $count = $emailWishlist->getItemCount();
                //update wishlist count and set to modified
                $emailWishlist->setItemCount(--$count);
                $emailWishlist->setWishlistModified(1);
                $this->emailWishlistResource->save($emailWishlist);
            }
        } catch (\Exception $e) {
            $this->helper->log((string)$e, []);
        }
    }
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        try {
            $wishlistItem = $observer->getEvent()->getItem();
            $emailWishlist = $this->emailWishlistCollection->create()
                ->getWishlistById($wishlistItem->getWishlistId());

            if ($emailWishlist) {
                $count = $emailWishlist->getItemCount();
                //update wishlist count and set to modified
                $emailWishlist->setItemCount(--$count);
                $emailWishlist->setWishlistModified(1);
                $this->emailWishlistResource->save($emailWishlist);
            }
        } catch (\Exception $e) {
            $this->helper->log((string)$e, []);
        }
    }
public function execute ( \ Magento \ Framework \ Event \ Observer $ observer ) { try { $ wishlistItem = $ observer -> getEvent ( ) -> getItem ( ) ; $ emailWishlist = $ this -> emailWishlistCollection -> create ( ) -> getWishlistById ( $ wishlistItem -> getWishlistId ( ) ) ; if ( $ emailWishlist ) { $ count = $ emailWishlist -> getItemCount ( ) ; //update wishlist count and set to modified $ emailWishlist -> setItemCount ( -- $ count ) ; $ emailWishlist -> setWishlistModified ( 1 ) ; $ this -> emailWishlistResource -> save ( $ emailWishlist ) ; } } catch ( \ Exception $ e ) { $ this -> helper -> log ( ( string ) $ e , [ ] ) ; } }
Delete wishlist item event.
@param \Magento\Framework\Event\Observer $observer
Delete wishlist item event .