Skip to content

Instantly share code, notes, and snippets.

@Schrank
Created December 27, 2014 12:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Schrank/8aff4cc624b665a16705 to your computer and use it in GitHub Desktop.
Save Schrank/8aff4cc624b665a16705 to your computer and use it in GitHub Desktop.
Get magento XML configuration for default, websites and stores
<?php
// app/code/local/Ikonoshirt/Shared/Model/Adminhtml/
class Ikonoshirt_Shared_Model_Adminhtml_ConfigAsXml
extends Mage_Core_Model_Config_Data
{
protected function _afterLoad()
{
/** @var $xml Mage_Core_Model_Config */
$xml = Mage::getConfig();
$xml->loadDb();
/** @var $result Mage_Core_Config_Element[] */
$result
= $xml->getXpath('/config/default | /config/websites | /config/stores');
$output
= <<<XML
<config>
<default>
{$result[0]->asNiceXml()}
</default>
<websites>
{$result[1]->asNiceXml()}
</websites>
<stores>
{$result[2]->asNiceXml()}
</stores>
</config>
XML;
$this->setValue($output);
}
protected function _beforeSave()
{
$this->setValue('');
}
}
<?xml version="1.0" ?>
<!-- app/code/local/Ikonoshirt/Shared/etc/system.xml -->
<config>
<tabs>
<ikonoshirt translate="label" module="ikonoshirt_pbkdf2">
<label>Ikonoshirt</label>
<sort_order>506</sort_order>
</ikonoshirt>
</tabs>
<sections>
<ikonoshirt_shared translate="label" module="ikonoshirt_pbkdf2">
<label>Misc</label>
<tab>ikonoshirt</tab>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<config translate="label" module="ikonoshirt_shared">
<label>Config</label>
<expanded>1</expanded>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<save_config translate="label comment" module="ikonoshirt_pbkdf2">
<label><![CDATA[Get config as XML]]></label>
<frontend_type>textarea</frontend_type>
<backend_model>ikonoshirt_shared/adminhtml_configAsXml</backend_model>
<sort_order>5</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</save_config>
</fields>
</config>
</groups>
</ikonoshirt_shared>
</sections>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment