Magento: migration of static blocks and configuration parameters

To transfer all changes to all environments, I use database update scripts. I use them to create different instances (client, tax settings, etc.), but usually to transfer static blocks and configuration settings.

To migrate static blocks:

<?php
$block = Mage::getModel('cms/block');
$data = array(
   'title' => 'Block title',
   'identifier' => 'block_identifier',
   'content' => 'block content',
   'is_active' => 1,
   'stores' => array(0 => Mage_Core_Model_App::ADMIN_STORE_ID),
);

$block->addData($data);
$block->save();
?>

To migrate settings:

<?php
Mage::getModel('core/config')->saveConfig('design/theme/default', 'theme');
?>

I know that we can change Magento settings through config.xml:

<default>
    <general>
        <store_information>
            <name>My Store</name>
        </store_information>
        <content_staging>
            <block_frontend_stub>home</block_frontend_stub>
        </content_staging>
    </general>
</default>

, , : general/store_information/name
/content _staging/block_frontend_stub db NULL, NULL, xml. , , , Magento, xml. ?

, ? Magento? , :)

+5
2

, , xml, core_config_data. B00MER, Mage_Core_Model_Config::init():

public function init($options=array())
{
    $this->setCacheChecksum(null);
    $this->_cacheLoadedSections = array();
    $this->setOptions($options);
    $this->loadBase();

    $cacheLoad = $this->loadModulesCache();
    if ($cacheLoad) {
        return $this;
    }
    $this->loadModules();
    $this->loadDb();
    $this->saveCache();
    return $this;
}

, loadDb() loadModules().
Mage_Core_Model_Resource_Config::loadToXml().

:

$xmlConfig->setNode('default/' . $r['path'], $value);

- :

$nodePath = sprintf('websites/%s/%s', $websites[$r['scope_id']]['code'], $r['path']);
$xmlConfig->setNode($nodePath, $value);

- :

$nodePath = sprintf('stores/%s/%s', $stores[$r['scope_id']]['code'], $r['path']);
$xmlConfig->setNode($nodePath, $value);

, , .

+4

core_config_data local.xml :

<config>
   <stores>
       <store_code>
            <!-- config value for a store  (web/unsecure/base_url)  -->
            <web>
                <unsecure>
                      <base_url>http://example-magento-store.com</base_url>
               </unsecure>
            </web>
        </store_code>
   </stores>
   <websites>
       <website_code>
            <!-- config value for a website  (web/unsecure/base_url)  -->
            <web>
                <unsecure>
                      <base_url>http://another-example-magento-store.com</base_url>
               </unsecure>
            </web>
        </website_code>
   </websites>
   <default>
      <!-- default config value (web/unsecure/base_url) -->
       <web>
            <unsecure>
                   <base_url>http://default-magento-store.com</base_url>
              </unsecure>
        </web>
   </default>
</config>

: https://twitter.com/IvanChepurnyi/status/111544548806758403

, Magento XML, : Mage_Core_Model_Config

, :

+2

All Articles