Reputation: 369
In common I need to change values of this lines in DB (table core_config_data):
(UPDATE value WHERE path like)
design/package/name
design/theme/locale
design/theme/template
design/theme/skin
design/theme/layout
design/theme/default
My update script should look like this.
/**
* Installation script for changing theme config
*/
$installer = $this;
$installer->startSetup();
// Update theme package values
$themeConfig = array(
'theme_package_name' => 'mypackage',
'theme_locale' => 'mytheme',
'theme_template' => 'mytheme',
'theme_skin' => 'mytheme',
'theme_layout' => 'mytheme',
'theme_default' => 'default'
);
// … code to change values
$installer->endSetup();
So, while I’m new with Magento can anyone tell me where I should search for model? Model to recognize what setters must be here? And what syntax of code I should use?
Upvotes: 1
Views: 611
Reputation: 369
Thank you so much, Douglas Radburn! Your answer was helpfull. Partially my problem was in MysqlUpdates module. This manual helps with install-upgrade module for Magento: http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/
So, this is my final code:
/**
* Installation script for changing theme config
*/
$installer = $this;
$installer->startSetup();
// Update theme package values
$themeConfig = array(
'theme_package_name' => 'mypackage',
'theme_locale' => 'mytheme',
'theme_template' => 'mytheme',
'theme_skin' => 'mytheme',
'theme_layout' => 'mytheme',
'theme_default' => 'default'
);
// Update theme package values
$configUpdate = new Mage_Core_Model_Config();
$configUpdate->saveConfig('design/package/name', $themeConfig['theme_package_name'], 'default', 0);
$configUpdate->saveConfig('design/theme/locale', $themeConfig['theme_locale'], 'default', 0);
$configUpdate->saveConfig('design/theme/template', $themeConfig['theme_template'], 'default', 0);
$configUpdate->saveConfig('design/theme/skin', $themeConfig['theme_skin'], 'default', 0);
$configUpdate->saveConfig('design/theme/layout', $themeConfig['theme_layout'], 'default', 0);
$configUpdate->saveConfig('design/theme/default', $themeConfig['theme_default'], 'default', 0);
$installer->endSetup();
Upvotes: 2
Reputation: 808
I believe this can be achieved using the Mage_Core_Model_Config()
class. Example below:
$configUpdate = new Mage_Core_Model_Config();
$configUpdate->saveConfig('design/theme/template', "mypackage", 'default', 0);
This would set the design theme template specifically.
Upvotes: 1