magento - Mage::getStoreConfig 始终为我的自定义模块管理选项返回 null

标签 magento module magento-1.7

我有一个模块:app/code/local/Namespace/Resize/

所以我添加了一个通过 Magento 管理禁用/启用选项的选项。

系统 > 配置 > 命名空间 > 调整大小

但是当我尝试访问此选项时,尽管该选项设置为"is",但我总是收到 Mage::getStoreConfig 的 NULL。

Mage::getStoreConfig('resize/settings/enabled', Mage::app()->getStore()->getId());

Mage::getStoreConfig('resize/settings/enabled');

返回NULL

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Resize>
            <version>0.0.1</version>
        </Namespace_Resize>
    </modules>

    <global>
        <helpers>
            <resize>
              <class>Namespace_Resize_Helper</class>
            </resize>
        </helpers>
        <events>
            <catalog_product_save_after>
              <observers>
                <resize>
                  <type>singleton</type>
                  <class>namespace_resize_model_observer</class>
                  <method>catalog_product_save_after</method>
                </resize>
              </observers>
            </catalog_product_save_after>
        </events>
    </global>
</config>

system.xml

<?xml version="1.0" ?>
<config>
    <tabs>
        <resizing module="resize" translate="label">
            <label>Resize</label>
            <sort_order>100</sort_order>
        </resizing>
    </tabs>
    <sections>
        <resize module="resize" translate="label">
            <label>Resize</label>
            <sort_order>200</sort_order>
            <show_in_default>0</show_in_default>
            <show_in_website>0</show_in_website>
            <show_in_store>1</show_in_store>
            <tab>resizing</tab>
            <groups>
                <settings module="resize" translate="label">
                    <label>Settings</label>
                    <sort_order>10</sort_order>
                    <show_in_default>0</show_in_default>
                    <show_in_website>0</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enabled translate="Enable resize">
                            <label>Enabled</label>
                            <comment>Backend Resizing</comment>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <show_in_default>0</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>1</show_in_store>
                        </enabled>
                    </fields>
                </settings>
            </groups>
        </resize>
    </sections>
</config>

adminhtml.xml

<?xml version="1.0" ?>
<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <resize>
                                        <title>Resize Settings</title>
                                    </resize>
                                </children>
                            </config>
                        </children>
                    </system>
                 </children>
            </admin>
        </resources>
    </acl>
</config>

帮助程序应用程序/代码/本地/命名空间/调整大小/Helper/数据

<?php
class Namespace_Resize_Helper_Data extends Mage_Core_Helper_Abstract {

}
  • 模块工作正常

  • 缓存已禁用

  • 我确信该选项已保存,因为我可以看到数据库中已更新的条目。

config id | scope  | scope id | path                    | value
785       | stores | 1        | resize/settings/enabled | 1

谁能帮帮我,这是怎么回事?

谢谢

最佳答案

使用 PHP my admin 并确保您的设置保存在 core_config_data 表中

使用此查询

SELECT * FROM `core_config_data` where path like "%YOUR_CONFIG_FIELD_NAME%";

并确保您能找到您的设置。如果没有,那么你的模块端就有问题了。

关于magento - Mage::getStoreConfig 始终为我的自定义模块管理选项返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16312356/

相关文章:

python - 导入的工作原理。为什么导入的模块不继承其他导入的模块

php - 在 PHP Core 中将现有字符串日期转换为 'm/j/Y'

javascript - process.on ('uncaughtException' ) 在 ES6 模块中处理

python - 日志记录包 - 在主模块和模块之间共享日志文件 - python 3

mysql - Controller 文件已加载但类不存在?

magento - 如何在 magento 中进行压力/负载测试

magento - 按顺序运行多个 Magento DataFlow 配置文件

magento - 如何在产品详细信息页面上显示最近查看的产品列表 - magento

php - 创建变体文章

magento - 用于图像的第二个 Linux 服务器(与 Magento 组合)