【问题标题】:How to make SOAP v2 multiCall to the Magento API?如何使 SOAP v2 multiCall 到 Magento API?
【发布时间】:2015-12-24 18:18:20
【问题描述】:
$client = new SoapClient($host . '/api/v2_soap/?wsdl');
$session = $client->login($apiUser, $apiKey);

$result = $client->catalogInventoryStockItemMultiUpdate($session, 'sku_id1',
          array('qty' => 1), null, 'sku');
$result = $client->catalogInventoryStockItemMultiUpdate($session, 'sku_id1',
          array('qty' =>2), null, 'sku');

如何使用函数catalogInventoryStockItemMultiUpdate()或其他决定一次请求调用多个函数?

示例仅适用于soap v1,而不是soap v2。

【问题讨论】:

    标签: php magento soap


    【解决方案1】:

    为那些从谷歌那里得到它的人回答这个问题。 v2 Magento Api 没有多重调用功能。 v1 API 可以。

    这里是 API v1 文档中的 coden-p,演示了如何一次进行多个调用:

    $client = new SoapClient('http://magentohost/soap/api/?wsdl');
    
    // If somestuff requires api authentification,
    // then get a session token
    $session = $client->login('apiUser', 'apiKey');
    
    $result = $client->call($session, 'somestuff.method');
    $result = $client->call($session, 'somestuff.method', 'arg1');
    $result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
    $result = $client->multiCall($session, array(
         array('somestuff.method'),
         array('somestuff.method', 'arg1'),
         array('somestuff.method', array('arg1', 'arg2'))
    ));
    
    
    // If you don't need the session anymore
    $client->endSession($session);
    

    请求仍然必须一个一个地创建和排队,但至少您节省了一个接一个地发送请求所花费的时间。

    在我拥有的工具中,我结合使用 v1 和 v2 api 进行批量更新和选择性更新。 v1 API 可以满足您的所有需求,只是不符合 WSI。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多