/** * Main entry point when loading a promotion. Collects pertinent * information before sending to monitor to add a promo * impression. In order to be able to track promotions via * Javascript, the outputted HTML of the promotion is modified * here to add a 'banner-alias' parameter to the enclosing HTML * node. * * @name viewPromotion * @param observer $observer */ public function viewPromotion($observer) { $block = $observer->getBlock(); $className = get_class($block); if ($className == 'Enterprise_Banner_Block_Widget_Banner') { $alias = $block->getBlockAlias(); $transport = $observer->getTransport(); $html = $transport->getHtml(); $modifiedHtml = preg_replace('/(^<\\w+\\s+)/', '$1 banner-alias="' . $alias . '" ', $html); $transport->setHtml($modifiedHtml); foreach ($block->getBannerIds() as $id) { $banner = Mage::getModel('enterprise_banner/banner')->load($id); $this->monitor->addPromoImpression($banner, $alias); } } }