【问题标题】:Using cURL to update inventory in BigCommerce使用 cURL 更新 BigCommerce 中的库存
【发布时间】:2016-06-13 22:49:46
【问题描述】:

我正在使用以下代码使用我们亚马逊列表中的新库存编号更新 bigcommerce 中的产品 - 它非常适用于任何没有选项集的产品(特别是手套和衬衫,它们显然具有单独的库存水平) S、M、L)。

    $api_url = 'https://store-558hrkjw.mybigcommerce.com/api/v2/products/'.$nearrow['ProductID'].'.json';//put inventory
    $StockdataRAW = array('inventory_level' => 500);//$nearrow['CurrentStockLevel']
    $Stockdata = json_encode($StockdataRAW);
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $api_url );
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array ('Content-type: application/json', 'Accept: application/json') );
    curl_setopt( $ch, CURLOPT_VERBOSE, 0 );
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
    curl_setopt($ch, CURLOPT_POSTFIELDS,     $Stockdata);
    curl_setopt( $ch, CURLOPT_USERPWD, "UID:PW" );
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    // Switch on verbose information and display it on the web page.
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'w+'));
    $response = curl_exec( $ch );
    $result = json_decode($response);
    print_r($result);
    $info = curl_getinfo($ch);
    curl_close($ch);

当我将此代码用于选项时,我得到每个产品 ID 的 404 - 有什么想法吗?

【问题讨论】:

    标签: php curl bigcommerce inventory-management


    【解决方案1】:

    您的代码适用于没有选项集的产品,因为您点击了 products endpoint,它用于单个产品,没有选项集/变体。

    如果您有带有选项/变体的产品(例如手套和衬衫),这些将是 SKU,您可以使用 SKUs endpoint 更新这些产品 - 确保您拥有与每个 SKU 关联的正确 ID。

    Here are the API docs,如果遇到更多问题可以参考。请注意 ProductSKU 对象之间的区别。

    【讨论】:

      【解决方案2】:

      我可能遗漏了一些东西,但看起来你没有告诉 api 你指的是哪个选项,所以它无法正确回复并因此给你一个 404。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多