做Magento和其他系统的对接时需要调用Magento的Api,原以为更新一个订单的状态这样的函数Magento默认肯定自带有,一开始却找不到,打开官网看order部分提供的接口函数列表也没找到。
按说明,从上到下依次为批量获取订单,获取单个订单,给订单添加备注,锁定订单,解锁订单和取消订单。在我认为不存在这个函数准备自己写一个的时候,看代码发现其实addComment这个函数已经提供了更新订单状态的功能,而不仅仅是添加备注,看代码
public function addComment($orderIncrementId, $status, $comment = null, $notify = false) { $order = $this->_initOrder($orderIncrementId); $order->addStatusToHistory($status, $comment, $notify); try { if ($notify && $comment) { $oldStore = Mage::getDesign()->getStore(); $oldArea = Mage::getDesign()->getArea(); Mage::getDesign()->setStore($order->getStoreId()); Mage::getDesign()->setArea('frontend'); } $order->save(); $order->sendOrderUpdateEmail($notify, $comment); if ($notify && $comment) { Mage::getDesign()->setStore($oldStore); Mage::getDesign()->setArea($oldArea); } } catch (Mage_Core_Exception $e) { $this->_fault('status_not_changed', $e->getMessage()); } return true; }
addStatusToHistory这个函数可以同时修改订单状态和添加订单备注,并且添加一条订单历史记录,要比直接修改订单的状态值要合理。同时addComment这个接口还可以发送订单更新邮件给客户,是否发送取决于$notify这个参数。
也就是说,Magento提供的更新订单的接口还是挺完整的,可惜文档里没体现出来,会误导人。
您还没有登录,请您登录后再发表评论
Magento-中文开发教程, 欢迎大家指出错误。 深入理解Magento-第一章 – Magento强大的配置系统 深入理解Magento-第二章 – Magento请求分发与控制器 深入理解Magento-第三章 – 布局,块和模板 深入理解...
magento-ce-2.4.0_sample_data-2020-07-26-02-51-57.tar.gz Include sample data
magento-1.8.0.0.tar.gz
1.订单管理-----------------------------------------------------Magento-2.1订单管理 2.发票---------------------------------------------------------- Magento-2.2订单管理 3.配送--------------------------...
magento-ce-2.4.0-2020-07-24-11-15-38.tar.gz 不带sample data
Magento-Redismanager, 在 Magento,用于Redis的超级用户控制 Redis 管理Redis服务的实用程序特性系统> 配置>的自动或者手动配置高级> Redis管理在负载均衡环境中缓存服务不同的理想情况直接从magento面板管理员管理...
magento-1.6.2.0 magento-1.6.2.0 magento-1.6.2.0
##使用指南var magentoRestApi = require('magento-rest-api');// Create api objectvar api = magentoRestApi.createClient({ consumerKey: '<Your>', consumerSecret: '<Your>', token: '<Token>', tokenSecret: ...
magento -redis 安装包
因为国外网速太慢了,所以下载后分享给需要的人。magento-ce-2.4.2-p1-2021-04-22-10-49-09
magento-1.9.1.1-2015-04-30-12-49-08 源代码包
以详细的操作实例说明了magento的使用、配置、开发相关的实际应用。
magento-演示数据1.6.1.0
magento2-blog-module-tutorial, 关于如何从头开始创建 magento 2模块的教程,带有测试 2博客模块教程这个模块是 WIP,它将被更新为每个教程我目前正在写。介绍如何从头创建完整功能的Magento 2模块。 即使有测试,...
magento-1.6.1.0最新英文版
最新的magento-1.7.0.2汉化包,汉化率达到98%上,绝对适合你
magento-1.7.0.7z,安装包
Magento-CE-2.3.4_sample_data-2020-01-22-11-11-58.tar.gz源自官网
在Magento 2站点内安装要在您的Magento 2项目中使用,可以使用: composer require --dev magento/magento-coding-standard 出于安全考虑,以这种方式安装时,无法自动添加phpcs的Magento标准。 您可以通过将以下...
magento-enhancedemails-源码.rar
相关推荐
Magento-中文开发教程, 欢迎大家指出错误。 深入理解Magento-第一章 – Magento强大的配置系统 深入理解Magento-第二章 – Magento请求分发与控制器 深入理解Magento-第三章 – 布局,块和模板 深入理解...
magento-ce-2.4.0_sample_data-2020-07-26-02-51-57.tar.gz Include sample data
magento-1.8.0.0.tar.gz
1.订单管理-----------------------------------------------------Magento-2.1订单管理 2.发票---------------------------------------------------------- Magento-2.2订单管理 3.配送--------------------------...
magento-ce-2.4.0-2020-07-24-11-15-38.tar.gz 不带sample data
Magento-Redismanager, 在 Magento,用于Redis的超级用户控制 Redis 管理Redis服务的实用程序特性系统> 配置>的自动或者手动配置高级> Redis管理在负载均衡环境中缓存服务不同的理想情况直接从magento面板管理员管理...
magento-1.6.2.0 magento-1.6.2.0 magento-1.6.2.0
##使用指南var magentoRestApi = require('magento-rest-api');// Create api objectvar api = magentoRestApi.createClient({ consumerKey: '<Your>', consumerSecret: '<Your>', token: '<Token>', tokenSecret: ...
magento -redis 安装包
因为国外网速太慢了,所以下载后分享给需要的人。magento-ce-2.4.2-p1-2021-04-22-10-49-09
magento-1.9.1.1-2015-04-30-12-49-08 源代码包
以详细的操作实例说明了magento的使用、配置、开发相关的实际应用。
magento-演示数据1.6.1.0
magento2-blog-module-tutorial, 关于如何从头开始创建 magento 2模块的教程,带有测试 2博客模块教程这个模块是 WIP,它将被更新为每个教程我目前正在写。介绍如何从头创建完整功能的Magento 2模块。 即使有测试,...
magento-1.6.1.0最新英文版
最新的magento-1.7.0.2汉化包,汉化率达到98%上,绝对适合你
magento-1.7.0.7z,安装包
Magento-CE-2.3.4_sample_data-2020-01-22-11-11-58.tar.gz源自官网
在Magento 2站点内安装要在您的Magento 2项目中使用,可以使用: composer require --dev magento/magento-coding-standard 出于安全考虑,以这种方式安装时,无法自动添加phpcs的Magento标准。 您可以通过将以下...
magento-enhancedemails-源码.rar