I'm trying to get the multiple wishlist by customer_id, but not work

protected $wishlistCollectionFactory;


    \Magento\Wishlist\Model\ResourceModel\Wishlist\CollectionFactory $wishlistCollectionFactory


$this->wishlistCollectionFactory = $wishlistCollectionFactory;

actual code in controller

if ($action == "wishlist") {

            $customer_id = $this->customerSession->getCustomer()->getId();
            $wishlistCollection = $this->wishlistCollectionFactory->create()->addFieldToFilter('customer_id', $customerId);;
            $result->setData(['error' => 0,
                    'message' => __('Operation Success'),
                    'wishlistCollection' => json_encode($wishlistCollection)
            return $result;

the output of wishlist is null, anyone know how to get the wishlist collection in commerce edition?

i want to get the all wishlist names.

1 Answer 1


changed to use

    \Magento\Wishlist\Model\Wishlist $wishlistModel


        $wishlist = $this->wishlistModel->getCollection()->addFieldToFilter('customer_id', $customer_id);
        foreach ($wishlist as $list) {
            echo $list->getId().'__'.$list->getName()."<br>";

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.