Mage_Rss_Block_Catalog_Category Class Reference

Inheritance diagram for Mage_Rss_Block_Catalog_Category:

Mage_Rss_Block_Abstract Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Protected Member Functions

 _construct ()
 _toHtml ()


Detailed Description

Definition at line 34 of file Category.php.


Member Function Documentation

_construct (  )  [protected]

Internal constructor, that is called from real constructor

Please override this one instead of overriding real __construct constructor

Please override this one instead of overriding real __construct constructor

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 36 of file Category.php.

00037     {
00038         /*
00039         * setting cache to save the rss for 10 minutes
00040         */
00041         $this->setCacheKey('rss_catalog_category_'
00042             .$this->getRequest()->getParam('cid').'_'
00043             .$this->getRequest()->getParam('store_id')
00044         );
00045         $this->setCacheLifetime(600);
00046     }

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 48 of file Category.php.

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                 //want to load all products no matter anchor or not
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 //echo "<pre>";
00067 //print_r($data);
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                 /*if ($_collection->count()) {
00085                     foreach ($_collection as $_category){
00086                          $data = array(
00087                                     'title'         => $_category->getName(),
00088                                     'link'          => $_category->getCategoryUrl(),
00089                                     'description'   => $this->helper('rss')->__('Total Products: %s', $_category->getProductCount()),
00090                                     );
00091 
00092                         $rssObj->_addEntry($data);
00093                     }
00094                 }
00095                 */
00096                 $category->getProductCollection()->setStoreId($storeId);
00097                 /*
00098                 only load latest 50 products
00099                 */
00100                 $_productCollection = $currentyCateogry
00101                     ->getProductCollection()
00102                     ->addAttributeToSort('updated_at','desc')
00103                     ->setCurPage(1)
00104                     ->setPageSize(50)
00105                 ;
00106 //echo "<hr>".$_productCollection->getSelect();
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 //print_r($data);
00126                         $rssObj->_addEntry($data);
00127                     }
00128                 }
00129             }
00130         }
00131         return $rssObj->createRssXml();
00132 
00133     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:38 2009 for Magento by  doxygen 1.5.8