2016-06-13 5 views
0

다음 코드를 사용하여 bigcommerce의 제품을 Amazon 목록의 새 인벤토리 번호로 업데이트합니다. 옵션 세트가없는 제품 (특히 장갑 및 셔츠)은 완벽하게 작동합니다. 분명히 각 S, M, L에 대해 별도의 재고 수준을 가짐).cURL을 사용하여 BigCommerce의 인벤토리 업데이트

$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가 표시됩니다.

답변

2

옵션 세트/변형없이 단일 제품에 사용되는 products endpoint을 치기 때문에 코드가 옵션 세트가없는 제품에서 작동합니다.

옵션/변형 (예 : 장갑 및 셔츠)이있는 제품은 SKU가 될 수 있으며 SKUs endpoint을 사용하여 업데이트 할 수 있습니다. 각 SKU와 관련된 적절한 ID가 있는지 확인하십시오.

Here are the API docs 더 많은 문제가 발생하면 참조 할 수 있습니다. ProductSKU 개체의 차이점에 유의하십시오.

0

내가 누락되었을 수도 있지만 API가 어떤 옵션을 말하는 것인지 알지 못하는 것 같아서 올바르게 응답 할 수 없으며 결과적으로 404를 제공합니다.