对Magento扩展的本地XML覆盖';s的默认配置
首先,请原谅,如果我在Magento方言方面犯了任何错误,这是我在平台上的第一个项目 我正在为Magento 1.7开发一个扩展,它将每晚从FTP站点(在同一台服务器上)导入数据。我没有将FTP目录的路径硬编码到我的模块中,而是将以下内容添加到app/code/local/CompanyName/ModuleName/etc/config.xml中:对Magento扩展的本地XML覆盖';s的默认配置,magento,configuration,Magento,Configuration,首先,请原谅,如果我在Magento方言方面犯了任何错误,这是我在平台上的第一个项目 我正在为Magento 1.7开发一个扩展,它将每晚从FTP站点(在同一台服务器上)导入数据。我没有将FTP目录的路径硬编码到我的模块中,而是将以下内容添加到app/code/local/CompanyName/ModuleName/etc/config.xml中: <?xml version="1.0" encoding="UTF-8"?> <config> <default
<?xml version="1.0" encoding="UTF-8"?>
<config>
<default>
<ftp_server_path>/home/ftpuser/</ftp_server_path>
</default>
... other module configuration...
</config>
/家庭/家庭/
... 其他模块配置。。。
我可以使用Mage::getStoreConfig('ftp\u server\u path')
访问模型中的存储值
现在我要做的是根据每个环境(我的本地计算机、暂存等)覆盖ftp\u server\u path
值。我的第一个想法是app/etc/local.xml,但我不确定这是否是合适的位置,也不确定这是否是app/etc/local.xml中存储的特定于环境的扩展配置的好例子
如果您能在这方面提供任何指导,我们将不胜感激。提前谢谢你 为什么不能使用system.xml文件将此ftp路径存储在后端可编辑字段中的数据库中 然后,您只需要在每个后端上更改它,以获得本地/dev/live版本 在模块的etc目录中创建system.xml文件,并将其放入其中:
<?xml version="1.0"?>
<config>
<sections>
<ftppath translate="label" module="yourmodule">
<label>Manage </label>
<tab>general</tab>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general translate="label">
<label>General</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<path translate="label">
<label>Path to FTP Server</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</path>
</fields>
</general>
</groups>
</ftppath>
</sections>
管理
全体的
50
1.
1.
1.
全体的
文本
10
1.
1.
1.
FTP服务器的路径
文本
1.
1.
1.
1.
您可以通过执行Mage::getStoreConfig('ftppath/general/path')获得该值
如果需要此部分仅由特定用户组的管理员查看,请在adminhtml.xml文件中创建acl(仍在模块的etc目录中)
管理FTP
50
PS:我曾经在app/etc/local.xml文件中使用过类似的方法,但从1.7开始,它就不再工作了:(为什么不能使用system.xml文件将此ftp路径存储在后端可编辑字段中的数据库中 然后,您只需要在每个后端上更改它,以获得本地/dev/live版本 在模块的etc目录中创建system.xml文件,并将其放入其中:
<?xml version="1.0"?>
<config>
<sections>
<ftppath translate="label" module="yourmodule">
<label>Manage </label>
<tab>general</tab>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<general translate="label">
<label>General</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<path translate="label">
<label>Path to FTP Server</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</path>
</fields>
</general>
</groups>
</ftppath>
</sections>
管理
全体的
50
1.
1.
1.
全体的
文本
10
1.
1.
1.
FTP服务器的路径
文本
1.
1.
1.
1.
您可以通过执行Mage::getStoreConfig('ftppath/general/path')获得该值
如果需要此部分仅由特定用户组的管理员查看,请在adminhtml.xml文件中创建acl(仍在模块的etc目录中)
管理FTP
50
PS:我曾经在app/etc/local.xml文件中做过类似的工作,但是从1.7开始它就不再工作了:(接受的SO答案中的信息,虽然是一个非常好的起点,但缺少很多需要做的事情,以便在管理面板中添加自定义配置部分 尽管有点过时,@SteveGrunwell()在接受的答案中给出的文章对我来说很有帮助,它非常详细,切中要害 过时的观点似乎是,从版本1.4及更高版本开始,ACL部分假定位于模块的/etc/文件夹中的adminhtml.xml文件中
另一个链接帮助我在上找到了被接受的SO答案中的信息,虽然这是一个很好的起点,但缺少在管理面板中添加自定义配置部分所需做的大量工作 尽管有点过时,@SteveGrunwell()在接受的答案中给出的文章对我来说很有帮助,它非常详细,切中要害 过时的观点似乎是,从版本1.4及更高版本开始,ACL部分假定位于模块的/etc/文件夹中的adminhtml.xml文件中
另一个在上帮助我的链接我担心通过后端编辑会很复杂,但是在你的答案和我之间可以让它工作。谢谢你的帮助!我担心通过后端编辑会很复杂,但是在你的答案和我之间可以让它工作。Tha谢谢你的帮助!