问题
我在使用 Magento SOAP API 创建订单时遇到问题。我已经准备好了所有必需品(下面的代码片段),但每次我尝试创建订单时都会失败,状态代码为 1008(请参阅 Magento Docs )。
但是没有错误消息,所以我只知道订单创建失败。
$cart_id = $magi->execute("cart.create");
$customerEntity = $magi->execute("customer.info",5);
$customerEntity["mode"] = "customer";
$customerAddressEntity = $magi->execute("customer_address.info",$customerEntity["default_billing"]);
$customerAddressEntity["mode"] = "billing";
$magi->execute("cart_customer.set", array($cart_id,$customerEntity));
$magi->execute("cart_customer.addresses", array($cart_id,array($customerAddressEntity)));
$productEntity = array("product_id" => 48,"qty" => 1);
$magi->execute("cart_product.add",array($cart_id,array($productEntity)));
$magi->execute("cart_payment.method",array($cart_id,array("method" => "banktransfer")));
$orderId = $magi->execute("cart.order", array($cart_id));
在此操作后,magento 日志中会记录以下消息。
未定义偏移量:0/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php
undefined variable :websiteId/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php。
(此条目在该条目之后重复 3 次,每次相隔半秒)。
我在这里不知所措,几周前它还处于工作状态,从那以后没有太大变化。
更多信息
$magi 变量保存一个对象,该对象是使用 Magento Soap api 的抽象。它还捕获并记录所有错误,因此此代码中没有 try/catch block 。
- Magento 版本:1.7.0.0
- PHP 版本 5.4.6
- 服务器操作系统:Ubuntu 11.10(开发服务器)
最佳答案
Undefined offset: 0/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php
该错误表示存在一个数组没有 [ '0' ] 值
关于api - Magento SOAP 无法创建订单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10996520/