Retrieving configuration values programmatically in Magento 1 is a fundamental task for custom module development and theme customization. The Mage::getStoreConfig() method allows you to fetch global settings, SEO metadata, and store-specific options directly from the system backend.
Getting Default Meta Data
\To programmatically pull global head metadata settings, use the following PHP code snippets:
\To get Default Title:
\$defaultTitle = Mage::getStoreConfig('design/head/default_title');
\ To get Default Description:
\$defaultDescription = Mage::getStoreConfig('design/head/default_description');
\ To get Default Keywords:
\$defaultKeywords = Mage::getStoreConfig('design/head/default_keywords');
\ \
Working with System Configurations
\Magento core settings follow a standard XPath syntax: section_code/group_code/field_code.
To get a specific field value:
\$fieldValue = Mage::getStoreConfig('section_code/group_code/field_code');
\ To get an entire configuration group (returns an array):
\$configArray = Mage::getStoreConfig('section_code/group_code');
\ \
Advanced Contexts: Store Scope & Flags
\1. Retrieve Configuration for a Specific Store View
\By default, the function targets the current active store view. Pass a store ID or store code as the second parameter to target a specific view:
\$storeId = 2; // Store ID integer or Store Code string
$specificConfig = Mage::getStoreConfig('section_code/group_code/field_code', $storeId);
\ 2. Check Boolean/Flag Settings
\When checking yes/no toggle settings (such as checking if a custom module is enabled), use getStoreConfigFlag() for a strict boolean return value:
$isEnabled = Mage::getStoreConfigFlag('section_code/group_code/is_active');
if ($isEnabled) {
\ // Perform custom logic here
}