Magento: how do I access custom variables in PHP?

前端 未结 6 918
清歌不尽
清歌不尽 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:41

    Note: A custom variable might have different values for different stores.

    So to access store specific value for the custom variable with the code custom_variable_code

    Use this:

    $storeId = Mage::app()->getStore()->getId();
    
      $custom_variable_text = Mage::getModel('core/variable')->setStoreId($storeId)
                              ->loadByCode('custom_variable_code')
                              ->getValue('text');
    
      $custom_variable_plain_value = Mage::getModel('core/variable')->setStoreId($storeId)
                                    ->loadByCode('custom_variable_code')
                                    ->getValue('plain');
    
      $custom_variable_html_value = Mage::getModel('core/variable')->setStoreId($storeId)
                                    ->loadByCode('custom_variable_code')
                                    ->getValue('html');
    

提交回复
热议问题