Skip to main content
edited title
Link
Stack user
  • 517
  • 1
  • 5
  • 14

How to create custom variable programatically for template in magento 2

Source Link
Stack user
  • 517
  • 1
  • 5
  • 14

How to create custom variable for template in magento 2

With the all searching so far I have found that we can add custom variable using this:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $model = $objectManager->get('Magento\Variable\Model\Variable')->loadByCode('custom-variable-code'); $plain_value = $model->getPlainValue(); 

but I have no idea where to add this and what to do with plain value. Please let me know how can I create custom variable which I can use in my email template globally. Thanks