Magento: how do I access custom variables in PHP?

前端 未结 6 917
清歌不尽
清歌不尽 2020-12-23 19:18

I am aware of \'Custom Variables\' and how they can be used with {{ }} brackets in email templates as well as in static blocks.

However, I want to use them in templa

6条回答
  •  不知归路
    2020-12-23 19:44

    Been doing this for some time to create various messages that are editable through the admin interface so I don't have to go code digging when the flavor of the moment changes.

    To access the plain value of the custom variable with code custom_variable_code use this:

    Mage::getModel('core/variable')->loadByCode('custom_variable_code')->getValue('plain');
    

    NOTE: Single store doesn't show the store select dropdown for the variable scope. This answer is not technically correct, in order to future-proof yourself in case of having multiple stores --> Please see @Mark van der Sanden answer below and give him an upvote.

提交回复
热议问题