- 浏览: 82796 次
- 性别:
- 来自: 上海
-
文章分类
最新评论
-
shuishui8310:
开公司了?
Magento学习课程继续 -
yanggaojiao:
对不起,很久没上这里了,在CMS->Home->D ...
Magento在首页自定制Block的方法 -
beautiful_good:
hi,你好我用的是magento 1.4.2.0版本的,请问如 ...
Magento在首页自定制Block的方法 -
as3291363:
太慢了....
Magento 1.4.1.0 的CMS太酷了 -
richardlovejob:
这个分享是在太及时了,谢谢。
Magento Events分析和使用实例与技巧
Javaeye的一些作者也有相同的文章(都是从官网直接贴过来的),不过我还打算自己也发布一下,方便读者不用到处找Magento的资料。
废话不说,要新增一个Magento支付模块的话,最好单独出来定义;当然也可以跟其他的module定义在同一个Module中如果有需要的话。
下面我们将新增一个带可以完成下面列表的功能的payment方法的module:
-
读取信用卡的信息
-
交易提交前进行验证
-
在订单支付记录中记录该交易的ID
假设这个module叫做NewModule.,当然这个名字是任意的。
首先确保你的 app/code/local
在 include_path中(你不能确定的话,请看我前面的文章有相关的代码完成该功能).
如果你的system->cache Management 中的configuration cache是开着的话,把它Disable,或者在更新*.xml配置文件时reset/reflash一下。
新建 app/etc/modules/CompanyName_NewModule.xml
:
<config> <modules> <!-- declare CompanyName_NewModule module --> <CompanyName_NewModule> <!-- this is an active module --> <active>true</active> <!-- this module will be located in app/code/local code pool --> <codePool>local</codePool> <!-- specify dependencies for correct module loading order --> <depends> <Mage_Payment /> </depends> </CompanyName_NewModule> </modules> </config>
Magento在初始化配置的时候自动到etc/目录下读取相关的xml文件。分析完上面的代码知道你新增一个module
Create app/code/local/CompanyName/NewModule/etc/config.xml
:
<?xml version="1.0"?> <config> <modules> <CompanyName_NewModule> <!-- declare module's version information for database updates --> <version>0.1.0</version> </CompanyName_NewModule> </modules> <global> <!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 --> <blocks> <newmodule> <class>CompanyName_NewModule_Block</class> </newmodule> </blocks> <!-- declare model group for new module --> <models> <!-- model group alias to be used in Mage::getModel('newmodule/...') --> <newmodule> <!-- base class name for the model group --> <class>CompanyName_NewModule_Model</class> </newmodule> </models> <!-- declare resource setup for new module --> <resources> <!-- resource identifier --> <newmodule_setup> <!-- specify that this resource is a setup resource and used for upgrades --> <setup> <!-- which module to look for install/upgrade files in --> <module>CompanyName_NewModule</module> </setup> <!-- specify database connection for this resource --> <connection> <!-- do not create new connection, use predefined core setup connection --> <use>core_setup</use> </connection> </newmodule_setup> <newmodule_write> <connection> <use>core_write</use> </connection> </newmodule_write> <newmodule_read> <connection> <use>core_read</use> </connection> </newmodule_read> </resources> </global> <!-- declare default configuration values for this module --> <default> <!-- 'payment' configuration section (tab) --> <payment> <!-- 'newmodule' configuration group (fieldset) --> <newmodule> <!-- by default this payment method is inactive --> <active>0</active> <!-- model to handle logic for this payment method --> <model>newmodule/paymentMethod</model> <!-- order status for new orders paid by this payment method --> <order_status>pending</order_status> <!-- default title for payment checkout page and order view page --> <title>Credit Card (Authorize.net)</title> <cctypes>AE,VI,MC,DI</cctypes> <payment_action>authorize</payment_action> <allowspecific>0</allowspecific> </newmodule> </payment> </default> </config>
上面的xml文档定义了一些配置选项,在Magento admin panel System > Configuration 你将会看到这些选项。
Create app/code/local/CompanyName/NewModule/etc/system.xml
:
<?xml version="1.0"?> <config> <sections> <!-- payment tab --> <payment> <groups> <!-- newmodule fieldset --> <newmodule translate="label" module="paygate"> <!-- will have title 'New Module' --> <label>New Module</label> <!-- position between other payment methods --> <sort_order>670</sort_order> <!-- do not show this configuration options in store scope --> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <fields> <!-- is this payment method active for the website? --> <active translate="label"> <!-- label for the field --> <label>Enabled</label> <!-- input type for configuration value --> <frontend_type>select</frontend_type> <!-- model to take the option values from --> <source_model>adminhtml/system_config_source_yesno</source_model> <!-- field position --> <sort_order>1</sort_order> <!-- do not show this field in store scope --> <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>4</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>2</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> </newmodule> </groups> </payment> </sections> </config>
打开 Admin / System / Configuration / Payment Methods, 看到"New Module” group.Enable之,然后检测一下新模块是否可以工作了. 在payment methods可以看到"New Module” payment method并且带有填写信用卡信息的表单.
Create app/code/local/CompanyName/NewModule/sql/newmodule_setup/mysql4-install-0.1.0.php
:
<?php // here are the table creation for this module e.g.: $this->startSetup(); $this->run("HERE YOUR SQL"); $this->endSetup();
定义版本信息:
<modules> <CompanyName_NewModule> <version>0.2.0</version> </CompanyName_NewModule> </modules>
然后 create app/code/local/CompanyName/NewModule/sql/newmodule_setup/mysql4-upgrade-0.1.0-0.2.0.php
:
<?php // here are the table updates for this module e.g.: $this->startSetup(); $this->run("HERE YOUR UPDATE SQL"); $this->endSetup();
注意事项:
-
Dont put your module in /Mage. It belongs in
app/code/community/
orapp/code/local
-
Make sure your module’s first letter is capitalized. newmodule apparently will not work, it must start with a capital letter Newmodule.
-
Also make sure that the recipient folder of the module’s folder (CompanyName in the example) is capitalized as well. companyName doesn’t seem to work, either.
-
If your module is not showing in configuration>advanced then check your config.xml
-
If your module shows in the list of modules (configuration>advanced) but not in the Payment Methods, your problem is probably in system.xml
-
Make sure you clear the cache.
发表评论
-
Magento Admin Form表单元素大全
2012-09-30 12:08 1055开发Magento后台的时候经常用到表单(Varien_Dat ... -
Magento A-Z和sitemap插件
2012-09-30 11:53 3772Iifire历经四个月多开发 ... -
Magento SQL绑定查询条件
2012-04-17 15:17 2657Magento从数据库中取数据时大多用的Collection, ... -
Magento站内信插件
2012-02-28 10:04 1525Magento Message Box即站内信组件,主要用于管 ... -
Magento內链外链插件
2012-02-21 10:26 1510给您的Magento网站添加关键词的链接,更多的内链和外链,更 ... -
Magento高级产品订阅
2012-02-21 08:54 2309基本功能介绍 产品订 ... -
Magento产品降价通知和到货通知插件
2012-02-09 16:04 01.客户可以在Magento前台页面订阅某个产品的降价通知(缺 ... -
Magento学习课程继续
2011-03-20 16:05 1515由于前一大段时间都比较忙,忽略了大家啦,好久没有更新内容了。打 ... -
Magento在首页自定制Block的方法
2010-09-19 14:27 2846Magento中想在首页显示一些自定制的BLock有很多中方法 ... -
magento获取相应的查询语句
2010-09-19 14:12 1139虽然Magento对数据库层封装得比较深,但是我们可以很轻松的 ... -
Magento 使用小技巧体现大智慧(Last things first)
2010-06-15 23:38 1314在我们的购物车Magento上线之前,有些小细节很容易被忽略。 ... -
从数据库设计看Magento系列教程(1)
2010-06-15 19:11 0TODO..... -
Magento Events分析和使用实例与技巧
2010-06-14 20:15 3438当你需要扩展Magento的核心的功能时有两个选择 重写( ... -
Magento CMS 应用实例
2010-06-14 19:03 4817下面是一些CMS的应用实例: 本文已移到 http:// ... -
Magento 1.4.1.0 的CMS太酷了
2010-06-14 02:49 1727哇,Magento 1.4.1.0版本已经出来了,今天安装使用 ... -
Magento SEO 使用技巧
2010-06-13 20:50 1162这些内容大致分为: HTML Head URL rewr ... -
Magento web services API 扩展
2010-06-13 11:52 3154<?xml version="1.0&qu ... -
Magento image 操作
2010-06-13 10:48 1341由于lib/Varien/Image.php 的 Varie ... -
Magento中直接使用SQL查询语句
2010-06-13 10:29 1818本文已移到:http://www.iifire.com ... -
在导航栏中或其他位置添加Home链接
2010-06-13 08:47 2584本节不打算翻译,留给自己需要的时候Copy用 A ...
相关推荐
return $this->resultPageFactory->create()->setBlock($block)->renderView(); } } ``` 3. **View**: 视图负责展示内容。在`View`目录下创建`frontend`子目录,然后创建`templates`子目录。在这里,创建一个名为...
这个“Java_Database_CreateTable_module.rar”压缩包文件显然包含了一个关于如何在Java中创建数据库表的教程或代码示例。在这个模块中,我们将深入探讨Java数据库编程的基础知识,特别是如何使用SQL语句在数据库中...
react-native-create-module 使用单个命令创建React Native库的工具。你为什么需要这个? 如果您要为React Native创建本机模块,则需要为要支持的每个平台提供一些本机代码,然后需要一些JavaScript代码将其绑定在...
It describes each and every code used to make a Hello World module, a feedback module, a tips module, an order total module, and a shipping and payment module. The book covers installing, ...
本文将详细介绍如何使用`create-ssl-certificate`这个基于Node.js的命令行工具来创建自签名SSL证书。 首先,`create-ssl-certificate`是一个Node.js应用程序,它简化了在本地或开发环境中生成自签名SSL证书的过程。...
struct class *class_create(struct module *owner, const char *name); ``` - `owner`: 指向拥有这个设备类的模块。 - `name`: 设备类的名称。 #### 四、udev支持 从Linux内核2.6的某个版本开始,udev取代了devfs...
安装npm install create-module --global用法create-module <package> [--check] [--offline] 请执行以下工作流程:mkdir < package>cd < package># create <githubrepo> for <package>git initgit remote add ...
例如,当客户端发送一个POST请求时,如果Nginx配置中没有明确允许该方法,则可能会返回405 Method Not Allowed的状态码。 #### 三、源码级修改步骤 ##### 1. 进入Nginx源码目录 首先,需要获取Nginx的源码包,并...
Dive into Drupal module development as we create the Philosopher Biographies website, developing new modules and themes to meet practical goals. Create custom content types. Add AJAX functionality ...
现在,“create_system_point.zip”这个压缩包文件提供了一个方便的途径,允许用户快速创建和管理系统还原点。这个文件可能包含了一个批处理文件以及如何使用它的详细说明。用户首先需要阅读这些说明,以了解如何...
本文将深入探讨如何在CentOS 7上安装Zabbix 5.0,并详细介绍如何导入MySQL所需的SQL文件`create.sql`来初始化数据库。 首先,让我们了解Zabbix。Zabbix是一款功能强大的网络监控系统,能够实时监控服务器、网络设备...
在这个场景中,我们需要创建一个名为`createModule`的函数,它能够根据输入的参数生成一个具有特定属性和方法的对象。以下是根据标题和描述所创建的`createModule`函数的知识点详解: 1. **函数定义**: `create...
MySQL_create.sql
docker中的 zabbix5 缺乏create.sql.gz 得找到这个文件才能继续 docker cp create.sql.gz zabbix5:/soft # 上传create.sql.gz文件 # zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uroot -proot...
马肯打码机软件CoLOS Create Pro 5.2是一款专为标识和编码行业设计的专业软件,它提供了强大的标签设计和打印功能。该版本包含了中文包,使得中国用户在使用过程中能够更加方便地理解和操作软件的各项功能。CoLOS ...
`db.createUser` 方法就是用于创建具有特定权限的用户的。以下是对 `db.createUser` 使用的详细介绍: ### 1. `db.createUser` 方法的官方文档参考 `db.createUser` 方法允许管理员创建新的用户账户,其基本语法...
20110930_createpdf20110930_createpdf20110930_createpdf20110930_createpdf20110930_createpdf20110930_createpdf20110930_createpdf20110930_createpdf
Oracle Create Type 详解 Oracle Create Type 是 Oracle 数据库中的一种强大工具,可以用于创建自定义类型,例如对象类型、数组类型、表类型等。在本文中,我们将详细介绍 Oracle Create Type 的概念、语法和应用。...
The LabVIEW Touch Panel Module extends the LabVIEW graphical development environment to Touch Panel devices so you can create human-machine interface (HMI) applications for Touch Panel devices running...