[转] Magento 自定义EMS FEDEX DHL UPS扩展 第一章

2,760次阅读
没有评论

共计 4548 个字符,预计需要花费 12 分钟才能阅读完成。

Magento 内置了UPS FEDEX DHL USPS 的扩展,因为这些扩展都需要条用官方的结果,而我们的价格和官方又不一样,所以独立出来新建扩展就可以自定义自己的计算规则和价格.同样我也考虑了用SOAP,因为站点比较多.价格也统一了

参考官方文档的步骤很快能实现这一功能:

Magento Official WIKI :Create Shiping Mod

创建模块的步骤:

1.在app/etc/modules中新建xml配置文件用来申明该插件的代码位置和状态

2.在app/code/local(community)目录中存放插件,目录需要在app/etc/modules/Company_Module.xml中指定

3.在插件目錄中撰寫config.xml和system.xml配置相關的文件進行配置.

4.撰寫php代碼,model和block部份.

5.後臺配置,前臺調試

一.先到app/etc/modules目录中新建一个文件,名为:Plima_Ship.xml.根据Magento的命名规则,_前为org名 称(公司或者组织,当然了.根据自己喜好设定),_后为模块名称.文件全称意味着在 app/etc/code/local(community)中目录和配置文件相符.如:Plima_Ship.xml对应的目录应该为:app/etc /code/local(community)/Plima/Ship

Create config file in app/etc/modules and declare module

[php]

< ?xml version="1.0"?>
< config>
< modules>
< Plima_Ship>
< active>t< /active>
< codePool>lo< /codePool>
< /Plima_Ship>
< /modules>
< /config>

[/php]

为模块名称,必须和文件对应,否则Magento找不到模块
中true为启用,反之false为停用
代码位置,之前我提到了有两个地方:local和community,在此申明就可以了,当然了.如果你非要写在core也是可以的,只是预留在这两个位置方便我们对插件进行管理.接下来进行第二步.
二.在app/etc/code/local/中創建插件的目錄結構:
etc 中存放config.xml和system.xml的配置文件
Model 為php的計算模型
Helper 為助手,根據框架的思想來設計的

三.在etc中新建兩個文件,config.xml和system.xml
由于文件代码较多,在文章中我就不一一阐述了,只挑一部分进行说明,两个文件可以在下边的url中下载:
config.xml:http://

system.xml http://

文件说明:
1.config.xml:
之前強調的模塊名稱再一次在這裡出現,需要特別注意名稱的大小寫和目錄的目錄須保持一致;

[php]

< modules>
< Plima_Ship>
< version>0.1.0 B< /version>
< depends>
< Mage_Shipping />
< /depends>
< /Plima_Ship>
< /modules>

[/php]

中告訴Magento ship provider 的類名
注:我用pems作為文件名稱是考慮到如果我用ups和fedex時可能會和magento內置的模塊衝突,故在文件名前+了p,如果不需要可先在app/etc/modules/Mage_All.xml中找到 Usa 停用即可

像title name allowspecific這些配置為默認後臺看到的選項,接下來我會在system.xml中說明

[php]

< default>
< carriers>
< pems>
< activ< /active>
< model>plima_ship_model_shipping_carrier_p< /model>
< allowed_metho< /allowed_methods>
< weight_unit< /weight_unit>
< rounding_rule>n< /rounding_rule>
< google_checkout_compatibl< /google_checkout_compatible>
< name>P< /name>
< title>Plima < /title>
< sallowspecifi< /sallowspecific>
< specificcountry< /specificcountry>
< sort_orde< /sort_order>
< /pems>
< carriers>
< /default>

[/php]

2.system.xml
< label>Plima_EMS< /label> 這塊為後臺配置時顯示的塊名稱,可以在這裡修改;
fields為詳細的選項,比如常用
active,title,salowspecific,specificcountry等等,這些字段的申明是爲了在model中接受參數,而參數的鍵值正為這裡什麽的名稱,如果我定義一個則我在model中接受的時候需這樣寫:
$val = $this->getConfigData(‘discount’);
而值是根據配置來定的,如果是文本,則值為文本域所保存的值.
< frontend_type>text< /frontend_type>這一段就是什麽字段類型為文本;

