Magento 1.9 - SOAP V1 - 一项产品没有标识符或sku

时间:2016-12-09 13:33:16

标签: php soap magento-1.9

任何人都可以帮我摆脱这条消息 - 有一项产品没有标识符或sku 这里是我的代码 -

$proxy = new SoapClient('http://www.testdomain.com/api/soap/?wsdl');
$sessionId = $proxy->login('myapi', 'test@123');

//$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'default' ) );


$arrProducts = array(
    array(
        "product_id" => 12,
        "qty" => 1,
        "options" => array(         
            "267" => 653,
            "268" => array('date' => '12/8/2016'),
         )
    ),
    array(
        "sku" => 20707,
        "quantity" => 4,
        "store_id" => 1
    )
);
try {
        $resultCartProductAdd = $proxy->call(
            $sessionId,
            "cart_product.add",
            array(
                991,
                array($arrProducts)
            )
        );
} catch (SoapFault $e) {
    $message = $e->getMessage();
    print_r($message);
}

我已经尝试了这里找到的所有例子 - http://devdocs.magento.com/guides/m1x/api/soap/checkout/cartProduct/cart_product.add.html但是没有成功,任何帮助都会非常感激,谢谢。

1 个答案:

答案 0 :(得分:4)

最后我把它解决为 -

$proxy = new SoapClient('http://www.testdomain.com/api/soap/?wsdl');
$sessionId = $proxy->login('apitest', 'test@123');

//$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'default' ) );


$arrProducts = array(
    array(
        "product_id" => 12,
        "quantity" => 1,
        "options" => array(         
            "267" => 653,
            "268" => array('date' => '12/8/2016'),
         ),
    "sku" => 20707,
        "quantity" => 4,
        "store_id" => 1
    )
);
try {
        $resultCartProductAdd = $proxy->call(
            $sessionId,
            "cart_product.add",
            array(
                985,
                $arrProducts
            )
        );
    print_r($resultCartProductAdd);
} catch (SoapFault $e) {
    $message = $e->getMessage();
    print_r($message);
}

我已更新 $ arrProducts 数组,它解决了我的问题。希望这会对别人有所帮助,谢谢。