4

Until a few minutes ago I thought I understood how Magento xml files (config, layout, system, api, ...) are merged into one big xml that is later used by the application. Apparently I was wrong.
The question came into my mind after trying to find a solution for SOAP v2 catalogProductListOfAdditionalAttributes Uncaught SoapFault exception: Access Denied.
In the solution I found I had to make the Mage_Catalog module depend on one of my custom modules otherwise I would get strange results. Some nodes were not merged. They were overwritten.

I understand that for example these 2 xml sections:

<config>
    <some_node some_attribute="attr_value">Some label</some_node>
</config>

and

<config>
    <some_other_node some_other_attribute="other_attr_value">Other label label</some_node>
</config>

when merged, become

<config>
    <some_node some_attribute="attr_value">Some label</some_node>
    <some_other_node some_other_attribute="other_attr_value">Other label label</some_node>
</config>

But what happens if I have these:

<config>
    <some_node>
        <label>Some label</label>
    </some_node>
</config>

and

<config>
    <some_node attr="value"></some_node>
</config>

I thought that it will become

 <config>
    <some_node attr="value">
        <label>Some label</label>
    </some_node>
</config>

Apparently this does not happen at least for the api.xml files. It may not happen for other types of xmls, but most probably it does because the api.xml files are loaded fia the same method: Mage::getConfig()->loadModulesConfiguration().
After all this talk, here are my questions:
How are the xml files merged? What nodes are overwritten and what nodes are merged?

1 Answer 1

4

In my understanding they are always merged. If the node with attribute came first, it is created with attribute, if the ndoe without attributes came first, it is created without attribute.

I.e. the first <some_node> is used, any further <some_node>s can be understood as references. The children are copied into the first node, but attributes are ignored (unfortunately)

2
  • Aha. So you say that the attributes are overwritten and tags are merged. You might be on to something. I will test this approach and get back to you. Thanks.
    – Marius
    Oct 23, 2014 at 8:54
  • 2
    Yep. You are right. The attributes are not merged. Thanks.
    – Marius
    Oct 23, 2014 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.