如何通过安装脚本将主题包更改为Magento?

时间:2015-08-18 15:06:57

标签: php magento magento-1.9

通常我需要在DB(table core_config_data)中更改这些行的值:

(UPDATE值WHERE路径之类)

design/package/name
design/theme/locale
design/theme/template
design/theme/skin
design/theme/layout
design/theme/default

我的更新脚本应如下所示。

/**
 * 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的新手,但有人可以告诉我应该在哪里搜索模型吗?模型识别必须在哪里安装者?我应该使用什么语法代码?

2 个答案:

答案 0 :(得分:2)

非常感谢Douglas Radburn!你的回答很有帮助。部分我的问题是在MysqlUpdates模块中。本手册有助于Magento的安装升级模块:http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/

所以,这是我的最终代码:

/**
 * 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();

答案 1 :(得分:1)

我相信这可以使用Mage_Core_Model_Config()类来实现。示例如下:

$configUpdate = new Mage_Core_Model_Config();
$configUpdate->saveConfig('design/theme/template', "mypackage", 'default', 0);

这将专门设置设计主题模板。