Product API from server
Description
When transferring the product database via Product API, there can be cases when the out-of-stock product page becomes unavailable.
In this case users cannot access it and, accordingly, no Product API method event can be sent. This means that such a product will remain in stock on the Retail Rocket platform.
To avoid this problem, you need to configure such products to send data from the server with the information that the product is out of stock.
Example
The server must send a POST request with product information. The information in the $data_string variable must be in JSON format and be identical to the information in the retailrocket.products.post tracking code on the website.
If the Retail Rocket system processes the request successfully - the response should contain the status 200/204.
Example code in PHP:
$data_string = '{
"id": 67998,
"name": "ITEM NAME",
"description": "ITEM DESCRIPTION",
"price": 790,
"pictureUrl": "LINK TO PICTURE",
"url": "LINK TO ITEM",
"isAvailable": false,
"categoryPaths": [
"PATH/TO/CATEGORY"
],
"stockId": "Madrid"
}';
$ch = curl_init('https://cdn.retailrocket.net/api/1.0/partner/<PARTNER_ID>/products/<PRODUCT_ID>');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_exec($ch);
$result = curl_getinfo($ch);
print_r($result);
$data_string = '{
"groupId": 67998,
"name": "ITEM NAME",
"description": "ITEM DESCRIPTION",
"price": 790,
"pictureUrl": "LINK TO PICTURE",
"url": "LINK TO ITEM",
"isAvailable": false,
"categoryPaths": [
"PATH/TO/CATEGORY"
],
"products": {
"679981": {
"isAvailable": false
},
"679982": {
"isAvailable": false
}
}
}';
$ch = curl_init('https://cdn.retailrocket.net/api/1.0/partner/<PARTNER_ID>/productsgroup/<PRODUCT_GROUP_ID>');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_exec($ch);
$result = curl_getinfo($ch);
print_r($result);
Where <PARTNER_ID> is the partnerId of the store
Updated over 2 years ago