具體可以查看數據庫 core_config_data中的表.

[php]

< pems translate="label" module="ship">
< label>Plima_< /label>
< frontend_type>t< /frontend_type>
< sort_order< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< fields>
< active translate="label">
< label>Enab< /label>
< frontend_type>sel< /frontend_type>
< source_model>adminhtml/system_config_source_ye< /source_model>
< sort_orde< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /active>
< gateway_url translate="label">
< label>SOAP < /label>
< frontend_type>t< /frontend_type>
< sort_order< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /gateway_url>
< tax_fee translate="label">
< label>< /label>
< frontend_type>t< /frontend_type>
< sort_order< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /tax_fee>
< sort_order translate="label">
< label>Sort or< /label>
< frontend_type>t< /frontend_type>
< sort_order>< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /sort_order>
< title translate="label">
< label>Ti< /label>
< frontend_type>t< /frontend_type>
< sort_orde< /sort_order>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /title>
< sallowspecific translate="label">
< label>Ship to applicable countr< /label>
< frontend_type>sel< /frontend_type>
< sort_order< /sort_order>
< frontend_class>shipping-applicable-coun< /frontend_class>
<source_model>adminhtml/system_config_source_shipping_allspecificcountr< /source_model>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /sallowspecific>
< specificcountry translate="label">
< label>Ship to Specific countr< /label>
< frontend_type>multisel< /frontend_type>
< sort_order< /sort_order>
< source_model>adminhtml/system_config_source_coun< /source_model>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /specificcountry>
< showmethod translate="label">
< label>Show method if not applica< /label>
< frontend_type>sel< /frontend_type>
< sort_order< /sort_order>
< source_model>adminhtml/system_config_source_ye< /source_model>
< show_in_defaul< /show_in_default>
< show_in_websit< /show_in_website>
< show_in_stor< /show_in_store>
< /showmethod>
< /fields>
< /pems>[/php]

 

正文完
 0
评论(没有评论)

空瓶子部落

文章搜索
推荐阅读
法兰密封垫的密封原理、设计计算以及选用原则

法兰密封垫的密封原理、设计计算以及选用原则

密封就是控制两个区域之间介质的相互交换,使区域的界面处没有泄漏的现象。 在实际的结构、设计以及机械加工中,是无...
什么是质量检验?质量检验的方式有哪些?

什么是质量检验?质量检验的方式有哪些?

质量检验是指对产品的一种或多种特性进行测量、检查、试验、计量,并将这些特性与规定的要求进行比较,以确定其符合性...
浅谈零缺陷管理核心思想

浅谈零缺陷管理核心思想

导语:零缺陷管理的建成绝非一朝一夕的事情,这需要我们做大量实践,总结经验教训,并且不断地坚持、努力、评估、改进...
钢中的马氏体、贝氏体与珠光体组织傻傻分不清?

钢中的马氏体、贝氏体与珠光体组织傻傻分不清?

在金属材料科学中,钢的组织结构对其性能具有决定性的影响。钢的组织主要包括马氏体、贝氏体和珠光体等,这些组织的形...
最新文章
群晖 Let’s Encrypt 泛域名证书自动更新

群晖 Let’s Encrypt 泛域名证书自动更新

目前acme协议版本更新,开始支持泛域名(wildcard),也就是说,可以申请一个类似*.domain.co...
可以卸载TV Box 了,这款支持「绅士模式」的影视神器你值得拥有

可以卸载TV Box 了,这款支持「绅士模式」的影视神器你值得拥有

还在为找优秀片源难、广告多、平台会员太贵而烦恼?今天给大家挖到一款真正的影视宝藏工具——小猫影视! 作为开源免...
【收藏】一次性解决TV点播/直播自由

