Mage_Rss_Block_Catalog_Salesrule Class Reference

Inheritance diagram for Mage_Rss_Block_Catalog_Salesrule:

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 Salesrule.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 Salesrule.php.

00037     {
00038         /*
00039         * setting cache to save the rss for 10 minutes
00040         */
00041         $this->setCacheKey('rss_catalog_salesrule_'.$this->getStoreId().'_'.$this->_getCustomerGroupId());
00042         $this->setCacheLifetime(600);
00043     }

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 46 of file Salesrule.php.

00047     {
00048         //store id is store view id
00049         $storeId = $this->_getStoreId();
00050         $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
00051         //customer group id
00052         $custGroup =   $this->_getCustomerGroupId();
00053 
00054         $newurl = Mage::getUrl('rss/catalog/salesrule');
00055         $title = Mage::helper('rss')->__('%s - Discounts and Coupons',Mage::app()->getStore($storeId)->getName());
00056         $lang = Mage::getStoreConfig('general/locale/code');
00057 
00058         $rssObj = Mage::getModel('rss/rss');
00059         $data = array('title' => $title,
00060                 'description' => $title,
00061                 'link'        => $newurl,
00062                 'charset'     => 'UTF-8',
00063                 'language'    => $lang
00064                 );
00065         $rssObj->_addHeader($data);
00066 
00067         $now = date('Y-m-d');
00068         $_saleRule = Mage::getModel('salesrule/rule');
00069         $collection = $_saleRule->getResourceCollection()
00070                     ->addFieldToFilter('from_date', array('date'=>true, 'to' => $now))
00071                     ->addFieldToFilter('website_ids',array('finset' => $websiteId))
00072                     ->addFieldToFilter('customer_group_ids', array('finset' => $custGroup))
00073                     ->addFieldToFilter('is_rss',1)
00074                     ->addFieldToFilter('is_active',1)
00075                     ->setOrder('from_date','desc');
00076         $collection->getSelect()->where('to_date is null or to_date>=?', $now);
00077         $collection->load();
00078 
00079         $url = Mage::getUrl('');
00080 
00081         foreach ($collection as $sr) {
00082             $description = '<table><tr>'.
00083             '<td style="text-decoration:none;">'.$sr->getDescription().
00084             '<br/>Discount Start Date: '.$this->formatDate($sr->getFromDate(), 'medium').
00085             ( $sr->getToDate() ? ('<br/>Discount End Date: '.$this->formatDate($sr->getToDate(), 'medium')):'').
00086             ($sr->getCouponCode() ? '<br/> Coupon Code: '.$sr->getCouponCode().'' : '').
00087             '</td>'.
00088             '</tr></table>';
00089              $data = array(
00090                 'title'         => $sr->getName(),
00091                 'description'   => $description,
00092                 'link'          => $url
00093                 );
00094             $rssObj->_addEntry($data);
00095         }
00096         return $rssObj->createRssXml();
00097     }


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