Skip to content

E-Commerce Core Concepts

InnoShop has five core data models: Category, Brand, Specification (Variant), Option, and Attribute. Understanding their differences and use cases is fundamental for customization.

Concept Comparison

ConceptPurposeAffects PriceAffects StockRelationship
CategoryOrganize productsMany-to-many (product_categories)
BrandIdentify manufacturerOne-to-many (brand_id)
SpecificationProduct variant SKUOne-to-many (product_skus)
OptionValue-added serviceMany-to-many (product_options)
AttributeProduct specs displayMany-to-many (product_attributes)

1. Category

Organize products in a hierarchy for navigation and filtering.

Electronics
  └── Phones
       └── Smartphones

Features: Tree hierarchy (parent_id), multi-category per product, SEO support, multi-language.

Database Tables: categories (main), category_translations, product_categories (pivot)

Code Location: innopacks/common/src/Models/Category.php, Repositories/CategoryRepo.php

php
$category->children();        // Child categories
$category->activeChildren();  // Active children
$category->parent();          // Parent category
$category->products();        // Products in category

2. Brand

Identify the product manufacturer for brand-based filtering.

Features: Direct brand_id foreign key, brand logo support, first-letter filtering.

Database Tables: brands (main, no translation table needed)

Code Location: innopacks/common/src/Models/Brand.php, Repositories/BrandRepo.php

php
$brand->products();
BrandRepo::getInstance()->autocomplete($keyword);

3. Specification (Variant)

Define different product versions/SKUs. Each specification combination maps to an independent stock unit.

Spec ComboSKU CodePriceStock
Red - LargeSKU-001$9950
Red - MediumSKU-002$8930

Features: Independent SKU, pricing, stock, and code per variant. Spec data stored as JSON in products.variables.

Example products.variables JSON:

json
{
  "color": {
    "name": {"en": "Color", "zh-cn": "颜色"},
    "values": {
      "red": {"name": {"en": "Red", "zh-cn": "红色"}},
      "blue": {"name": {"en": "Blue", "zh-cn": "蓝色"}}
    }
  }
}

Database Tables: products.variables (JSON), product_skus

Code Location: Models/Product.php, Models/Product/Sku.php, Repositories/Product/SkuRepo.php

php
$product->skus();          // All SKUs
$product->masterSku();     // Master SKU
$product->isMultiple();    // Has multiple variants?
$product->variables;       // Variant definitions

4. Option

Value-added services or add-ons selectable during purchase. These are supplementary services, not product variants.

Option NameValuesPrice Impact
Gift WrapStandard / Gift Box+$10
Warranty1-year / 2-year extended+$99

Features: Price adjustment, required/optional, select/radio/checkbox display types, multi-language JSON.

Database Tables: options, option_values, product_options, product_option_values

Code Location: Models/Option.php, Models/OptionValue.php, Repositories/OptionRepo.php

php
$product->options();           // Product options
$product->productOptions();    // Option configurations
$option->values();             // Option values

5. Attribute

Describe product specifications and technical parameters for detail page display and category page filtering.

AttributeValue
MaterialCotton
Weight500g

Features: Product spec display, filtering, grouped management. Filter logic: different attribute groups use AND, values within the same group use OR.

Filter URL format: attr=1:10,11|2:20 means (attr1=value10 OR value11) AND (attr2=value20)

Database Tables: attributes, attribute_translations, attribute_groups, attribute_values, product_attributes

Code Location: Models/Attribute.php, Models/Attribute/Group.php, Repositories/AttributeRepo.php

php
$product->productAttributes();    // Product attributes
$product->groupedAttributes();    // Grouped attributes
$attribute->group();              // Attribute group
$attribute->values();             // Attribute values