다음 코드를 사용하여 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가 표시됩니다.