Mage_Rss_Block_Catalog_NotifyStock Class Reference

Inheritance diagram for Mage_Rss_Block_Catalog_NotifyStock:

Mage_Rss_Block_Abstract Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 addNotifyItemXmlCallback ($args)

Protected Member Functions

 _construct ()
 _toHtml ()


Detailed Description

Definition at line 34 of file NotifyStock.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 NotifyStock.php.

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

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 45 of file NotifyStock.php.

00046     {
00047         $newurl = Mage::getUrl('rss/catalog/notifystock');
00048         $title = Mage::helper('rss')->__('Low Stock Products');
00049 
00050         $rssObj = Mage::getModel('rss/rss');
00051         $data = array('title' => $title,
00052                 'description' => $title,
00053                 'link'        => $newurl,
00054                 'charset'     => 'UTF-8',
00055                 );
00056         $rssObj->_addHeader($data);
00057 
00058         $_configManageStock = (int)Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
00059         $stockItemWhere = "({{table}}.low_stock_date is not null) "
00060             . " and ({{table}}.low_stock_date>'0000-00-00') "
00061             . " and IF({{table}}.use_config_manage_stock=1," . $_configManageStock . ",{{table}}.manage_stock)=1";
00062 
00063         $product = Mage::getModel('catalog/product');
00064         $collection = $product->getCollection()
00065             ->addAttributeToSelect('name', true)
00066             ->addAttributeToSelect('name', true)
00067             ->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty'=>'qty', 'notify_stock_qty'=>'notify_stock_qty', 'use_config' => 'use_config_notify_stock_qty','low_stock_date' => 'low_stock_date'), $stockItemWhere, 'inner')
00068             ->setOrder('low_stock_date')
00069         ;
00070         $_globalNotifyStockQty = (float) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY);
00071 
00072         /*
00073         using resource iterator to load the data one by one
00074         instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
00075         */
00076         Mage::getSingleton('core/resource_iterator')
00077             ->walk($collection->getSelect(), array(array($this, 'addNotifyItemXmlCallback')), array('rssObj'=> $rssObj, 'product'=>$product, 'globalQty' => $_globalNotifyStockQty));
00078 
00079         return $rssObj->createRssXml();
00080     }

addNotifyItemXmlCallback ( args  ) 

Definition at line 82 of file NotifyStock.php.

00083     {
00084         $product = $args['product'];
00085         $product->setData($args['row']);
00086         $url = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit/', array('id'=>$product->getId(),'_secure' => true,'_nosecret' => true));
00087         $description = Mage::helper('rss')->__('%s has reached a quantity of %s.', $product->getName(),(1*$product->getQty()));
00088         $rssObj = $args['rssObj'];
00089         $data = array(
00090         'title'         => $product->getName(),
00091         'link'          => $url,
00092         'description'   => $description,
00093         );
00094         $rssObj->_addEntry($data);
00095     }


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