Commercio Docs

Products

Manage your products with SKU support. Products must belong to a category.

Product Creation Flow

How products are created with category validation

Product Creation Process

100%
Loading diagram...

Important

Products must be assigned to a category. Create a category first before creating products.

Create Product

Create a new product with SKU and category

import { createProductService, createCategoryService } from "commercio";

const productService = createProductService();
const categoryService = createCategoryService();

// First, create a category
const category = await categoryService.createCategory("Electronics");

// Create product (categoryId is required)
const product = await productService.createProduct(
  "Laptop Dell XPS 15",
  "SKU-LAPTOP-001",
  category.id
);

Product Operations

Get Product

Retrieve products by ID or SKU

// Get by ID
const product = await productService.getProductById(productId);

// Get by SKU
const product = await productService.getProductBySku("SKU-LAPTOP-001");