Php 如何通过安装脚本将主题包更改为Magento?
通常,我需要在DB中更改此行的值(表core\u config\u data): (更新类似路径的值) 我的更新脚本应该是这样的Php 如何通过安装脚本将主题包更改为Magento?,php,magento,magento-1.9,Php,Magento,Magento 1.9,通常,我需要在DB中更改此行的值(表core\u config\u data): (更新类似路径的值) 我的更新脚本应该是这样的 /** * Installation script for changing theme config */ $installer = $this; $installer->startSetup(); // Update theme package values $themeConfig = array( 'theme_package_name
/**
* 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();
所以,当我刚接触Magento时,有人能告诉我应该在哪里搜索模型吗?模型来识别这里必须有哪些设置器?我应该使用什么样的代码语法?我相信这可以通过使用
Mage\u Core\u Model\u Config()
类来实现。示例如下:
$configUpdate = new Mage_Core_Model_Config();
$configUpdate->saveConfig('design/theme/template', "mypackage", 'default', 0);
这将专门设置设计主题模板。非常感谢您,道格拉斯·拉德伯恩!你的回答很有帮助。我的部分问题是在MysqlUpdates模块中。本手册帮助安装Magento的升级模块: 这是我最后的代码:
/**
* 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();
/**
* 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();