Public Member Functions | |
addNewItemXmlCallback ($args) | |
Protected Member Functions | |
_construct () | |
_toHtml () |
Definition at line 34 of file New.php.
_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 New.php.
00037 { 00038 /* 00039 * setting cache to save the rss for 10 minutes 00040 */ 00041 //$this->setCacheKey('rss_catalog_new_'.$this->_getStoreId()); 00042 //$this->setCacheLifetime(600); 00043 }
_toHtml | ( | ) | [protected] |
Render block HTML
Reimplemented from Mage_Core_Block_Template.
Definition at line 45 of file New.php.
00046 { 00047 $storeId = $this->_getStoreId(); 00048 00049 $newurl = Mage::getUrl('rss/catalog/new'); 00050 $title = Mage::helper('rss')->__('New Products from %s',Mage::app()->getStore()->getGroup()->getName()); 00051 $lang = Mage::getStoreConfig('general/locale/code'); 00052 00053 $rssObj = Mage::getModel('rss/rss'); 00054 $data = array('title' => $title, 00055 'description' => $title, 00056 'link' => $newurl, 00057 'charset' => 'UTF-8', 00058 'language' => $lang 00059 ); 00060 $rssObj->_addHeader($data); 00061 /* 00062 oringinal price - getPrice() - inputed in admin 00063 special price - getSpecialPrice() 00064 getFinalPrice() - used in shopping cart calculations 00065 */ 00066 00067 $product = Mage::getModel('catalog/product'); 00068 $todayDate = $product->getResource()->formatDate(time()); 00069 00070 $products = $product->getCollection() 00071 ->setStoreId($storeId) 00072 ->addStoreFilter() 00073 ->addAttributeToFilter('news_from_date', array('date'=>true, 'to'=> $todayDate)) 00074 ->addAttributeToFilter(array(array('attribute'=>'news_to_date', 'date'=>true, 'from'=>$todayDate), array('attribute'=>'news_to_date', 'is' => new Zend_Db_Expr('null'))),'','left') 00075 ->addAttributeToSort('news_from_date','desc') 00076 ->addAttributeToSelect(array('name', 'short_description', 'description', 'price', 'thumbnail'), 'inner') 00077 ->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left') 00078 ; 00079 00080 Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products); 00081 Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products); 00082 //echo $products->getSelect(); 00083 /* 00084 using resource iterator to load the data one by one 00085 instead of loading all at the same time. loading all data at the same time can cause the big memory allocation. 00086 */ 00087 Mage::getSingleton('core/resource_iterator') 00088 ->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('rssObj'=> $rssObj, 'product'=>$product)); 00089 00090 return $rssObj->createRssXml(); 00091 }
addNewItemXmlCallback | ( | $ | args | ) |
Definition at line 93 of file New.php.
00094 { 00095 $product = $args['product']; 00096 //$product->unsetData()->load($args['row']['entity_id']); 00097 $product->setData($args['row']); 00098 $final_price = $product->getFinalPrice(); 00099 $description = '<table><tr>'. 00100 '<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>'. 00101 '<td style="text-decoration:none;">'.$product->getDescription(). 00102 '<p> Price:'.Mage::helper('core')->currency($product->getPrice()). 00103 ($product->getPrice() != $final_price ? ' Special Price:'. Mage::helper('core')->currency($final_price) : ''). 00104 '</p>'. 00105 '</td>'. 00106 '</tr></table>'; 00107 $rssObj = $args['rssObj']; 00108 $data = array( 00109 'title' => $product->getName(), 00110 'link' => $product->getProductUrl(), 00111 'description' => $description, 00112 00113 ); 00114 $rssObj->_addEntry($data); 00115 }