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
Post a Comment