Magento - Accessing a customer's wishlist
magento
Solution
You're very close to your target.
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();
if (count($wishListItemCollection)) {
$arrProductIds = array();
foreach ($wishListItemCollection as $item) {
/* @var $product Mage_Catalog_Model_Product */
$product = $item->getProduct();
$arrProductIds[] = $product->getId();
}
}
The array variable `$arrProductIds` will now contain the list of all Product IDs that have been wishlisted by that specific Customer.
Problem
I would like to be able to load a customer's wishlist and return the product id's of the products within the list I am using: ``` $wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer); $wishListItemCollection = $wishList->getItemCollection(); ``` The problem is that the arrays in the Item Collection are protected and I can't find any methods to extract the data. Is there another way to do this?