PATCH https://example.com/api/v1/product/{product_id}

Update Product

Updates an existing product. Only the fields you send will be updated (partial update).

URL Parameters

ParameterTypeDescription
product_idintegerID 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,
	];
}
$payload = [
	'name' => "Test Name",
	'category' => "Category Name",
	'brand' => "Test",
	'cost' => 100,
	'price' => 299.51,
	'stock' => 1,
	'active' => 1,
	'barcode' => "AS85551212",
	'stock_code' => "fs123",
	'description_html' => "<p>Test</p><p>Test 2</p>"
];
$productID = 1; // The ID number of the product to be updated.
$result = apiRequest('PATCH', $baseUrl . '/products/' . (int)$productID, $apiKey, $payload);
Sample Response (JSON)
(
    [http_code] => 200
    [curl_error] => 
    [response] => Array
        (
            [success] => 1
            [message] => Product updated
            [data] => Array
                (
                    [id] => 6
                    [name] => Test Name
                    [slug] => test-name
                    [url] => http://localhost/frisay/category-name/test-name-6
                    [price] => 299.51
                    [old_price] => 0
                    [stock] => 1
                    [in_stock] => 1
                    [active] => 1
                    [barcode] => AS85551212
                    [stock_code] => fs123
                    [id_category] => 6
                    [category_name] => Category Name
                    [id_brand] => 5
                    [brand_name] => Test
                    [image_url] => http://localhost/frisay/templates/default/img/favicon.png
                    [short_description] => 
                    [description] => Test Test 2
                    [description_html] => <p>Test</p><p>Test 2</p>
                    [meta_title] => 
                    [meta_description] => 
                    [vat] => 20
                    [doviz] => try
                    [doviz_price] => 299.51
                    [doviz_old_price] => 0
                    [cargo_day] => 0
                    [label] => 
                    [product_video] => 
                    [desi] => 0
                    [images] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 1
                                    [url] => http://localhost/frisay/img/products/1.jpg
                                    [cover] => 1
                                )

                        )

                )

        )

)