Update Product Variant
Update an existing product variant. Supports updating translations, attributes, and variant details.
Endpoint
Authentication
Required (Store role)
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Yes | Variant ID |
Request Body
Content-Type: multipart/form-data
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
product_id |
integer | Yes | Product ID |
name_az |
string | No | Name in Azerbaijani |
name_en |
string | No | Name in English |
name_es |
string | No | Name in Spanish |
name_de |
string | No | Name in German |
description_az |
string | No | Description in Azerbaijani |
description_en |
string | No | Description in English |
description_es |
string | No | Description in Spanish |
description_de |
string | No | Description in German |
sku |
string | No | Stock Keeping Unit |
price |
float | No | Product price |
stock_quantity |
integer | No | Available stock quantity |
json_data |
string | No | JSON string for updating/adding attributes |
delete_data |
string | No | Comma-separated attribute IDs to delete |
JSON Data Format
The json_data field should be a JSON string containing an array of attribute objects:
[
{
"id": 1,
"attribute_id": 1,
"value": "Updated Red"
},
{
"id": 0,
"attribute_id": 2,
"value": "Large"
}
]
- If
idis provided and > 0, the attribute is updated - If
idis 0 or not provided, a new attribute is created
Response
Success (200 OK)
{
"id": 1,
"product_id": 5,
"product": {...},
"name_az": "Yenilənmiş Məhsul",
"name_en": "Updated Product",
"sku": "SKU-001-UPDATED",
"stock_quantity": 150,
"price": 39.99,
"attributes": [...],
"images": [...],
"created": "2025-01-15T10:30:00Z"
}
Error Responses
Product Not Found (404)
Variant Not Found (404)
Attribute Not Found (404)
Example Request
curl -X PUT "https://api.luxmart.site/v1/products/variant/store/?id=1" \
-H "Authorization: Token your_access_token" \
-F "product_id=5" \
-F "name_en=Updated Product Name" \
-F "price=39.99" \
-F "stock_quantity=150" \
-F 'json_data=[{"id":1,"attribute_id":1,"value":"Updated Red"}]' \
-F "delete_data=3,4"
Notes
- Only provided fields are updated
- Product must belong to the authenticated store
- Variant must belong to the specified product
- Attributes can be updated, added, or deleted
- Translation fields update the corresponding language translations