VOOZH about

URL: https://deepwiki.com/gp247net/shop/3-product-management-system

⇱ Product Management System | gp247net/shop | DeepWiki


Loading...
Menu

Product Management System

The Product Management System is the core catalog management component of GP247/Shop, providing comprehensive functionality for organizing and managing product data. This system encompasses four primary entities: Products, Categories, Brands, and Suppliers, along with their supporting models for multilingual descriptions, images, attributes, and store associations.

This page provides an overview of the catalog architecture and entity relationships. For detailed information on specific components, see:

System Architecture

The product catalog is organized around four core entities with supporting models for descriptions, relationships, and metadata.

Catalog Entity Relationship Diagram


Sources: src/Models/ShopProduct.php40-87 src/Models/ShopCategory.php23-35

Core Database Schema

TablePurposeKey Fields
shop_productMain product recordsid, sku, alias, price, stock, kind, brand_id, supplier_id
shop_categoryHierarchical categoriesid, alias, parent, top, sort, status
shop_brandProduct brandsid, name, alias, image, status
shop_supplierProduct suppliersid, name, alias, email, phone, store_id
shop_product_categoryProduct-category M:Nproduct_id, category_id
shop_product_storeProduct-store M:Nproduct_id, store_id
shop_product_descriptionProduct i18n contentproduct_id, lang, name, description, content
shop_category_descriptionCategory i18n contentcategory_id, lang, title, description
shop_product_imageProduct image galleryproduct_id, image, sort
shop_product_attributeProduct attributesproduct_id, attribute_group_id, name, add_price
shop_product_promotionPromotional pricingproduct_id, price_promotion, date_start, date_end
shop_product_buildBundle componentsbuild_id, product_id, quantity
shop_product_groupProduct variantsgroup_id, product_id

Sources: src/Models/ShopProduct.php22 src/Models/ShopCategory.php16

Product Entity

The ShopProduct model src/Models/ShopProduct.php17-939 is the central entity in the catalog system, storing product information, pricing, inventory, and relationships.

Product Types

Products are classified by the kind field src/Models/ShopProduct.php27:

KindConstantDescriptionImplementation
0GP247_PRODUCT_SINGLESingle standalone productStandard product with stock tracking
1GP247_PRODUCT_BUILDProduct bundleCollection of products sold together; stock updates cascade to components src/Models/ShopProduct.php409-416
2GP247_PRODUCT_GROUPProduct groupVariants of the same product (e.g., different sizes/colors)

Product Tags

Products are further classified by the tag field src/Models/ShopProduct.php28:

TagTypeDescription
0PhysicalTangible products requiring shipping
1DownloadDigital downloadable products
2View OnlyDisplay-only products (not purchasable)
3ServiceService-based offerings

Key Product Methods

MethodPurposeLocation
getDetail($key, $type, $storeId, $checkActive)Retrieve single product with all relationshipssrc/Models/ShopProduct.php192-258
getFinalPrice()Calculate effective price (regular or promotional)src/Models/ShopProduct.php115-123
allowSale()Determine if product can be purchasedsrc/Models/ShopProduct.php358-377
updateStock($product_id, $qty_change)Update stock and sold countssrc/Models/ShopProduct.php399-418
buildQuery()Build filtered product querysrc/Models/ShopProduct.php703-868

Product Relationships

The ShopProduct model defines these Eloquent relationships src/Models/ShopProduct.php40-87:


For detailed product business logic, pricing, and query operations, see Product Model and Business Logic

Sources: src/Models/ShopProduct.php17-939

Category Entity

The ShopCategory model src/Models/ShopCategory.php10-298 provides hierarchical organization for products using a parent-child tree structure.

Category Structure

Categories form a three-level hierarchy:


Sources: src/Models/ShopCategory.php20-22 src/Models/ShopCategory.php291-296

Category Properties

FieldTypeDescription
idstring (UUID)Auto-generated unique identifier
aliasstringURL-friendly slug for routing
imagestringCategory thumbnail image path
parentstringParent category ID (null/empty = root)
topbooleanDisplay in top navigation (1=yes)
statusbooleanActive status (1=active)
sortintegerDisplay order within parent

Sources: src/Models/ShopCategory.php16-22

Key Category Methods

MethodPurposeLocation
getDetail($key, $type, $checkActive)Retrieve category with descriptionssrc/Models/ShopCategory.php126-156
getListSub($cId)Get all subcategory IDs recursivelysrc/Models/ShopCategory.php291-296
getCategoryRoot()Filter to root categories onlysrc/Models/ShopCategory.php195-199
getCategoryTop()Filter to top navigation categoriessrc/Models/ShopCategory.php202-208
buildQuery()Build filtered category querysrc/Models/ShopCategory.php213-282

Category Relationships


Sources: src/Models/ShopCategory.php23-35

Category Administration

The AdminCategoryController src/Admin/Controllers/AdminCategoryController.php10-407 provides CRUD operations:

Categories support multilingual descriptions, multi-store assignment, custom fields, and SEO metadata.

For detailed category operations and frontend display, see Category Management

Sources: src/Models/ShopCategory.php10-298 src/Admin/Controllers/AdminCategoryController.php10-407

Brand Entity

The ShopBrand model represents product manufacturers or brand identities. While the model file is not included in the provided sources, it follows the same architectural patterns as products and categories.

Brand Properties

Brands contain these core fields:

