Fetching and Updating Magento Config Data

本文介绍了如何通过Magento的内置函数和数据库操作来更新商店配置数据,包括如何使用PHP/MySql进行更新,并提供了实例代码。

Fetching and Updating Magento Config Data

03 10 2011 0
Viet Le Quang

In Magnto, it’s easy to update configuration data for a store through the admin interface, or by going into the database itself and making the changes (after getting your head round EAV). The table core_config_data in particular holds a lot of this information. There is also a way of doing this via PHP/MySql by using Magento’s own inbuilt functions.

The function accepts only a few arguments: saveConfig( pathToData, value, websiteScope, scopeId );

The example below shows updating the default store name, first by initiating the core config model, then by applying the function.

 

$updateconfigdata = new Mage_Core_Model_Config();
$updateconfigdata->saveConfig('general/store_information/name', "My New Store Name", 'default', 0);

 

This could come in useful if you need to make config changes based on user input on the frontend (though no uses come immediately to mind).

It’s easy to get config data using the function getStoreConfig() and entering the path as the only argument.

 

echo Mage::getStoreConfig('general/store_information/name');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值