如何使用soap api在magento 1.9中创建订单

时间:2016-04-20 12:37:55

标签: magento magento-1.9

我的代码

$proxy = new SoapClient('http://webisteurl/api/soap/?wsdl');
$sessionId = $proxy->login('user', 'key');

$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'magento_store' ) );
echo "dd";exit;
$arrProducts = array(
    array(
        "sku" => "test",
        "quantity" => 4
    )
);

$resultCartProductAdd = $proxy->call($sessionId,"cart_product.add", array($quoteId,$arrProducts ));

它给出错误"致命错误:未捕获的SoapFault异常:[1001]无法进行操作,因为商店不存在"

我该如何解决这个问题?我做对了吗?

提前致谢。

1 个答案:

答案 0 :(得分:1)

in magento admin, create api username and password
System > Web Services > Roles.
Create a new API role
Create a new API user

    <?php

    $api_url_v1 = "http://magento.local/api/soap/?wsdl=1";

    $username = 'mobile';
    $password = 'mobile123';

    $cli = new SoapClient($api_url_v1);

    //retreive session id from login
    $session_id = $cli->login($username, $password);

    //call customer.list method
    $result = $cli->call($session_id, 'customer.list', array(array()));