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
| Concept | Purpose | Affects Price | Affects Stock | Relationship |
|---|---|---|---|---|
| Category | Organize products | ❌ | ❌ | Many-to-many (product_categories) |
| Brand | Identify manufacturer | ❌ | ❌ | One-to-many (brand_id) |
| Specification | Product variant SKU | ✅ | ✅ | One-to-many (product_skus) |
| Option | Value-added service | ✅ | ✅ | Many-to-many (product_options) |
| Attribute | Product specs display | ❌ | ❌ | Many-to-many (product_attributes) |
1. Category
Organize products in a hierarchy for navigation and filtering.
Electronics
└── Phones
└── SmartphonesFeatures: 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
$category->children(); // Child categories
$category->activeChildren(); // Active children
$category->parent(); // Parent category
$category->products(); // Products in category2. 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
$brand->products();
BrandRepo::getInstance()->autocomplete($keyword);3. Specification (Variant)
Define different product versions/SKUs. Each specification combination maps to an independent stock unit.
| Spec Combo | SKU Code | Price | Stock |
|---|---|---|---|
| Red - Large | SKU-001 | $99 | 50 |
| Red - Medium | SKU-002 | $89 | 30 |
Features: Independent SKU, pricing, stock, and code per variant. Spec data stored as JSON in products.variables.
Example products.variables 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
$product->skus(); // All SKUs
$product->masterSku(); // Master SKU
$product->isMultiple(); // Has multiple variants?
$product->variables; // Variant definitions4. Option
Value-added services or add-ons selectable during purchase. These are supplementary services, not product variants.
| Option Name | Values | Price Impact |
|---|---|---|
| Gift Wrap | Standard / Gift Box | +$10 |
| Warranty | 1-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
$product->options(); // Product options
$product->productOptions(); // Option configurations
$option->values(); // Option values5. Attribute
Describe product specifications and technical parameters for detail page display and category page filtering.
| Attribute | Value |
|---|---|
| Material | Cotton |
| Weight | 500g |
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
$product->productAttributes(); // Product attributes
$product->groupedAttributes(); // Grouped attributes
$attribute->group(); // Attribute group
$attribute->values(); // Attribute values