Magento 2 – Get Customer Details by Wishlist Product ID

customermagento2wishlist

A list of products was added to wish-list by the number of customers and I need to know that which customer was added a particular product to the wish-list, based on the product id.

I need to get the customer details or at-least a customer id based on the product id.

Best Answer

Get data by Item ID

private $wishlist;

public function __construct(
    ...
    \Magento\Wishlist\Model\Wishlist $wishlist
) {
    $this->wishlist = $wishlist;
    ...
}

...
$item_id= 1;
$wishlistItem_collection = $this->wishlist->getItem($item_id);

This will return Item data collection including customer ID.

Wishlist Model

Related Topic