VOOZH about

URL: https://deepwiki.com/gp247net/shop/2-configuration-and-initial-data

⇱ Configuration and Initial Data | gp247net/shop | DeepWiki


Loading...
Menu

Configuration and Initial Data

Purpose and Scope

This document explains how the GP247/Shop package uses database seeders to populate initial system data and how configurations stored in the AdminConfig table drive system behavior at runtime. The shop system relies heavily on configuration-driven design, allowing administrators to control feature enablement, field visibility, validation rules, and business logic without code changes.

For information about the multi-store architecture that affects configuration scope, see Multi-Store and Multi-Vendor Architecture. For details on how configuration values control specific subsystems, see Configuration-Driven System Behavior.


Initialization Architecture

The GP247/Shop package uses a two-phase initialization strategy to separate global system setup from store-specific configuration:


Sources: src/DB/seeders/DataShopInitializeSeeder.php16-28 src/DB/seeders/DataShopDefaultSeeder.php12-33


System Initialization Seeder

The DataShopInitializeSeeder runs once during package installation to establish the foundational data structures required by all stores. This seeder is idempotent and safe to run multiple times.

Administrative Menu Structure

The seeder creates a hierarchical menu structure with six primary blocks:


Implementation: The seeder first deletes existing menu items src/DB/seeders/DataShopInitializeSeeder.php30-48 to ensure clean installation, then inserts the block structure src/DB/seeders/DataShopInitializeSeeder.php54-126 followed by leaf menu items src/DB/seeders/DataShopInitializeSeeder.php137-163

Sources: src/DB/seeders/DataShopInitializeSeeder.php30-163


Reference Data Population

The seeder populates several reference tables that define system-wide lookup values:

Currency Definitions

Two default currencies are inserted:

IDCodeNameSymbolExchange RatePrecisionSymbol First
1USDUSD Dola$121
2VNDVietNam Dong2000000

Sources: src/DB/seeders/DataShopInitializeSeeder.php130-135

Order Status Workflow

The seeder invokes private methods to populate three status types:


These statuses are used throughout the order lifecycle to track payment state, shipping progress, and overall order workflow.

Sources: src/DB/seeders/DataShopInitializeSeeder.php167-174


Admin Dashboard Components

The seeder registers four dashboard components for the admin homepage:


Each component maps to a Blade view in the gp247-shop-admin::component namespace.

Sources: src/DB/seeders/DataShopInitializeSeeder.php178-193


Base Configuration Values

The seeder inserts global configuration keys by calling dataConfigShop() method src/DB/seeders/DataShopInitializeSeeder.php196-197 This populates the AdminConfig table with system-level defaults that are not store-specific.


Multilingual Translations

The seeder populates the Languages table with translations for menu items, form labels, and email templates. Each translation is stored with a unique code, position, and location (language code):


The seeder inserts translations for both Vietnamese (vi) and English (en) src/DB/seeders/DataShopInitializeSeeder.php200-256

Sources: src/DB/seeders/DataShopInitializeSeeder.php200-416


Store Default Configuration Seeder

The DataShopDefaultSeeder runs for each new store created in the system, populating store-specific configurations and interface elements.

Store Context Resolution

The seeder determines which store to configure using session state:


Sources: src/DB/seeders/DataShopDefaultSeeder.php22-29


Configuration Groups

The seeder populates store-specific configurations organized into logical groups:

Group CodePurposeConfiguration Keys
admin_configAdmin interface settingsADMIN_NAME, ADMIN_TITLE, hidden_copyright_footer, hidden_copyright_footer_admin
display_configProduct display limitsproduct_top, product_list, product_relation, product_viewed, item_list, item_top
captcha_configCAPTCHA settingscaptcha_mode, captcha_page, captcha_method
config_layoutUI element visibilitylink_account, link_language, link_currency, link_cart
sendmail_configEmail trigger controlwelcome_customer, order_success_to_admin, order_success_to_customer, contact_to_customer, contact_to_admin

Configuration Structure: Each configuration entry has the following schema:


Sources: src/DB/seeders/DataShopDefaultSeeder.php94-123


Frontend Navigation Links

The seeder creates navigation links attached to the store:


Each link is created with a UUID and attached to the store using the polymorphic relationship src/DB/seeders/DataShopDefaultSeeder.php46-60

Sources: src/DB/seeders/DataShopDefaultSeeder.php35-60


Layout Block Registration

The seeder registers two layout blocks for displaying shop content:


Each block is tied to the store's template and can render on specific pages src/DB/seeders/DataShopDefaultSeeder.php63-88

