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_Catalog_Tag extends Mage_Rss_Block_Abstract
00035 {
00036 protected function _construct()
00037 {
00038
00039
00040
00041 $this->setCacheKey('rss_catalog_tag_'.$this->getStoreId());
00042 $this->setCacheLifetime(600);
00043 }
00044
00045 protected function _toHtml()
00046 {
00047
00048 $storeId = $this->_getStoreId();
00049 $tagModel = Mage::registry('tag_model');
00050 $newurl = Mage::getUrl('rss/catalog/new');
00051 $title = Mage::helper('rss')->__('Products tagged with %s', $tagModel->getName());
00052 $lang = Mage::getStoreConfig('general/locale/code');
00053
00054 $rssObj = Mage::getModel('rss/rss');
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 = $tagModel->getEntityCollection()
00064 ->addTagFilter($tagModel->getId())
00065 ->addStoreFilter($storeId);
00066
00067 $product = Mage::getModel('catalog/product');
00068
00069 Mage::getSingleton('core/resource_iterator')
00070 ->walk($_collection->getSelect(), array(array($this, 'addTaggedItemXml')), array('rssObj'=> $rssObj, 'product'=>$product));
00071
00072 return $rssObj->createRssXml();
00073 }
00074
00075 public function addTaggedItemXml($args)
00076 {
00077 $product = $args['product'];
00078 $product->unsetData()->load($args['row']['entity_id']);
00079 $description = '<table><tr>'.
00080 '<td><a href="'.$product->getProductUrl().'"><img src="'. $this->helper('catalog/image')->init($product, 'thumbnail')->resize(75, 75) .'" border="0" align="left" height="75" width="75"></a></td>'.
00081 '<td style="text-decoration:none;">'.$product->getDescription().
00082 '<p> Price:'.Mage::helper('core')->currency($product->getFinalPrice()).'</p>'.
00083 '</td>'.
00084 '</tr></table>';
00085 $rssObj = $args['rssObj'];
00086 $data = array(
00087 'title' => $product->getName(),
00088 'link' => $product->getProductUrl(),
00089 'description' => $description,
00090
00091 );
00092 $rssObj->_addEntry($data);
00093 }
00094 }