Skip to content

Product Module

Faisol Chehumar edited this page Feb 26, 2022 · 20 revisions

Tables

products

Field Constraints Type Description
brand_id FK VARCHAR(255) UUID of the Brand (refer to brands table).
name NN VARCHAR(12)
product_number NN, U VARCHAR(12) Product code from manufacturer.
description VARCHAR(255) Description can be html tag or plain text.
shop_location VARCHAR(255)
warranty_days NN INTEGER Warranty for product in day. Default 0

product_images

Field Constraints Type Description
product_id NN, FK VARCHAR(255) UUID of the Product (refer to products table).
image NN VARCHAR(255) Url Image for product thumbnail.

product_skus

Field Constraints Type Description
product_id NN, FK VARCHAR(255) UUID of the Product (refer to products table).
sku NN, U VARCHAR(255) SKU Code use for communicate with supplier.
image VARCHAR(255) Url Image for product thumbnail.
regular_price NN INT(5)
sale_price INT(5)
unit_in_stock NN INT(5) Unit of sku in stock. Default 0

product_ratings

Field Constraints Type Description
product_sku_id NN, FK VARCHAR(255) UUID of the Product sku (refer to product_skus table).
order_id NN VARCHAR(255) UUID of the Order (refer to order table).
rating NN INT(5) Rating min = 0, max = 5

product_sku_discounts

Field Constraints Type Description
product_sku_id NN, FK UUID UUID of the Product (refer to products table).
type NN VARCHAR(255) UUID of the Product Attribute (refer to product_attributes table).
value NN INTEGER UUID of the Product Attribute (refer to product_attributes table).
start_date NN DATETIME UUID of the Product Attribute (refer to product_attributes table).
end_date DATETIME UUID of the Product Attribute (refer to product_attributes table).

product_variants

Field Constraints Type Description
product_sku_id NN, FK VARCHAR(255) UUID of the Product (refer to products table).
product_attribute_id NN, FK VARCHAR(255) UUID of the Product Attribute (refer to product_attributes table).

product_attributes

Field Constraints Type Description
name NN VARCHAR(255) Name of attribute Ex. Size, Color Etc.

product_attribute_options

Field Constraints Type Description
product_attribute_id NN, FK VARCHAR(255) UUID of the Product Attribute (refer to product_attributes table).
name VARCHAR(255) Name of attributes options Ex. XXL, XL, MD, SM and XS

brands

Field Constraints Type Description
name NN, U VARCHAR(12)

Queries

Search product

POST /product/search?keyword={keyword}

  • ใช้สำหรับให้ค้นหาสินค้า

Request param

Name Type Required Value Rule Description
keyword String Y NMD

Response Example

{
  "success": true,
  "data": {
    "total_count": 533,
    "count": 10,
    "products": [
      {
         "id": "40a7089e-f5a7-433d-81b8-6e4c4a2b037d",
         "name": "รองเท้า NMD",
         "image": "https://cdn.foodddthailand.com/vender/Deli-veggies/products/xmKk71WGULRiP1zEb8FuUsaYMozijcRrRNs3.png",
         "regular_price_min": 1000,
         "regular_price_max": 1000,
         "percent_discount_min": 10,
         "percent_discount_max": 50,
         "sale_price_min": 400,
         "sale_price_max": 900,
         "shop_location": "กรุงเทพ",
         "rating_star": 4.8
      }
    ]
  }
}

Get product detail

POST /products/{product_id}

  • ใช้สำหรับขอรายละเอียดสินค้า

Response Example

{
  "success": true,
  "data": {
    "id": "40a7089e-f5a7-433d-81b8-6e4c4a2b037d",
    "name": "รองเท้า NMD",
    "description": "<p>ชาใสในรูปของชาผลไม้<br />มีกลิ่นพีช เปรี้ยวนิดๆ แช่เย็นดื่มสดชื่น</p>",
    "product_number": "551021234677",
    "images": ["https://cdn.foodddthailand.com/vender/Deli-veggies/products/xmKk71WGULRiP1zEb8FuUsaYMozijcRrRNs3.png"],
    "regular_price_min": 999,
    "regular_price_max": 999,
    "sale_price_min": 999,
    "sale_price_max": 999,
    "percent_discount_min": null,
    "percent_discount_max": null,
    "warranty_days": 14,
    "rating": {
      "rating_count": 1723,
      "rating_star": 4.8
    },
    "attributes": [
      { 
        "name": "size"
        "value": ["sm", "md", "xl"]
      },
      { 
        "name": "color"
        "value": ["black", "red"]
      }
    ],
    "variants": [
      {
        "sku": "NMD-BL-XL",
        "regular_price": 999,
        "sale_price": 500,
        "percent_discount": 15,
        "unit_in_stock": 10,
        "attribute_index": [2, 1],
        "image": "https://cdn.foodddthailand.com/vender/Deli-veggies/products/xmKk71WGULRiP1zEb8FuUsaYMozijcRrRNs3.png"
      }
    ]
 }
}

Exception

Error Code Error Message Description
PRODUCT_NOT_FOUNDED Username or password incorrect.

Error Example

{
  "success": false,
  "error": "Product not found.",
}