Update Stock And Price
Updates an existing product. Only the fields you send will be updated (partial update).
URL Parameters
| Parameter | Type | Description |
|---|---|---|
product_id | integer | ID of the product to update |
Body Parameters
Same fields as Add Product apply; all fields are optional.
PHP
<?php
$baseUrl = 'https://example.com/api/v1/';
$apiKey = ''; // You need to obtain a token from the admin for the API Key.
$result = '';
function apiRequest($method, $url, $apiKey, $data = null)
{
$ch = curl_init();
$headers = [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
];
if ($data !== null) {
$headers[] = 'Content-Type: application/json';
}
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false,
]);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
return [
'http_code' => $httpCode,
'curl_error' => $error,
'response' => json_decode($response, true) ?: $response,
];
}
function apiUploadImage($url, $apiKey, $filePath)
{
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . trim($apiKey),
'Accept: application/json',
],
CURLOPT_POSTFIELDS => [
'image' => new CURLFile($filePath, mime_content_type($filePath) ?: 'image/jpeg', basename($filePath)),
],
CURLOPT_SSL_VERIFYPEER => false,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'http_code' => $httpCode,
'response' => json_decode($response, true) ?: $response,
];
}
$productID = 1;
$payload = [
'price' => 500,
'old_price' => 600,
'stock' => 10,
'active' => 0, // 0 or 1
];
$result = apiRequest('PATCH', $baseUrl . '/products/' . (int)$productID . '/quick', $apiKey, $payload);
Sample Response (JSON)
(
[http_code] => 200
[curl_error] =>
[response] => Array
(
[success] => 1
[message] => Ürün hızlı güncellendi
[lang] => en
[data] => Array
(
[id] => 1
[lang] => en
[name] => Test Product
[slug] => test-product
[url] => http://localhost/fshop/test-product-1
[price] => 500
[old_price] => 600
[stock] => 10
[in_stock] => 1
[active] => 1
[barcode] => 8697595870761
[stock_code] => 349
[id_category] => 4
[category_name] => Elektronik
[id_brand] => 6
[brand_name] => Orzax
[image_url] => http://localhost/fshop/templates/default/img/favicon.png
[has_variations] => 1
[short_description] =>
[description] => <p>Test</p>
[meta_title] =>
[meta_description] =>
[vat] => 20
[doviz] => try
[doviz_price] => 500
[doviz_old_price] => 600
[cargo_day] => 5
[label] => 3 Al 2 Öde
[product_video] =>
[desi] => 1
[images] => Array
(
[0] => Array
(
[id] => 12
[url] => http://localhost/fshop/img/products/12.jpg
[cover] => 1
)
)
[variations] => Array
(
[0] => Array
(
[id] => 1
[id_variation] => 1
[sku] => VAR-9-1
[barcode] =>
[options] => Array
(
[Renk] => Kırmızı
[Beden] => M
)
[price] => 500
[stock] => 5
[active] => 1
)
[1] => Array
(
[id] => 2
[id_variation] => 2
[sku] => VAR-9-2
[barcode] =>
[options] => Array
(
[Renk] => Kırmızı
[Beden] => L
)
[price] => 500
[stock] => 6
[active] => 1
)
)
[translations] => Array
(
[en] => Array
(
[name] => Test Product
[slug] => test-product
[short_description] =>
[description] =>
[description_html] =>
[meta_title] =>
[meta_description] =>
)
[tr] => Array
(
[name] => Test Ürünü
[slug] => test-urun
[short_description] =>
[description] =>
[description_html] =>
[meta_title] =>
[meta_description] =>
)
)
)
)
)