Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

How to Get Multiple Wishlist Data by Wishlist Name in Magento 2 Enterprise?

As you know, in Magento 2 enterprise edition, customers can create multiple wishlists at their convenience. With multiple wishlists, users can easily categorize and organize their desired products. It also allows them to share specific lists with friends or family conveniently.

How to Get Multiple Wishlist Data by Wishlist Name in Magento 2 Enterprise?
Written by
JKJigar Karangiya
Published
Reading time
1 min read

Jigar Karangiya · · 1 min read

Today we will talk about, How to get multiple wishlist data by wishlist name in the magento2 enterprise edition project.

As you know, in Magento 2 enterprise edition, customers can create multiple wishlists (opens in new tab) at their convenience. With multiple wishlists, users can easily categorize and organize their desired products. It also allows them to share specific lists with friends or family conveniently.

We can easily fetch wishlists by specific customer and wishlist name programmatically.

We can achieve this using Magento\Wishlist\Model\ResourceModel\Wishlist\CollectionFactory.

One customer is logged in and has a “Vacation Wants” wishlist. Let’s see how we can get this wishlist data programmatically.

Figure 01Magento 2 Enterprise Edition - Multiple Wishlist
Magento 2 Enterprise Edition - Multiple Wishlist

We will create a function named getCustomerWishListByName() and specify 2 parameters: customerId and Wishlist Name.

php
<?php
namespace Jigar\Tutorials\Block;
 
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Wishlist\Model\Wishlist;
use Magento\Wishlist\Model\ResourceModel\Wishlist\CollectionFactory;
 
/**
 * Class to load customer wish list by name.
 */
class Example
{
    /** @var CollectionFactory */
    private $wishlistCollectionFactory;
    
    /**
     * @param CollectionFactory $wishlistCollectionFactory
     */
    public function __construct(CollectionFactory $wishlistCollectionFactory)
    {
        $this->wishlistCollectionFactory = $wishlistCollectionFactory;
    }
 
    /**
     * Load customer wish list by name.
     *
     * @param int $customerId
     * @param string $wishListName
     * @return Wishlist
     * @throws NoSuchEntityException if wish list with provided name for customer doesn't exist.
     */
    public function getCustomerWishListByName(int $customerId, string $wishListName): Wishlist
    {
        $wishListCollection = $this->wishlistCollectionFactory->create();
 
        $wishList = $wishListCollection->filterByCustomerId($customerId)
            ->addFieldToFilter('name', $wishListName)->getFirstItem();
 
        if (!$wishList->getWishlistId()) {
            throw NoSuchEntityException::doubleField('customer_id', $customerId, 'name', $wishListName);
        }
 
        return $wishList;
    }
}

In your template file or any suitable place, you can call this function and get a wishlist as shown below.

php
<?php
 
$customerId = 1; //Customer Id
$wishlistName = "Vacation Wants"; //Wishlist Name
$wishlist = $block->getCustomerWishListByName($customerId, $wishlistName);
 
foreach ($wishlist->getItemCollection() as $item) {
    echo $item->getProduct()->getName();echo "<br>";
    echo $item->getProduct()->getId();echo "<br>";
}

This will output the wishlist item Name and Product ID, you can get additional product details as per your requirement.

That’s It… I hope this tutorial is helpful.

Please share it with your teammates and friends.

Do not forget to comment on your queries and feedback in the comment box.

You can also check,

Add Yes/No Attribute in Magento 2 programmatically

How to remove/disable add to compare in Magento 2?

How to Show/Hide one field based on another field in UI Component forms in Magento 2?

Keep reading
All posts

01 · 10 min · Shares Adobe Commerce Core

Adobe Commerce Agentic Capabilities, Q4 2026

Five agentic releases for Adobe Commerce: LLM product discovery, Brand Visibility, the Shopper MCP server, Brand Concierge, and Experience Workspace. What each one does, which editions get it, and when.

10 min

03 · 3 min · Shares Adobe Commerce Core

Conditions for Collections in Magento 2

Collections in Magento 2 (Now Adobe Commerce), are among the most powerful tools for retrieving and manipulating data directly from the database.

3 min

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe