Magento 获取系统设置 How to get data from Magento System Configuration

I just wandering on how I can get the configuration data for my custom module. The configuration can be set from the admin system->configuration and how to pull it in frontend?

解决:

$configValue = Mage::getStoreConfig('sectionName/groupName/fieldName');

sectionName, groupName and fieldName are present in etc/system.xml file of your module.

The above code will automatically fetch config value of currently viewed store.

If you want to fetch config value of any other store than the currently viewed store then you can specify store ID as the second parameter to the getStoreConfig function as below:

$storeId = 2; // ID of the store you want to fetch the value of
$configValue = Mage::getStoreConfig('sectionName/groupName/fieldName', $storeId);

或者

$configValue = Mage::getStoreConfig('sectionName/groupName/fieldName',Mage::app()->getStore());

原文: http://stackoverflow.com/a/5893586

 

实例: 获取 system->configuration->Catalog->Frontend->Products per Page on Grid Default Value

Selection_192

$grid_per_page = Mage::getStoreConfig('catalog/frontend/grid_per_page'); 
$grid_per_page_values = explode(',', Mage::getStoreConfig('catalog/frontend/grid_per_page_values'));

 

本文: Magento 获取系统设置 How to get data from Magento System Configuration

 

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.