Sources: src/DB/seeders/DataShopDefaultSeeder.php63-88


Configuration Storage Structure

All configuration values are stored in the AdminConfig table with a hierarchical organization:


Configuration Access Functions

The system provides two helper functions for retrieving configuration values:

FunctionScopeUsage
gp247_config($key, $default)Current store contextGeneral application code
gp247_config_admin($key, $default)Admin-specified storeAdministrative interfaces

Sources: Referenced in src/Views/admin/screen/config_shop/config_sendmail.blade.php8 src/Library/Helpers/order.php10


Configuration-Driven System Behavior

The configuration system drives behavior across multiple subsystems without requiring code changes. This section demonstrates key examples.

Dynamic Order Validation

The gp247_order_mapping_validate() function constructs validation rules dynamically based on configuration values:


Implementation Details:

  • Each customer field (lastname, phone, address, country, postcode, company, etc.) has two configuration keys: one for visibility and one for requirement
  • If customer_[field] config is false, the field is not collected at all
  • If customer_[field]_required is true, validation adds required rule; otherwise nullable
  • Shipping and payment method requirements are also configurable

Sources: src/Library/Helpers/order.php89-210


Email Notification Control

Email sending is controlled by multiple configuration layers:


Configuration Keys:

  • email_action_mode: Master switch for all email functionality (0 = OFF, 1 = ON)
  • order_success_to_admin: Send order notification to store admin
  • order_success_to_customer: Send order confirmation to customer
  • welcome_customer: Send welcome email on registration
  • contact_to_admin: Send contact form submission to admin
  • contact_to_customer: Send contact confirmation to customer

Sources: src/Library/Helpers/order.php7-84 src/Library/Helpers/customer.php85-102


Customer Field Visibility

Customer forms dynamically render fields based on configuration:


This allows different stores to have completely different registration forms based on their regional or business requirements (e.g., Japanese stores can require katakana name fields, European stores can require company tax IDs).

Sources: src/Library/Helpers/customer.php183-395


Display Configuration

Display limits for various product listings are configurable:

Configuration KeyPurposeDefault Value
product_topProducts shown on homepage12
product_listProducts per page in listings12
product_relationRelated products shown4
product_viewedRecently viewed products4
item_listGeneric item listing limit12
item_topTop items display12

These values are queried at runtime when controllers build product queries, affecting pagination and limit clauses.

Sources: src/DB/seeders/DataShopDefaultSeeder.php100-105


Layout Element Visibility

The config_layout group controls visibility of header/footer elements:


This allows stores to hide functionality they don't need (e.g., single-currency stores can hide the currency selector).

Sources: src/DB/seeders/DataShopDefaultSeeder.php109-112


CAPTCHA Configuration

CAPTCHA protection is configurable per page:


Sources: src/DB/seeders/DataShopDefaultSeeder.php106-108


Configuration Management Interface

Administrators can modify configuration values through the admin panel. The sendmail configuration interface demonstrates the pattern:


The interface uses the .check-data-config class with data-store attribute to enable real-time configuration updates without page reloads src/Views/admin/screen/config_shop/config_sendmail.blade.php18

Sources: src/Views/admin/screen/config_shop/config_sendmail.blade.php1-27


Email Template Integration

Email templates reference configuration values to conditionally render content:


Email Templates:

  • email.order_success_to_admin: Notify admin of new order
  • email.order_success_to_customer: Confirm order to customer
  • email.welcome_customer: Welcome new customer registration
  • email.forgot_password: Password reset link
  • email.customer_verify: Email address verification

Each template uses internationalized labels fetched via gp247_language_render() for the current locale.

Sources: src/Views/front/email/order_success_to_admin.blade.php1-68 src/Views/front/email/order_success_to_customer.blade.php1-68 src/Library/Helpers/order.php32-81


Summary

The GP247/Shop configuration system provides:

  1. Two-Phase Initialization: DataShopInitializeSeeder for global setup, DataShopDefaultSeeder for per-store configuration
  2. Hierarchical Storage: Configurations organized by groupcodekey with store isolation
  3. Dynamic Behavior Control: Validation rules, email triggers, field visibility, and business logic driven by database values
  4. Runtime Access: Helper functions (gp247_config, gp247_config_admin) provide simple configuration retrieval
  5. Administrative Interface: Web-based configuration management with real-time updates

This architecture allows the same codebase to support dramatically different store behaviors and requirements through configuration alone, enabling multi-tenant and international deployments without code customization.