Magento:获取“禁用模块输出”的值
Magento 后端允许您禁用每个站点的模块输出。我已经进行了一些谷歌搜索,但不知道如何通过我的代码获取这个值。基本上,当我的模块的输出被禁用时,它工作得很好。但我发现(困难的方式)Magento 不会阻止模块加载每个站点。
因为我正在扩展一些核心类,所以一些构造函数仍在执行。我的想法是检查模块输出是否被禁用。如果是这样,让我的构造函数调用父级的构造函数。如果模块输出已启用,请继续执行我的自定义代码。
我只是不知道如何获取当前站点的这个值(顺便说一句,我是多站点的)。理想情况下,它会是这样的:
$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');
基本上有一行可以获取当前站点的值(如果没有为当前站点指定,则为默认值)。
任何帮助将不胜感激!
编辑:我找到了 core_config_data 表,它似乎存储了此信息。如果需要的话,我可以手动查询它,但我觉得 Magento 会有内置的东西来返回当前商店的值,回退到默认值。
The Magento backend allows you to disable module output per site. I've done some Google searches but can't figure out how to grab this value through my code. Basically when my module's output is disabled that works just fine. But I've discovered (the hard way) that Magento doesn't prevent the module from loading per-site.
Because I'm extending some core classes, some constructors are still being executed. My thought is to check if the module output is disabled. If so, have my constructor call the parent's constructor. If the module output is enabled, proceed with my custom code.
I just can't figure out how to grab this value for the current site (I am multi-sited, BTW). Ideally it would be something like this:
$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');
Basically have a single line that fetches the current site's value (or the default, if not specified for the current site).
Any help would be greatly appreciated!
EDIT: I found the table core_config_data, which appears to store this information. I could manually query it if I had to, but I feel like Magento would have something built-in to return the current store's value, falling back to the default value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它是一个标准配置设置,因此访问它应该与访问任何其他配置设置没有什么不同。你只需要知道这个值的路径是什么。分析数据库我相信这应该可以解决问题:
It is a standard config setting, so accessing it should be no different than accessing any other config setting. You just need to know what is the path to this value. Analysing the DB I believe this should do the trick:
另一个选项是
Mage_Core_Helper_Abstract
有一个isModuleEnabled($moduleName = null)
方法,这意味着您应该能够调用:还有一个
isModuleOutputEnabled ()
方法。查看代码,这些似乎没有被 store/view 过滤,而 @silvo 的方法是。The other option is that the
Mage_Core_Helper_Abstract
has anisModuleEnabled($moduleName = null)
method, which means that you should be able to call:There is also a
isModuleOutputEnabled()
method. Looking at the code, these don't seem to be filtered by store/view, whereas @silvo's method is.