Skip to content

Product Variant Model

The Product Variant model represents a sellable product with specific attributes, pricing, and inventory. This is the actual item that customers can purchase.

Structure

{
  "id": 1,
  "product_id": 5,
  "product": {
    "id": 5,
    "store_id": 3,
    "store": {...},
    "category_id": 2,
    "category": {...},
    "brand_id": 1,
    "brand": {...},
    "currency_id": 1,
    "currency": {...}
  },
  "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": 29.99,
  "attributes": [
    {
      "id": 1,
      "attribute_id": 1,
      "attribute_name": "Color",
      "attribute_type": "select",
      "value": "Red",
      "is_filter": true,
      "is_view": true
    }
  ],
  "images": [
    {
      "id": 1,
      "order": 1,
      "image": "https://..."
    }
  ],
  "created": "2025-01-15T10:30:00Z"
}

Fields

Field Type Description Notes
id integer Unique identifier Auto-increment, primary key
product_id integer Parent product ID Required, foreign key to ProductModel
sku string Stock Keeping Unit Required, unique identifier
price float Product price Required, in product's currency
stock_quantity integer Available stock Required, must be >= 0
status string Product status "1" = Approved (active)
is_deleted boolean Soft delete flag Default: false
created datetime Creation timestamp Auto-generated
updated datetime Last update timestamp Auto-updated

Translation Fields

Product variants support multi-language names and descriptions through the ProductVariantTranslationModel:

Field Type Description
name_az string Name in Azerbaijani
name_en string Name in English
name_es string Name in Spanish
name_de string Name in German
description_az string Description in Azerbaijani
description_en string Description in English
description_es string Description in Spanish
description_de string Description in German

Status Values

  • "1" - Approved (active, can be purchased)
  • "2" - Reject
  • "3" - Waiting
  • "4" - Expired

Relationships

  • ProductModel: Many-to-one relationship with parent product
  • ProductVariantTranslationModel: One-to-many relationship with translations
  • ProductVariantAttributeModel: One-to-many relationship with attributes
  • ProductVariantImageModel: One-to-many relationship with images
  • ProductVariantBasketModel: One-to-many relationship with basket items
  • ProductVariantWishlistModel: One-to-many relationship with wishlist items
  • OrderModel: One-to-many relationship with orders

Notes

  • SKU must be unique across all variants
  • Stock quantity is decremented when orders are successfully paid
  • Translations are automatically created when a variant is created (using Google Translate API)
  • Attributes define variant-specific properties (e.g., color, size)
  • Images are ordered by order_image field
  • Only variants with status: "1" and is_deleted: false are visible on the public site