Magento 读取配置数据
我正在尝试读取自定义模块的配置数据,以根据配置设置启用或禁用它。我正在尝试读取 Observer 中的配置数据,如下所示: $module_state = Mage::helper( 'stopcheckout')->moduleActive();
这是我的 助手。当产品添加到购物车时,我的观察者就会接到电话。但是当我尝试使用上面的代码片段读取配置数据时,我得到一个空白页。以下是 config.xml 和 system.xml 文件。我哪里出错了?谢谢。
I am trying to read config data for a custom module to enable or disable it based on the config setting. I am trying to read the config data in an Observer like this : $module_state = Mage::helper('stopcheckout')->moduleActive();
and here is my helper. My observer gets called when ever a product is added to cart. But i get a blank page when i try to read the config data with the above snipped of code. Here are the config.xml and system.xml files. Where am i going wrong? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的辅助方法不正确,我相信您已经猜到了:-)
尝试一下:
getStoreConfigFlag()
方法始终返回一个布尔值。它将字符串“false”和“0”评估为false
,因此这是合适的,因为adminhtml/system_config_source_yesno
源模型使用 1 和 0 作为存储值。通过 system.xml 字段设置的值传递的参数始终包含三部分:一部分用于
节点,一部分用于
节点,一个用于
节点。Your helper method is not correct, as I'm sure you've guessed :-)
Try this:
The
getStoreConfigFlag()
method always returns a boolean. It evaluates the strings "false" and "0" asfalse
, so this is appropriate because theadminhtml/system_config_source_yesno
source model uses 1 and 0 as the stored values.The parameter that is passed for values set via system.xml fields will always have three parts: one for the
<sections>
node, one for the<groups>
node, and one for the<fields>
node.