0

I want to display the products which are contained in the wishlist of a particular customer. Pls can anyone help me in this.

2

1 Answer 1

0

You can use below code

private $wishlist;

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

    ...
    $customer_id = 1;
    $wishlist_collection = $this->wishlist->loadByCustomerId($customer_id, true)->getItemCollection();

    foreach ($wishlist_collection as $item) {
        print_r($item->getProduct()->getName());
    }

Reference link

Your Answer

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

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