新增一個模組,只要基本的四個檔案即可:
app/code/community/Namespace/ModuleName/etc/config.xml
app/code/community/Namespace/ModuleName/etc/system.xml
app/code/community/Namespace/ModuleName/Model/Payment.php
app/etc/modules/Namespace_ModuleName.xml
config.xml
<config>
<modules>
<Namespace_ModuleName>
<version>0.1.0</version>
</Namespace_ModuleName>
</modules>
<global>
<models>
<modulename>
<class>Namespace_ModuleName_Model</class>
</modulename>
</models>
</global>
<default>
<payment>
<modulename>
<active>1</active>
<model>modulename/payment</model>
<order_status>processing</order_status>
<title>XXX Payment</title>
</modulename>
</payment>
</default>
</config>
system.xml
<config>
<sections>
<payment>
<groups>
<modulename translate="label">
<label>XXX Payment</label>
<sort_order>800</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<active translate="label">
<label>Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</active>
<order_status translate="label">
<label>New order status</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</order_status>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</title>
</fields>
</modulename>
</groups>
</payment>
</sections>
</config>
Model/Payment.php
<?php
class Namespace_ModuleName_Model_Payment extends Mage_Payment_Model_Method_Abstract
{
protected $_code = 'modulename';
}
Namespace_ModuleName.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Namespace_ModuleName>
<active>true</active>
<codePool>community</codePool>
<depends>
<Mage_Payment />
</depends>
</Namespace_ModuleName>
</modules>
</config>
Magento 版本 1.8.0.0-alpha1
原始討論:
http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=7552