How to Get Wishlist ID According to Product ID in Magento

wishlist

I have a product id but i want to know the wishlist id according to that product id.
Is there any way to find that wish list corresponding that productid?

Best Answer

Try this:

$productId =1;
$wishlistItem = Mage::getModel('wishlist/item')->getCollection()
    ->addFieldToFilter('product_id',$productId);
if(count($wishlistItem)) {
    $wishlistIds = $wishlistItem->getColumnValues('wishlist_id');
    print_r($wishlistIds);
}


//OR

if(count($wishlistItem)) {
    echo $wishlistId = $wishlistItem->getFirstItem()->getWishlistId();
}