Magento getStoreConfig multistore



我试图获取我在admin中创建的配置,这是core_config_data表

|config_id|scope   |scope_id|path                            |value|
|123      |websites|2       |myappgeneral/current_time/second|3600 |
|124      |websites|3       |myappgeneral/current_time/second|7200 |
|125      |websites|4       |myappgeneral/current_time/second|1800 |

我有 1 页显示这样的所有信息

网站 2 将在 3600 秒内启动

网站 3 将在 7200 秒内启动

网站 4 将在 1800 秒内启动

如何获取值?谢谢

您可以使用

Mage::app()->getWebsite($website_id)
    ->getConfig('myappgeneral/current_time/second') 

$website_id 参数是可选的,默认情况下当前使用的网站。

但通常您需要一个商店视图值,您可以使用

Mage::getStoreConfig('myappgeneral/current_time/second', $store_id)

$store_id 参数是可选的,可能包含商店视图 ID 或商店视图代码,默认情况下使用当前商店视图。

更多信息在这里 - http://alanstorm.com/custom_magento_system_configuration,"检索值"部分

最新更新