/**
  *
  *
  * @return Mage_Core_Block_Abstract
  */
 protected function _createBlock()
 {
     parent::_createBlock();
     /*
      * Sets product ids for a lighter DB Query. We remove and add products back to simulate the order in which they
      * were first viewed.  Due to the small size of the cookie products may cycle through the recently viewed products
      * list more often than normal.
      */
     $this->_block->setProductIds($this->_productIds);
     $_collection = $this->_block->getItemsCollection();
     if (is_object($_collection)) {
         foreach ($this->_productIds as $_productId) {
             $_item = $_collection->getItemById($_productId);
             $_collection->removeItemByKey($_productId);
             if ($_item) {
                 $_collection->addItem($_item);
             }
         }
     }
     return $this->_block;
 }
 protected static function _generateBlockLayoutXML($blockName)
 {
     $engine = Mage::getSingleton('brim_pagecache/engine');
     // get layout sections references our block
     if (self::$_updateCache == null) {
         self::$_updateCache = Mage::app()->getLayout()->getUpdate()->asSimplexml();
     }
     $sections = self::$_updateCache->xpath("//block[@name='{$blockName}'] | //reference[@name='{$blockName}']");
     // convert section into it's own layout.
     $layoutXml = "<layout>";
     foreach ($sections as $section) {
         $layoutXml .= self::_generateSubBlockLayoutXml($section);
     }
     $layoutXml .= "</layout>";
     return $layoutXml;
 }