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 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.