首页 > 解决方案 > 将自定义字段添加到贝宝模块 magento 1.9

问题描述

我需要在 paypal 配置中添加一个额外的字段,但由于教皇配置中使用了“无限”组,我无法添加它。是否可以向核心 paypal v.1.6.0.6 magento 1.9 模块添加自定义字段?

我正在我的自定义模块的 system.xml 文件中尝试使用以下代码,但没有运气。同一 xml 中的 cashondelivery 选项可以正常工作。

任何帮助将不胜感激

<?xml version="1.0"?>
<config>
    <sections>
        <payment>
            <groups>
                <paypal_payments>
                    <payments_pro_hosted_solution translate="label comment">
                        <fields>
                            <pphs_required_settings translate="label">
                                <fields>
                                    <pphs_required_settings_pphs translate="label">
                                        <fields>
                                            <charge_type translate="label">
                                                <label>Payment Charge Type</label>
                                                <frontend_type>select</frontend_type>
                                                <source_model>paymentcharge/system_config_source_chargetype</source_model>
                                                <sort_order>22</sort_order>
                                                <show_in_default>1</show_in_default>
                                                <show_in_website>1</show_in_website>
                                                <show_in_store>0</show_in_store>
                                            </charge_type>
                                            <charge_value translate="label">
                                                <label>Payment Charge</label>
                                                <frontend_type>text</frontend_type>
                                                <sort_order>24</sort_order>
                                                <show_in_default>1</show_in_default>
                                                <show_in_website>1</show_in_website>
                                                <show_in_store>0</show_in_store>
                                            </charge_value>
                                        </fields>
                                    </pphs_required_settings_pphs>
                                </fields>
                            </pphs_required_settings>
                        </fields>
                    </payments_pro_hosted_solution>
                </paypal_payments>
                <cashondelivery translate="label">
                    <fields>
                        <charge_type translate="label">
                            <label>Payment Charge Type</label>
                            <frontend_type>select</frontend_type>
                            <source_model>paymentcharge/system_config_source_chargetype</source_model>
                            <sort_order>200</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </charge_type>
                        <charge_value translate="label">
                            <label>Payment Charge</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>201</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </charge_value>
                    </fields>
                </cashondelivery>
            </groups>
        </payment>
    </sections>
</config>

这里是magento 1.9 system.xml文件的官方paypal模块v 1.6.0.6

https://github.com/mgtf/magento-1.9.2.0/blob/master/app/code/core/Mage/Paypal/etc/system.xml

标签: xmlmagentopaypalmagento-1.9

解决方案


试试这个

<?xml version="1.0"?>
<config>
    <sections>
        <payment>
            <groups>
                <paypal_payments>
                    <payments_pro_hosted_solution translate="label comment">
                        <fields>
                            <pphs_required_settings translate="label">
                                <fields>
                                    <pphs_required_settings_pphs translate="label">
                                    <label>Payments Pro Hosted Solution</label>
                                        <show_in_default>1</show_in_default>
                                        <show_in_website>1</show_in_website>
                                        <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model>
                                        <sort_order>10</sort_order>
                                        <fields>
                                            <charge_type translate="label">
                                                <label>Payment Charge Type</label>
                                                <frontend_type>select</frontend_type>
                                                <source_model>paymentcharge/system_config_source_chargetype</source_model>
                                                <sort_order>22</sort_order>
                                                <show_in_default>1</show_in_default>
                                                <show_in_website>1</show_in_website>
                                                <show_in_store>0</show_in_store>
                                            </charge_type>
                                            <charge_value translate="label">
                                                <label>Payment Charge</label>
                                                <frontend_type>text</frontend_type>
                                                <sort_order>24</sort_order>
                                                <show_in_default>1</show_in_default>
                                                <show_in_website>1</show_in_website>
                                                <show_in_store>0</show_in_store>
                                            </charge_value>
                                        </fields>
                                    </pphs_required_settings_pphs>
                                </fields>
                            </pphs_required_settings>
                        </fields>
                    </payments_pro_hosted_solution>
                </paypal_payments>
                <cashondelivery translate="label">
                    <fields>
                        <charge_type translate="label">
                            <label>Payment Charge Type</label>
                            <frontend_type>select</frontend_type>
                            <source_model>paymentcharge/system_config_source_chargetype</source_model>
                            <sort_order>200</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </charge_type>
                        <charge_value translate="label">
                            <label>Payment Charge</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>201</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </charge_value>
                    </fields>
                </cashondelivery>
            </groups>
        </payment>
    </sections>
</config>

推荐阅读