【收藏】一次性解决TV点播/直播自由

很多时候,资源就在面前,但是我们视而不见,因为长久的安逸,已经让人失去动手的兴趣。但是每次我需要挨个切换APP...
OpenWrt 存储空间扩容的两种方案

OpenWrt 存储空间扩容的两种方案

说明:当我们通过群晖 VMM 虚拟机安装 Open­Wrt 时,默认会分配一个 10GB 的存储空间,而实际情...
OpenWrt修改IP地址两种方法(直接命令修改跟后台修改)

OpenWrt修改IP地址两种方法(直接命令修改跟后台修改)

OpenWrt是什么?OpenWrt一般常见于无线路由器(软路由)第三方固件,它是一个高效、可靠、功能多的路由...
热门文章
提高过程能力指数(CP/CPK)的途径

提高过程能力指数(CP/CPK)的途径

编者按:过程能力指数(CP/CPK)想必各位质量人都耳熟能详、运用自如,质量工程师之家前期也共享过数篇关于过程...
SPC控制图的八种模式分析

SPC控制图的八种模式分析

SPC控制图有八种模式,即八种判断异常的检验准则,每一种检验准则代表一种异常现象,应用SPC控制图进行过程评估...
测量高手放大招:圆跳动测量技巧总结

测量高手放大招:圆跳动测量技巧总结

01. 前言 在五金机加工厂实际的测量工作中,经常碰到要求测量两个要素的圆跳动问题, 利用不同的测量辅件及夹具...
过程能力分析(CP&cpk)

过程能力分析(CP&cpk)

引入过程能力分析的目的? 在我们现有的管理过程中,我们经常会遇到有些具体指标总是不尽人意,存在许多需要改进的地...
新能源汽车 “两会”精神宣贯会

新能源汽车 “两会”精神宣贯会

此次和大家分享新能源汽车相关政策: [embeddoc url=”https://www.ctro...
最新评论
多乐士 多乐士 通过摸索发现ssh拉取会报错,直接网页访问下载会报404错误,不知道原因;但是可以通过群晖CM注册表访问下载,其方法如下: Container Manager-注册表-设置-新增-注册表名称随便写,注册表URL填你的加速地址,勾选信任的SSL自我签署证书,登录信息不填-应用-使用你的地址,这是注册表会显示了,在搜索栏中输入映像名称,搜索结果在每一页的最后一个,你需要划到最后一个进行下载,实测可正常下载安装。 以上供网友参考。
多乐士 多乐士 还有一个比较简单的方法,只是需要一些外部工具。 1、讲损毁硬盘取出,装入外部移动硬盘 2、打开Diskgenius,定位到硬盘 3、格式化系统分区 4、重新插入硬盘 5、存储池->修复存储池即可
多乐士 多乐士 写的不错的文章
辞了老衲 辞了老衲 这个确实有帮助。
渋驀 渋驀 当然任何时候都可以用curl命令和crontab来实现动态更新DDNS的ip地址: 1、安装crontab之后为root用户创建文件/var/spool/cron/root 2、创建并配置ddnsupdate.sh,放到/usr/bin/文件下,文件内容(以he.net为例): Autodetect my IPv4/IPv6 address: IPV4:curl -4 "http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com" IPV6:curl -6 "http://dyn.example.com:password@dyn.dns.he.net/nic/update?hostname=dyn.example.com" 3、添加执行权限chomod +x /usr/bin/ddnsupdate.sh 4、编辑root用户的crontab:*/10 * * * * /usr/binddnsupdate.sh,每10分钟执行一次。好了,可以享受你的DDNS了
21410 21410 请问下载链接在那里?
madkylin madkylin 不错,不错,谢谢分享了,好东西啊 :lol:
feilung feilung 求方法
zengsuyi zengsuyi 应该挺不错的
zise zise 看看是怎么操作的。。 :oops: