标签:and route end 配置 not ebs 网址 显示 varchar
https://code.tutsplus.com/tutorials/create-a-custom-payment-method-module-in-magento-part-one--cms-23464
首先,要对Magento的基础模型创建程序很熟悉;
国外的一个网址:https://code.tutsplus.com/tutorials/magento-custom-module-development--cms-20643;
这个是国内的比较好的博客文章:http://blog.csdn.net/suese/article/category/1916481
自定义模块的代码池:local
自定义模块的命名空间:Envato
自定义模块的名字:Custompaymentmethod
需要创建的文件:
app/etc/modules/Envato_All.xml: 这个文件让自定义模块可用;app/code/local/Envato/Custompaymentmethod/etc/config.xml: 这个配置文件用来声明自定义模块;app/code/local/Envato/Custompaymentmethod/etc/system.xml: 这个是系统配置文件,用来为自定义的支付方式设置配置项;app/code/local/Envato/Custompaymentmethod/sql/custompaymentmethod_setup/install--1.0.0.0.php:这个是和数据库相关的文件,用来给自定义支付方式创建自定义的字段;创建app/etc/modules/Envato_All.xml
<?xml version="1.0"?>
<config> <modules> <Envato_Custompaymentmethod> <active>true</active> <codePool>local</codePool> <depends> <Mage_Payment /> </depends> </Envato_Custompaymentmethod> </modules></config><?php
$installer = $this;$installer->startSetup();$installer->run("ALTER TABLE `{$installer->getTable(‘sales/quote_payment‘)}` ADD `custom_field_one` VARCHAR( 255 ) NOT NULL,ADD `custom_field_two` VARCHAR( 255 ) NOT NULL;ALTER TABLE `{$installer->getTable(‘sales/order_payment‘)}` ADD `custom_field_one` VARCHAR( 255 ) NOT NULL,ADD `custom_field_two` VARCHAR( 255 ) NOT NULL;");$installer->endSetup();<?xml version="1.0"?>
<config> <modules> <Envato_Custompaymentmethod> <version>1.0.0.0</version> </Envato_Custompaymentmethod> </modules> <global> <fieldsets> <sales_convert_quote_payment> <custom_field_one> <to_order_payment>*</to_order_payment> </custom_field_one> <custom_field_two> <to_order_payment>*</to_order_payment> </custom_field_two> </sales_convert_quote_payment> </fieldsets> <helpers> <custompaymentmethod> <class>Envato_Custompaymentmethod_Helper</class> </custompaymentmethod> </helpers> <blocks> <custompaymentmethod> <class>Envato_Custompaymentmethod_Block</class> </custompaymentmethod> </blocks> <models> <custompaymentmethod> <class>Envato_Custompaymentmethod_Model</class> </custompaymentmethod> </models> <resources> <custompaymentmethod_setup> <setup> <module>Envato_Custompaymentmethod</module> </setup> </custompaymentmethod_setup> </resources> </global> <default> <payment> <custompaymentmethod> <active>1</active> <model>custompaymentmethod/paymentmethod</model> <order_status>pending</order_status> <title>CustomPaymentMethod</title> <allowspecific>0</allowspecific> <payment_action>sale</payment_action> </custompaymentmethod> </payment> </default> <frontend> <routers> <custompaymentmethod> <use>standard</use> <args> <module>Envato_Custompaymentmethod</module> <frontName>custompaymentmethod</frontName> </args> </custompaymentmethod> </routers> </frontend></config><fieldsets> 、<sales_convert_quote_payment>这两个标签告诉Magento将这些字段信息和客户订单信息一起保存;<payment> 、<custompaymentmethod>将我们的支付模块插入到Magento的支付模块中;这标签里面可以继续创建支付模块的字段,如支付的状态、订单的状态等;<frontend>、<routers>在前端给支付方式指定了路由;<?xml version="1.0"?>
<config> <sections> <payment> <groups> <custompaymentmethod translate="label" module="custompaymentmethod"> <label>CustomPaymentMethod Module</label> <sort_order>1000</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <fields> <title translate="label"> <label>Title</label> <frontend_type>text</frontend_type> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <sort_order>1</sort_order> </title> <active translate="label"> <label>Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <sort_order>2</sort_order> </active> <order_status translate="label"> <label>New order status</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_order_status</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <sort_order>3</sort_order> </order_status> <allowspecific translate="label"> <label>Payment from applicable countries</label> <frontend_type>allowspecific</frontend_type> <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <sort_order>4</sort_order> </allowspecific> <specificcountry translate="label"> <label>Payment from Specific countries</label> <frontend_type>multiselect</frontend_type> <source_model>adminhtml/system_config_source_country</source_model> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <sort_order>5</sort_order> </specificcountry> </fields> </custompaymentmethod> </groups> </payment> </sections></config>标签:and route end 配置 not ebs 网址 显示 varchar
原文地址:http://www.cnblogs.com/liudongqing/p/7417183.html