Perfect — updating a product via PrestaShop Webservice API is a bit stricter than creating one, so I’ll walk you through the safe + correct way 👇
(If you skip steps, PrestaShop throws a 500 😅)
Core Rule (Don’t Skip This)
👉 UPDATE = GET → MODIFY → PUT
You cannot send partial XML like other APIs.
1️⃣ Know the Product ID
Example:
Product ID = 123
Update endpoint:
/api/products/123
2️⃣ Get Existing Product XML
This is mandatory.
CURL
curl -X GET "https://yourstore.com/api/products/123" \
-u API_KEY:
This returns full product XML.
3️⃣ Modify Only What You Need
Common updates:
- price
- name
- active
- description
- category
- SEO fields
⚠️ Do NOT remove nodes
⚠️ Keep <id>123</id> inside <product>
4️⃣ Sample XML – Update Product
<?xml version="1.0" encoding="UTF-8"?>
<prestashop>
<product>
<id>123</id>
<price>1199</price>
<active>1</active>
<name>
<language id="1">Updated Product Name</language>
</name>
<link_rewrite>
<language id="1">updated-product-name</language>
</link_rewrite>
</product>
</prestashop>
5️⃣ PUT Request (Update Product)
curl -X PUT "https://yourstore.com/api/products/123" \
-u API_KEY: \
-H "Content-Type: application/xml" \
-d @product-update.xml
✅ Success → 200 OK
6️⃣ PHP Example – Update Product
$apiKey = 'YOUR_API_KEY';
$productId = 123;
$url = "https://yourstore.com/api/products/$productId";
// Step 1: Get product
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => $apiKey . ':'
]);
$xml = curl_exec($ch);
curl_close($ch);
// Step 2: Modify XML
$xmlObj = simplexml_load_string($xml);
$xmlObj->product->price = 1199;
$xmlObj->product->name->language[0] = 'Updated Product Name';
// Step 3: PUT update
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_USERPWD => $apiKey . ':',
CURLOPT_HTTPHEADER => ['Content-Type: application/xml'],
CURLOPT_POSTFIELDS => $xmlObj->asXML()
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
7️⃣ Updating Stock (Separate API ❗)
Price ≠ quantity.
Get stock ID
/api/stock_availables?filter[id_product]=123
Update stock quantity
<prestashop>
<stock_available>
<id>STOCK_ID</id>
<quantity>50</quantity>
</stock_available>
</prestashop>
PUT to:
/api/stock_availables/STOCK_ID
8️⃣ Common Errors & Fixes
| Error | Cause | Fix |
|---|---|---|
| 500 | Missing XML fields | Use GET → PUT flow |
| 401 | Auth issue | Check API key |
| 403 | Permission | Enable PUT for products |
| 406 | Wrong lang ID | Use correct language ID |
| Update succeeds but not visible | Cache | Clear PS cache |
9️⃣ Best Practices (Battle-tested)
✔ Always GET before PUT
✔ Keep product <id>
✔ Use XML for updates
✔ Don’t touch manufacturer_name
✔ Stock updated separately
✔ Clear cache after bulk updates
