get custom configuration into email template (Magento)

get custom configuration into email template (Magento)

September 22, 2026 · Illustrated author avatarBy Stefan Bogdanescu
get custom configuration into email template (Magento)

Retrieving Custom Configuration Data for Email Templates in Magento

Hello! I understand you’re looking to pull data from your custom configuration into an email template in Magento. Let’s dive right in.

Understanding the Current Setup

You’ve already created a new field called “GST No” under Configuration > General > Store Information. The system.xml code for this is:

<fields>
    <gst_no>
        <label>GST No</label>
        <frontend_type>text</frontend_type>
        <sort_order>31</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
    </gst_no>
</fields>

This is correctly configured to appear in the store’s general settings.

The Challenge: Accessing this Data in Email Templates

You want to use this GST No value in your email templates, like so:

{{var gst_no}}

However, you found that {{config path="general/store_information/gst_no"}} isn’t working as expected. Let’s troubleshoot this.

The Solution: Using Magento’s Core Functions

Magento has built-in functions to retrieve configuration data. Here are a few options:

1. Using Magento’s Singleton Class (Mage)

You can use the Mage::getStoreConfig() function directly in your PHTML templates or PHP files:

<?php echo Mage::getStoreConfig('general/store_information/gst_no'); ?>

This should fetch the GST No value and display it on your page.

2. Using Magento’s Singleton Class with Template Variables

You can set this variable at the controller level and access it from your template:

Controller:

$gstNo = Mage::getStoreConfig('general/store_information/gst_no');
Mage::register('current_gst_no', $gstNo);

Template:

{{var current_gst_no}}

3. Using Magento’s Singleton Class with the app/design Directory

If you’re working with a theme, you can create a custom block that fetches this data:

Block (app/code/local/Namespace/Modulename/Block/Gstno.php):

<?php class Namespace_Modulename_Block_Gstno extends Mage_Core_Block_Template {
    public function getGstNo() {
        return Mage::getStoreConfig('general/store_information/gst_no');
    }
}

Template:

<?php echo $this->getGstNo(); ?>

Best Practices and Further Reading

Remember, using Magento’s core functions is always the recommended approach for tasks like this. You can learn more about these concepts on our blog at https://laravelcompany.com/magento-development.

Always ensure you’re working in a child theme or module to avoid conflicts with future updates.

Conclusion

In summary, to access your custom configuration data (like the GST No field) in email templates:

  1. Use Mage::getStoreConfig('general/store_information/gst_no') directly in PHP files.
  2. Set this as a template variable at the controller level and use it in PHTML templates.
  3. Create a custom block if you’re working with themes.

These methods ensure your data remains secure, follows Magento’s best practices, and is compatible with future updates.

Feel free to explore more about Magento development on our blog for further insights!

Themes Configuration Email Orders

Our network