Magento 对于我的自定义模块管理选项,getStoreConfig始终返回null
我有一个模块:Magento 对于我的自定义模块管理选项,getStoreConfig始终返回null,magento,module,magento-1.7,Magento,Module,Magento 1.7,我有一个模块:app/code/local/Namespace/Resize/ 因此,我包括了一个通过Magento admin禁用/启用选项的选项 System>Configuration>Namespace>Resize 但是当我尝试访问这个选项时,我总是收到一个带有Mage::getStoreConfig的空值,尽管该选项设置为Yes Mage::getStoreConfig('resize/settings/enabled', Mage::app()->getStore()->
app/code/local/Namespace/Resize/
因此,我包括了一个通过Magento admin禁用/启用选项的选项
System>Configuration>Namespace>Resize
但是当我尝试访问这个选项时,我总是收到一个带有Mage::getStoreConfig
的空值,尽管该选项设置为Yes
Mage::getStoreConfig('resize/settings/enabled', Mage::app()->getStore()->getId());
或
返回空值
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>
<?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>
<?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>
adminhtml.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>
<?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>
<?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>
- 模块工作正常
- 已禁用缓存
- 我确信该选项已保存,因为我可以在数据库中看到已更新的条目
感谢使用PHP my admin并确保您的设置保存在core_config_数据表中 使用此查询
SELECT * FROM `core_config_data` where path like "%YOUR_CONFIG_FIELD_NAME%";
并确保找到您的设置。如果没有,则表示模块端有问题。是否要在system.xml文件中重命名此标记名
<tabs>
<resizing module="resize" translate="label">
<label>Resize</label>
<sort_order>100</sort_order>
</resizing>
</tabs>
调整大小
100
将调整大小替换为调整大小
然后重试。Mage::getStoreConfigFlag()给了您什么?谢谢,总是返回False。您还有问题吗?如果是这样的话,你在哪里调用getStoreConfig?我在后端测试,我的意思是magento admin,但当我在前端测试时,它工作正常!现在我知道它在后端不起作用,但我不想继续怀疑