【问题标题】:Magento 1.9 - SOAP V1 - One item of products do not have identifier or skuMagento 1.9 - SOAP V1 - 一件产品没有标识符或 sku
【发布时间】:2016-12-09 13:33:16
【问题描述】:

谁能帮我摆脱这条消息 - 一件产品没有标识符或 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 但未能成功,任何帮助将不胜感激,谢谢。

【问题讨论】:

  • 也许 id 必须在第二个数组中给出。
  • 我试过了但是不行

标签: php soap magento-1.9


【解决方案1】:

最后我把它解决为 -

$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 数组,它解决了我的问题。希望这对其他人有帮助,谢谢。

【讨论】:

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