完整的设置订单追踪信息的时候我们可能会用到它。在后台中他在这里设置:

有的时候我们想要设置自己定义的 carrier 比如 顺丰 申通 圆通 。。等等

我们能够先从 magento api 入手分析

我们调用 magento api —-> order_shipment.getCarriers

能够去查找 api 函数 在 app\code\core\Mage\Sales\Model\Order\Shipment\Api.php

    public function getCarriers($orderIncrementId)
{
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId); /**
* Check order existing
*/
if (!$order->getId()) {
$this->_fault('order_not_exists');
} return $this->_getCarriers($order);
}

追踪 _getCarriers 方法

 protected function _getCarriers($object)
{
$carriers = array();
$carrierInstances = Mage::getSingleton('shipping/config')->getAllCarriers(
$object->getStoreId()
); $carriers['custom'] = Mage::helper('sales')->__('Custom Value');
foreach ($carrierInstances as $code => $carrier) {
if ($carrier->isTrackingAvailable()) {
$carriers[$code] = $carrier->getConfigData('title');
}
} return $carriers;
}

即 都会有个默认的 custom

之后的都是通过 Mage::getSingleton(‘shipping/config’)->getAllCarriers() 获取的

追踪方法 getAllCarriers() 事实上就是循环config中的 carriers 比如这里面就有magento 自带的freeshipping

和 flatrate 等方法。 可是 要想显示到返回的 $carriers 中须要 isTrackingAvailable 为true

我们事实上能够在上面代码中打印你每个 $carrier 的类名 找到调用的 isTrackingAvailable 方法,

经分析 发现默认的比如 flatrate 他的 model中方法 isTrackingAvailable 是继承父类为false 的。

那么假设此时你想在后台 carrier中有 flatrate 能够设置他的 isTrackingAvailable 方法返回true即可了

相同适用于你自己定义的运送方式。

扩展的说下:

另一点,我们在前台结账的时候到 选择运送方式的时候比如有 flatrate 那么此时他的input value 你能够看到是

flatrate_flatrate 我们继续追踪代码,发现他在代码中显示的 是 getCarrier().’_’.getMethod() 通常我们会把这两个值在

设置的时候设置为一样的(在flatrate的model中)所以显示的就是这个样子了

可是这里要说的就是对接 Odoo 的时候默认的magento连接件 是通过这个订单的shipping method 。即运送方式

你能够在数据表 sale_flat_order 找到 比如就是 flatrate_flatrate 。 然而此时你在 Odoo 中设置tracking number的时候

可能报错,是由于提示没有 flatrate_flatrate

这时假设magento 设置 flatrate 的isTrackingAvailable 为true 你把Odoo中这个code改为 flatrate 就能够了

假设没有。能够直接设置code 为 custom 也是能够的,由于你能够在magento api中找到 默认都有个为 custom的code

magento getCarriers 分析的更多相关文章

  1. Magento架构分析,Magento MVC 设计分析

    Magento架构分析,Magento MVC 设计分析 分类:Magento 标签:Magento MVC.Magento架构 669人浏览 Magento 采用类似 JAVA的架构,其扩展与稳定性 ...

  2. magento性能分析插件

    两个好用的插件: http://connect20.magentocommerce.com/community/MagnetoDebughttp://connect20.magentocommerce ...

  3. 给 Magento 2 添加缓存层的分析与尝试

    虽然黑色星期五有惊无险的过去了, 但是 Magento 2 社区版无法读写分离这个限制, 始终是悬在整个网站上的一把利剑. 我之前尝试过给 Magento 2 写一个 MySQL 读写分离的插件, 在 ...

  4. Magento订单打印(pdf格式)

    Magento自身包含有:打印发票单,打印装箱单,打印退款单.这些都是基于西方国家的习惯来布置的.公司有个需求就是打印订单的四联单,PDF格式的,要一周内完成.刚接到这个任务时,觉得头大,因为对于PH ...

  5. Magento - Rewrite机制一窥

    看一个url例子 http://localhost/magento/index.php/customer/account/login 这里假定http://localhost/magento/ 是ma ...

  6. magento问题集

    magento产品页面价格出现2遍 In app\design\frontend\default\default\template\catalog\product\view\type\Simple.p ...

  7. 解决magento添加产品在前台不显示问题

    有时候我们在magento系统添加产品,前台不显示,最模板分析可能 以下几个原因: 1 添加新品要重新index一下,magento是静态的.html页面,不reindex不出来的.在System→I ...

  8. Magento中调用JS文件的几种方法

    一.全局调用方法: 通过该方法每个页面都会引用这个JS文件,除非是类似jQuery这样的系统文件,不然不推荐这种方法. 文件路径:/app/design/frontend/default/Your_T ...

  9. Magento请求分发与控制器

    Magento请求分发与控制器 Magento使用的是MVC结构,模型-试图-控制器结构,这样更好的实现显示逻辑和数据,业务逻辑的分离,更好的适合开发! 下面为传统的mvc结构 URL请求被一个PHP ...

随机推荐

  1. 18. IDEA 添加 persistence 时没有 sessionFactory

    转自:http://www.voidcn.com/article/p-rryjfhwi-e.html IDEA 添加 persistence 时没有 sessionFactory 点击项目,然后F4 ...

  2. Redis封装之List

    /// <summary> /// Redis list的实现为一个双向链表,即可以支持反向查找和遍历,更方便操作,不过带来了部分额外的内存开销, /// Redis内部的很多实现,包括发 ...

  3. 104.virtual虚函数多态与异构数据结构

    #include "mainwindow.h" #include <QApplication> #include <list> #include <Q ...

  4. PL/SQL Developer怎么连接远程数据库

    首先打开电脑,到PL/SQL安装的指定目录 [D:\app\DZL\product\10.2.0\dbhome_1\NETWORK\ADMIN]或者[D:\oracle\product\10.2.0\ ...

  5. javascript学习笔记总结

    1 有些浏览器可能不支持JavaScript,我们可以使用如下的方法对它们隐藏JavaScript代码. <html> <body> <script type=" ...

  6. <QT之Bug制造机>QT中串口类“QSerialPort”的学习笔记

    QT5中已经增加了串口类QSrialPort,可以直接调用API函数进行快速开发. 1. 获取串口信息 Dialog::Dialog(QWidget *parent) : QDialog(parent ...

  7. CentOS7/RedHat7的Apache配置介绍

    这里我们介绍yum安装httpd yum install -y httpd ************* [root@100 ~]# systemctl restart httpd [root@100 ...

  8. K-近邻算法学习

    # -- coding: utf-8 -- from numpy import * import operator def createDataSet(): group = array([[1.0,1 ...

  9. Json学习总结(1)——Java和JavaScript中使用Json方法大全

    摘要:JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使用了类似于C语 ...

  10. Swift编程语言初探

    继WWDC2014后,新的编程语言Swift浮出水面.它具有高速.现代.安全.可交互等特征,而且其语法简单,入门门槛低,有望替代语法复杂难懂的Objective-C语言.据其作者Chris Lattn ...