Example #1
0
 /**
  * Prepare grid collection
  */
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $layout = $this->getLayout();
     $update = $layout->getUpdate();
     $design = Mage::getSingleton('core/design_package');
     $layoutXML = $update->getFileLayoutUpdatesXml('frontend', $design->getPackageName(), $design->getTheme('layout'), 0);
     $xpath = $layoutXML->xpath('//action[@method="setEsi"]');
     foreach ($xpath as $x) {
         $esi = new Varien_Object();
         $handle = $x->xpath('ancestor::node()[last()-2]');
         $handleName = $handle[0]->label ? $handle[0]->label : $handle[0]->getName();
         $parentBlock = $x->xpath('parent::*');
         $parentBlockName = $parentBlock[0]->getAttribute('name');
         $parentBlockDescription = $parentBlock[0]->getAttribute('description');
         $cacheType = $x->params->cache_type ? $x->params->cache_type : "global";
         $esi->setId($parentBlockName);
         $esi->setHandle($handleName);
         $esi->setBlockName($parentBlockName);
         $esi->setDescription($parentBlockDescription);
         $esi->setCacheType($cacheType);
         try {
             $collection->addItem($esi);
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }