在Magento System Configuration页面添加配置项

时间:2023-03-10 06:50:01
在Magento System Configuration页面添加配置项

以 Jp_Coupon 模块为例:

目标: 在 System configuration 页面添加一个 JP tab, 在JP中添加 Coupon section, 然后给 Coupon section 添加2个配置项

按照以下步骤:

1. app/code/local/Jp/Coupon/ect/system.xml 文件

添加 jp tab 和 jp_coupon section

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0"?>
<config>
    <tabs>
        <jp translate="label" module="jp_coupon">
            <label>JP Extentions</label>
            <sort_order>200</sort_order>
        </jp>
    </tabs>
    <sections>
        <jp_coupon translate="label" module="jp_coupon">
            <label>jp Coupon</label>
            <tab>jp</tab>
            <frontend_type>text</frontend_type>
            <sort_order>40</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>100</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <config_item1 translate="label">
                            <label>Config Item 1</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>
                        </config_item1 >
                        <config_item2 translate="label">
                            <label>Config Item 2</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </config_item2 >
                    </fields>
                </general>
            </groups>
        </jp_coupon>
    </sections>
</config>

2. app/code/local/Jp/Coupon/ect/adminhtml.xml 文件

设置jp_coupon配置页面的访问权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <jp_coupon translate="title" module="jp_coupon">
                                        <title>jp Coupon</title>
                                    </jp_coupon>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

3. 清除Magento缓存,重新登录

如果您觉得阅读本文对您有帮助,欢迎转载本文,但是转载文章之后必须在文章页面明显位置保留此段声明,否则保留追究法律责任的权利。

作  者:www.jpdou.top

原文链接:http://www.jpdou.top/add-config-in-magento/