How to embed magento banner xml nodes in xml layout?

Background

I started developing a Magento Enterprise website that has a custom theme. When the custom theme was created, basic default templates were used, not standard enterprise templates, so the theme does not have any corporate functions.

I installed the Magento Enterprise installation for vanilla, which corresponds to the version number used on this site (1.11.1.0), and I slowly work through the difference between the two sites and add functionality back to one module at a time.

However, I came across an obstacle that the banner functionality works with, and therefore I am having problems trying to debug what is missing from the user theme so that they work correctly.

What i know

Functionality works great on my Vanilla Enterprise website.

There are no XML layout files for the banner module, which makes sense since they are dynamically created in the administration section, which allows you to choose which page / block you want to insert banner widgets.

Using a commerce error and looking at the compiled layout of the XML page, the nodes of the XML banner are definitely inserted, so they are not created programmatically (via PHP) inside other templates or blocks.

I looked right through the banner module and observers / events, but I don’t see anything that might be related to how the nodes are inserted.

It seems to be connected to the Enterprise CMS module.

I found links to banners in the FPC module, but FPC is not used on this site, and these methods did not suffer when FPC is disabled.

I checked twice and the module output is not disabled in Admin Advanced.

I am using the DesignFallbacks module with enterprise / default, and this did not help either.

I installed some banners in exactly the same way on the user site as on the enterprise website, but the banner nodes are not inserted in the compiled XML.

I searched on Google and Stack Overflow, but the information on Enterprise Banners is very limited, and I could only find talk about this section, and not how they function from the code level.

All this now leads to ...

What i would like to know

How / where XML banner nodes are embedded in the XML layout.

+4
source share
1 answer

The Mage_Core_Model_Layout_Update class in app/code/core/Mage/Core/Model/Layout/Update.php contains the code responsible for loading the package XML layout. Usually most of them are handled by the fetchFileLayoutUpdates method.

However, in this class there is a lesser known method called fetchDbLayoutUpdates . This method downloads the XML layout update from the database and combines 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 resource model Mage::getResourceModel('core/layout') corresponds to the core_layout_update table. In Magento Enterprise, this table stores layout updates related to banners.

 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 is not specifically designed for banner updates - it is simply that the developers of the Enterprise_Banner module decided to use the fetchDbLayoutUpdates functions to implement their functions.

+3
source

Source: https://habr.com/ru/post/1481860/


All Articles