Magento - Product Collection with the current user's Wishlist -


within magento php controller, how can product collection containing products listed in logged in user's (ie current user's) wishlist.

i getting wishlist using:

$wishlist = mage::getmodel('wishlist/wishlist')->loadbycustomer(mage::getsingleton('customer/session')->getcustomer()); 

and contains correct number of items.

but product collection. have tried:

$productcollection = $wishlist->getproductcollection(); 

and

$productcollection = $wishlist->getproductcollection()->addattributetoselect('id')->load(); 

but product collection has length of 0.

how product collection?

you can use getwishlistitemcollection (see link more details) off wishlist helper return collection of items, need product item.

i have been using following code create associative array of products, use determine if product displaying in list page in wishlist...hopefully help:

public function getwishlist() {     $_itemcollection = mage::helper('wishlist')->getwishlistitemcollection();     $_itemsinwishlist = array();      foreach ($_itemcollection $_item) {         $_product = $_item->getproduct();          $_itemsinwishlist[$_product->getid()] = $_item;     }      return $_itemsinwishlist;    }  

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -