Create Product Variant
Create a new product variant with automatic translation to multiple languages.
Endpoint
Authentication
Required (Store role)
Request Body
Content-Type: multipart/form-data
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
product_id |
integer | Yes | ID of the parent product |
name |
string | Yes | Product name in store's preferred language |
description |
string | Yes | Product description in store's preferred language |
sku |
string | Yes | Stock Keeping Unit identifier |
price |
float | Yes | Product price |
stock_quantity |
integer | Yes | Available stock quantity |
json_data |
string | Yes | JSON string of product attributes |
JSON Data Format
The json_data field should be a JSON string containing an array of attribute objects:
Response
Success (200 OK)
{
"product_variant": {
"id": 10,
"product_id": 5,
"product": {
"id": 5,
"store_id": 3,
"store": {...},
"category_id": 2,
"category": {...},
"brand_id": 1,
"brand": {...},
"currency_id": 1,
"currency": {...},
"created": "2025-01-15T10:30:00Z"
},
"name_az": "Məhsul Adı",
"name_en": "Product Name",
"name_es": "Nombre del Producto",
"name_de": "Produktname",
"description_az": "Məhsul Təsviri",
"description_en": "Product Description",
"description_es": "Descripción del Producto",
"description_de": "Produktbeschreibung",
"sku": "SKU-001",
"stock_quantity": 100,
"price": 99.99,
"attributes": [
{
"id": 1,
"attribute_id": 1,
"attribute_name": "Color",
"attribute_type": "select",
"value": "Red",
"is_filter": true,
"is_view": true
}
],
"images": [],
"created": "2025-01-15T10:30:00Z"
},
"product_attributes": [
{
"id": 1,
"product_variant_id": 10,
"attribute_id": 1,
"attribute": {...},
"value": "Red",
"created": "2025-01-15T10:30:00Z"
}
]
}
Error Responses
Product Not Found (404)
Validation Error (400)
Example Request
curl -X POST "https://api.luxmart.site/v1/products/variant/store/" \
-H "Authorization: Token your_access_token" \
-F "product_id=5" \
-F "name=Red T-Shirt" \
-F "description=Comfortable cotton t-shirt" \
-F "sku=TSH-RED-L" \
-F "price=29.99" \
-F "stock_quantity=50" \
-F 'json_data=[{"attribute_id":1,"value":"Red"},{"attribute_id":2,"value":"Large"}]'
Notes
- Product name and description are automatically translated to: az, en, es, de
- Translation uses Google Cloud Translation API
- Source language is determined by store's preferred language
- Product must belong to the authenticated store
- Variant status is automatically set to "1" (Approved)