【问题标题】:Magento SOAP unable to create orderMagento SOAP 无法创建订单
【发布时间】:2012-06-12 12:19:23
【问题描述】:

问题

我在使用 Magento SOAP api 创建订单时遇到问题。我已经准备好所有必需品(下面的代码 sn-p),但每次我尝试创建订单时,它都会失败,状态码为 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

未定义变量:websiteId/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php。
(此条目重复 3在此之后的时间,每次相隔半秒)。


我在这里不知所措,几周前它处于工作状态,从那时起没有太大变化。

更多信息

$magi 变量包含一个对象,该对象是使用 Magento Soap api 的抽象。它还捕获并记录所有错误,因此此代码中没有 try/catch 块。

  • Magento 版本:1.7.0.0
  • PHP 版本 5.4.6
  • 服务器操作系统:Ubuntu 11.10(开发服务器)

【问题讨论】:

    标签: api magento soap


    【解决方案1】:

    未定义的偏移量: 0/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php

    错误表示存在一个数组,该数组没有 [ '0' ]

    的值

    【讨论】:

    • 这是 Magento 中的一个错误,但不是问题的原因。可以通过向支付方式数组中的 [0] 添加一个值来删除此警告。
    【解决方案2】:

    第一个错误:

    未定义的偏移量:0/var/www/cloud2u.nl/mccloud_n/app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php

    是由于此方法的 Api.php 中的错误:

    protected function _preparePaymentData($data)
    {
        if (!(is_array($data) && is_null($data[0]))) {
            return array();
        }
    
        return $data;
    }
    

    我能够摆脱这个问题替换

    if (!(is_array($data) && is_null($data[0])))
    

    if (!(is_array($data) && !isset($data[0])))
    

    在测试期间,它以相同的方式工作并消除了错误。

    【讨论】:

      【解决方案3】:

      我认为你的 $productEntity 是错误的。

      $productEntity = array(
           array("product_id" => 48,"qty" => 1);
      );
      

      它使购物车是空的。

      ^^

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多