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_Category extends Mage_Rss_Block_Abstract
00035 {
00036 protected function _construct()
00037 {
00038
00039
00040
00041 $this->setCacheKey('rss_catalog_category_'
00042 .$this->getRequest()->getParam('cid').'_'
00043 .$this->getRequest()->getParam('store_id')
00044 );
00045 $this->setCacheLifetime(600);
00046 }
00047
00048 protected function _toHtml()
00049 {
00050 $categoryId = $this->getRequest()->getParam('cid');
00051 $storeId = $this->_getStoreId();
00052 $rssObj = Mage::getModel('rss/rss');
00053 if ($categoryId) {
00054 $category = Mage::getModel('catalog/category')->load($categoryId);
00055 if ($category && $category->getId()) {
00056 $layer = Mage::getSingleton('catalog/layer')->setStore($storeId);
00057
00058 $category->setIsAnchor(true);
00059 $newurl = $category->getUrl();
00060 $title = $category->getName();
00061 $data = array('title' => $title,
00062 'description' => $title,
00063 'link' => $newurl,
00064 'charset' => 'UTF-8',
00065 );
00066
00067
00068 $rssObj->_addHeader($data);
00069
00070 $_collection = $category->getCollection();
00071 $_collection->addAttributeToSelect('url_key')
00072 ->addAttributeToSelect('name')
00073 ->addAttributeToSelect('is_anchor')
00074 ->addAttributeToFilter('is_active',1)
00075 ->addIdFilter($category->getChildren())
00076 ->load()
00077 ;
00078 $productCollection = Mage::getModel('catalog/product')->getCollection();
00079
00080 $currentyCateogry = $layer->setCurrentCategory($category);
00081 $layer->prepareProductCollection($productCollection);
00082 $productCollection->addCountToCategories($_collection);
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 $category->getProductCollection()->setStoreId($storeId);
00097
00098
00099
00100 $_productCollection = $currentyCateogry
00101 ->getProductCollection()
00102 ->addAttributeToSort('updated_at','desc')
00103 ->setCurPage(1)
00104 ->setPageSize(50)
00105 ;
00106
00107 if ($_productCollection->getSize()>0) {
00108 foreach ($_productCollection as $_product) {
00109 $final_price = $_product->getFinalPrice();
00110 $description = '<table><tr>'.
00111 '<td><a href="'.$_product->getProductUrl().'"><img src="' . $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(75, 75)
00112 .'" border="0" align="left" height="75" width="75"></a></td>'.
00113 '<td style="text-decoration:none;">'.$_product->getDescription().
00114 '<p> Price:'.Mage::helper('core')->currency($_product->getPrice()).
00115 ($_product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : '').
00116 '</p>'.
00117 '</td>'.
00118 '</tr></table>'
00119 ;
00120 $data = array(
00121 'title' => $_product->getName(),
00122 'link' => $_product->getProductUrl(),
00123 'description' => $description,
00124 );
00125
00126 $rssObj->_addEntry($data);
00127 }
00128 }
00129 }
00130 }
00131 return $rssObj->createRssXml();
00132
00133 }
00134 }