【问题标题】:Magento 1 API: order.list not workingMagento 1 API:order.list 不起作用
【发布时间】:2016-01-28 16:59:55
【问题描述】:

我正在使用 SOAP 来使用 Magento 1 API。当我尝试使用 sales_order.info 时它可以工作。但是当我尝试接收销售列表时,返回“NULL”。到目前为止,我只使用了 Magento 的示例代码,这就是为什么我想知道它为什么不起作用。

$mage_url = 'https://myhost/api/?wsdl'; 
$mage_user = '######'; 
$mage_api_key = '#######'; 
$client = new SoapClient( $mage_url ); 
$session = $client->login( $mage_user, $mage_api_key );

//WORKING:
$sale = $client->call($session, 'sales_order.info', '416203797');
$firstname = $sale['customer_firstname'];
echo $firstname;  

//NOT WORKING:
$result = $client->call($session, 'sales_order.list');
var_dump ($result); <-- (result is 'NULL')

有人知道为什么吗?

【问题讨论】:

    标签: php api magento soap


    【解决方案1】:

    检查以下答案并根据您的要求进行更改。我为我的 API 编写了这段代码,它运行良好。这里我有“sales_order.list”和“sales_order.info”的代码。您可以根据您的要求获取代码。

    <?php
    error_reporting(E_ALL); 
    

    ini_set("display_errors", 1);

    $config=array();
    $config["hostname"] = "www.yoursitename.com";
    $config["login"] = "username";
    $config["password"] = "password";
    
    $proxy = new SoapClient('http://'.$config["hostname"].'/index.php/api/soap/?wsdl', array('trace'=>1));
    $sessionId = $proxy->login($config["login"], $config["password"]);
    
    $result = array();
    $orderlist = ($proxy->call($sessionId, 'sales_order.list', array(array('customer_id'=>array('eq'=>$_REQUEST['customer_id'])))));
    $order = ($proxy->call($sessionId, 'sales_order.info', array(array('order_info'=>array('eq'=>$_REQUEST['order'])))));
    //echo '<pre>';
    //print_r($orderlist);
    //print_r($order);
    //echo '</pre>';
    
    //$result = json_encode($orderlist);
    
    if($orderlist){
    $result['success'] = true;
    $result['available'] = $orderlist; 
    $result['available'] = $order;
    }
    else{
    $result['failed'] = false;
    $result['not-available'] = error message;
    }
    
    echo json_encode($result);
    
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-21
      • 2012-11-12
      相关资源
      最近更新 更多