FieldDescription
idAuto-generated UUID identifier
nameBrand display name
aliasURL-friendly slug
imageBrand logo image path
urlExternal brand website
sortDisplay order
statusActive status (1=active)

Brand Relationships


Brands support multi-store assignment and can be filtered in product queries. Products optionally belong to a single brand via the brand_id foreign key src/Models/ShopProduct.php40-43

Sources: src/Models/ShopProduct.php40-43 src/Commands/ShopSample.php433-467

Supplier Entity

The ShopSupplier model represents vendors or suppliers that provide products. Suppliers are store-specific entities used in multi-vendor scenarios.

Supplier Properties

FieldDescription
idAuto-generated UUID identifier
nameSupplier display name
aliasURL-friendly slug
emailContact email address
phoneContact phone number
imageSupplier logo image path
addressPhysical address
urlExternal supplier website
store_idAssociated store (for multi-vendor)
sortDisplay order
statusActive status (1=active)

Products optionally belong to a single supplier via the supplier_id foreign key src/Models/ShopProduct.php45-48

Sources: src/Models/ShopProduct.php45-48 src/Commands/ShopSample.php469-515

Multi-Language Support

All catalog entities support internationalization through separate description tables.

Localization Architecture


Sources: src/Models/ShopProduct.php71-110 src/Models/ShopCategory.php32-53

Description Access Methods

All entities provide consistent methods for accessing localized content:

MethodPurposeLocation
getText()Get description record for current localesrc/Models/ShopProduct.php90-93
getName() / getTitle()Get localized name/titlesrc/Models/ShopProduct.php94-97
getDescription()Get short descriptionsrc/Models/ShopProduct.php98-101
getKeyword()Get SEO keywordssrc/Models/ShopProduct.php102-105
getContent()Get full HTML content (products only)src/Models/ShopProduct.php106-109

The current locale is determined by gp247_get_locale() and automatically filters description queries throughout the system.

Sources: src/Models/ShopProduct.php89-110 src/Models/ShopCategory.php36-53

Multi-Store Architecture

The catalog system implements a hybrid multi-tenant architecture where products, categories, and brands can be shared or isolated across stores.

Store Association Pattern


Sources: src/Models/ShopProduct.php58-61 src/Models/ShopProduct.php713-739 src/Models/ShopCategory.php27-30

Store Filtering in Queries

Product and category queries automatically apply store filters when multi-store is enabled:


Key Implementation Points:

  1. Catalog Sharing: Products, categories, and brands don't have store_id columns; they use junction tables for M:N relationships src/Models/ShopProduct.php58-61
  2. Automatic Filtering: buildQuery() methods automatically join and filter by store src/Models/ShopProduct.php714-730
  3. Root Store Access: When config('app.storeId') == GP247_STORE_ID_ROOT, all stores' products are accessible src/Models/ShopProduct.php207-211
  4. Vendor Isolation: Non-root stores only see products assigned to their store src/Models/ShopProduct.php225-233

Sources: src/Models/ShopProduct.php58-61 src/Models/ShopProduct.php703-741 src/Models/ShopCategory.php231-238

Sample Data Generation

The system includes a comprehensive sample data generator for testing and demonstration purposes.

ShopSample Command

The gp247:shop-sample command src/Commands/ShopSample.php20-633 creates a complete sample catalog:

Generated Data:

EntityCountDetails
Categories164 root categories with 3 subcategories each
Brands3Nike, Adidas, Puma
Suppliers3ABC Corp, XYZ Inc, DEF Ltd
Products (Single)363 per subcategory with promotions
Products (Bundle)3Bundles of single products
Products (Group)3Product variants

Category Structure Example:

Ẩm thực (Food)
├── Phở Nam Định
├── Nem chua Thanh Hóa
└── Bún Chả Hà Nội

Du lịch (Travel)
├── Vịnh Hạ Long
├── Động Phong Nha
└── Tràng An

Văn hóa (Culture)
├── Gốm Bát Tràng
├── Tranh Đông Hồ
└── Chiếu cói Nga Sơn

Trái cây (Fruits)
├── Trái Cây Nam Bộ
├── Vải Thiều
└── Nhãn Lồng

Sources: src/Commands/ShopSample.php59-632

Usage:


This command is useful for:

  • Initial system testing
  • Demonstration environments
  • Development and debugging
  • Understanding data structure relationships

Sources: src/Commands/ShopSample.php20-633

Product Multi-Language Support

The Product Management System supports multiple languages through dedicated description tables.


Sources: src/Models/ShopProduct.php71-110 src/Models/ShopCategory.php32-53

The multi-language system:

  1. Stores language-specific content (name, description, keywords, content) in separate description tables
  2. Uses the current locale to determine which language version to retrieve
  3. Provides helper methods to easily access translated content
  4. Is consistent across products, categories, and other entities

Key language-related methods:

  • getText(): Retrieves the description record for the current language
  • getName(), getDescription(), etc.: Convenience methods to directly access translated fields

Sources: src/Models/ShopProduct.php89-110 src/Models/ShopCategory.php36-53

Conclusion

The Product Management System in the GP247/Shop platform provides a comprehensive set of models, relationships, and methods for managing all aspects of product data. From basic product information to complex pricing, categorization, and multi-store support, the system is designed to be flexible, efficient, and feature-rich.

This system forms the foundation of the shop's catalog functionality and integrates with other systems such as the Shopping Cart, Order Processing, and Frontend Display components.

For details on how products are displayed on the frontend, see Product Frontend Display.