Background
I have taken over the development of a Magento Enterprise website which has a custom theme. When the custom theme was created the base default templates were used rather than the enterprise default templates and so therefore the theme doesn't have any of the enterprise functionality.
I've setup a vanilla Magento Enterprise install which matches the version number used on this site (1.11.1.0) and I'm slowly working through diffing the two sites and adding the functionality back in one module at a time.
However I've run into a hurdle with how the banner functionality works and therefore I am having problems trying to debug what is missing from the custom theme for them to work correctly.
What I do know
The functionality works fine on my vanilla Enterprise site.
There's no XML layout files for the banner module, which makes sense as they are created dynamically within the admin section which allows you to select which page/block you want to insert the banner widgets into.
Using commerce bug and looking at the compiled page layout XML the banner XML nodes are definitely being inserted so are not being created programatically (via PHP) within other templates or blocks.
I've looked right through the banner module and in the observers/events but can't see anything that is of any relevance as to how the nodes are being inserted.
It does seem to be coupled with the Enterprise CMS module.
I've found references to the Banners in the FPC module, but FPC is not in use on this site and those methods are not hit when FPC is disabled.
I've double checked and the module output is not disabled within Admin Advanced.
I'm using the DesignFallbacks module with enterprise/default and that hasn't helped either.
I've setup some banners in the exact same way on the custom site as in the vanilla enterprise site however the compiled XML does not have the banner nodes being inserted.
I've searched across Google and Stack Overflow but information on Enterprise Banners is very limited and what I could find only talks about the admin section and not how they function from the code level.
All this now leads to...
What I'd like to know
How/where the banner XML nodes make their way into the layout XML.
The Mage_Core_Model_Layout_Update
class at app/code/core/Mage/Core/Model/Layout/Update.php
contains the code responsible for loading the package layout XML. Normally, most of this is handled in the fetchFileLayoutUpdates
method.
However, there's a lesser known method in this class named fetchDbLayoutUpdates
. This method loads layout update XML from the database and merges it with the package layout.
public function fetchDbLayoutUpdates($handle)
{
$_profilerKey = 'layout/db_update: '.$handle;
Varien_Profiler::start($_profilerKey);
$updateStr = Mage::getResourceModel('core/layout')->fetchUpdatesByHandle($handle);
if (!$updateStr) {
return false;
}
$updateStr = '<update_xml>' . $updateStr . '</update_xml>';
$updateStr = str_replace($this->_subst['from'], $this->_subst['to'], $updateStr);
$updateXml = simplexml_load_string($updateStr, $this->getElementClass());
$this->fetchRecursiveUpdates($updateXml);
$this->addUpdate($updateXml->innerXml());
Varien_Profiler::stop($_profilerKey);
return true;
}
The Mage::getResourceModel('core/layout')
resource model corresponds with the core_layout_update
table. In Magento Enterprise, this table is where banner related layout updates are stored.
mysql> select * from core_layout_update\G
*************************** 1. row ***************************
layout_update_id: 1
handle: cms_index_index
xml: <reference name="top.container"><block type="enterprise_banner/widget_banner" name="b6d24980179958bad81911d80bce5f36" template="banner/widget/block.phtml"><action method="setData"><name>display_mode</name><value>fixed</value></action><action method="setData"><name>banner_ids</name><value>1</value></action><action method="setData"><name>unique_id</name><value>e2fb0962e605ed01d3759cf531402534</value></action></block></reference>
sort_order: 0
*************************** 2. row ***************************
layout_update_id: 2
handle: cms_index_index
xml: <reference name="footer.before"><block type="enterprise_banner/widget_banner" name="2b2de5c74183936eb4514e860a09e265" template="banner/widget/block.phtml"><action method="setData"><name>display_mode</name><value>fixed</value></action><action method="setData"><name>banner_ids</name><value>2</value></action><action method="setData"><name>unique_id</name><value>1760872fb38c6042c8aee848bf86bf59</value></action></block></reference>
This table isn't specifically for banner updates — it's just that the developers of the Enterprise_Banner module chose to use the functionality of fetchDbLayoutUpdates
to implement their features.