如何以编程方式设置 Magento 存储配置数据?
How to set Magento store config data programmatically?
要获取商店配置数据,我会使用以下代码:
$data = Mage::getStoreConfig('my/path/whatever');
现在,我该如何保存到那个节点?我尝试了 Override Magento Config 中 Alans 的建议,但它对我不起作用。
谢谢!
尝试以下操作:
$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
或
$resource = $this->getResourceModel();
$resource->saveConfig(rtrim('my/path/whatever', '/'), 1, 'default', 0);
Empire Solution 是正确的,但请记住在它之后清理缓存。所以使用像
这样的东西
$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
Mage::getModel('core/config')->cleanCache();
要获取商店配置数据,我会使用以下代码:
$data = Mage::getStoreConfig('my/path/whatever');
现在,我该如何保存到那个节点?我尝试了 Override Magento Config 中 Alans 的建议,但它对我不起作用。
谢谢!
尝试以下操作:
$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
或
$resource = $this->getResourceModel();
$resource->saveConfig(rtrim('my/path/whatever', '/'), 1, 'default', 0);
Empire Solution 是正确的,但请记住在它之后清理缓存。所以使用像
这样的东西$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
Mage::getModel('core/config')->cleanCache();