Magento: Get a custom variable value in a phtml file

I think custom variables were originally designed to be used in emails but I use them within the main site for little bits of information whose value needs to change on a per store/language basis.

This is how you get a custom variable inside a phtml file:


You can create and set these custom variables in the admin via the system>custom variable menu.  Note that you can’t set values for different stores/languages until you have saved your initial value.  Going in to edit it once saved will allow you to change the values per store.

I use this as a sort of cheaters way of having some controllable values available in the admin without creating proper configuration values in modules and that sort of thing.

I hope this is helpful. If it has and has saved you some time, feel free to buy me a beer.

Facebook Comments

Leave a Reply

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

Apply your human brain cells and complete this highly complicated maths problem *