00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Rss_Block_Wishlist extends Mage_Core_Block_Template
00035 {
00036 protected function _toHtml()
00037 {
00038 $descrpt = Mage::helper('core')->urlDecode($this->getRequest()->getParam('data'));
00039 $data = explode(',',$descrpt);
00040 $cid = (int)$data[0];
00041
00042 $rssObj = Mage::getModel('rss/rss');
00043
00044 if ($cid) {
00045 $customer = Mage::getModel('customer/customer')->load($cid);
00046 if ($customer && $customer->getId()) {
00047
00048 $wishlist = Mage::getModel('wishlist/wishlist')
00049 ->loadByCustomer($customer, true);
00050
00051 $newurl = Mage::getUrl('wishlist/shared/index',array('code'=>$wishlist->getSharingCode()));
00052 $title = Mage::helper('rss')->__('%s\'s Wishlist',$customer->getName());
00053 $lang = Mage::getStoreConfig('general/locale/code');
00054
00055 $data = array('title' => $title,
00056 'description' => $title,
00057 'link' => $newurl,
00058 'charset' => 'UTF-8',
00059 'language' => $lang
00060 );
00061 $rssObj->_addHeader($data);
00062
00063 $collection = $wishlist->getProductCollection()
00064 ->addAttributeToSelect('url_key')
00065 ->addAttributeToSelect('name')
00066 ->addAttributeToSelect('price')
00067 ->addAttributeToSelect('thumbnail')
00068 ->addAttributeToFilter('store_id', array('in'=> $wishlist->getSharedStoreIds()))
00069 ->load();
00070
00071 $product = Mage::getModel('catalog/product');
00072 foreach($collection as $item){
00073 $product->unsetData()->load($item->getProductId());
00074 $description = '<table><tr>'.
00075 '<td><a href="'.$item->getProductUrl().'"><img src="' . $this->helper('catalog/image')->init($item, 'thumbnail')->resize(75, 75) . '" border="0" align="left" height="75" width="75"></a></td>'.
00076 '<td style="text-decoration:none;">'.
00077 $product->getDescription().
00078 '<p> Price:'.Mage::helper('core')->currency($product->getPrice()).
00079 ($product->getPrice() != $product->getFinalPrice() ? ' Special Price:'. Mage::helper('core')->currency($product->getFinalPrice()) : '').
00080 ($item->getDescription() && $item->getDescription() != Mage::helper('wishlist')->defaultCommentString() ? '<p>Comment: '.$item->getDescription().'<p>' : '').
00081 '</td>'.
00082 '</tr></table>';
00083 $data = array(
00084 'title' => $product->getName(),
00085 'link' => $product->getProductUrl(),
00086 'description' => $description,
00087 );
00088 $rssObj->_addEntry($data);
00089 }
00090
00091 }
00092
00093 } else {
00094 $data = array('title' => Mage::helper('rss')->__('Cannot retrieve the wishlist'),
00095 'description' => Mage::helper('rss')->__('Cannot retrieve the wishlist'),
00096 'link' => Mage::getUrl(),
00097 'charset' => 'UTF-8',
00098 );
00099 $rssObj->_addHeader($data);
00100 }
00101 return $rssObj->createRssXml();
00102 }
00103
00104 }