4

I followed the trace of a custom variable and I notice that it create entry on core_variable_value and core core_variable as well as in the logging table, I need a custom variable in one of my CMS codes but this needs to be done on the installation so the end user doesn't have to create it, is it possible to do it programatically?

8

Thought this would be useful to share, this is how yo do it on Magento without adding it on any system.xml.

$variable = Mage::getModel('core/variable')
                  ->setCode('variable-code')
                  ->setName('Variable Name')
                  ->setPlainValue(0)
                  ->save();
1
  • Hi :). Do you know how I would implement this in Magento 2? Thanks! – Joshua Flood Feb 8 '18 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.