- stack.md - PrestaShop 1.7.x, PHP, Smarty, SCSS, modules - architecture.md - MVC + hooks, override mechanism, CQRS in src/ - structure.md - Directory layout, key file locations - conventions.md - PHP/Smarty/SCSS/JS conventions, PS patterns - testing.md - No automated tests in custom modules - integrations.md - Allegro, Empik, BaseLinker, shipping, payments - concerns.md - Override fragility, EOL risk, missing CI/CD - db_schema.md - Custom tables, modified core tables Co-Authored-By: Claude <noreply@anthropic.com>
5.3 KiB
5.3 KiB
Architecture
Analysis Date: 2026-04-27
Pattern Overview
Overall: PrestaShop 1.7.x MVC Monolith with Hook System and Override Mechanism
Key Characteristics:
- Hook-based extensibility (modules register to hooks, PrestaShop fires them)
- Override mechanism (modules replace core classes by copying to
override/) - Smarty MVC — controllers prepare data, templates render it
- 133 modules active, many with overrides and custom hooks
- Symfony components embedded (service container, YAML) in PS 1.7 core
Layers
Core PrestaShop Layer:
- Purpose: Framework, models, standard controllers
- Contains:
classes/(models),controllers/(base front/admin),config/ - Key entry:
config/config.inc.php,config/bootstrap.php
Override Layer:
- Purpose: Replace core classes/controllers without touching core files
- Contains:
override/classes/,override/controllers/,override/modules/ - Critical overrides:
override/classes/order/Order.php,override/classes/Hook.php,override/classes/Dispatcher.php - Depends on: Core layer
- Risk: Multiple modules contributing to same override file
Module Layer:
- Purpose: Business features, marketplace integrations, shipping, payments
- Contains:
modules/(133 modules) - Custom modules:
modules/customfeaturetab/,modules/AddOrderExtraFields/ - Hook registrations in each module's
install()method - Depends on: Override layer + Core layer
Theme Layer:
- Purpose: Frontend rendering
- Contains:
themes/InterBlue/templates/(Smarty .tpl) - Assets:
themes/InterBlue/assets/css/,themes/InterBlue/assets/js/ - Depends on: Module layer (hook output inserted into templates)
CQRS Extension Layer (src/):
- Purpose: Modern query handling for Order domain
- Contains:
src/Adapter/Order/QueryHandler/GetOrderForViewingHandler.php - Interface:
src/Core/Domain/Order/QueryHandler/GetOrderForViewingHandlerInterface.php - Result objects:
src/Core/Domain/Order/QueryResult/ - Pattern: Adapter bridging legacy PrestaShop to CQRS
Data Flow
Frontend HTTP Request:
- HTTP request hits
index.php Dispatcher(overridden by fsadvancedurl) matches URL to controller- Front controller executes (e.g.,
ProductController) - Controller loads model data, fires hooks
- Smarty renders
.tpltemplate with data - Module hook outputs inserted at hook positions
- Response returned
Order Creation:
- Customer submits checkout (via
onepagecheckoutps—override/controllers/front/OrderController.php) PaymentModule::validateOrder()called (overridden inmodules/AddOrderExtraFields/override/classes/PaymentModule.php)actionBeforeAddOrderhook fires (override/classes/order/Order.php— modrefchange)- Order saved to DB with
order_sourcefield (Allegro/Sklep int./Telefonicznie) actionBeforeAddOrderInvoice,actionBeforeAddDeliveryNumberhooks fire- x13allegro module checks if Allegro order, suppresses customer emails if so
State Management:
- Stateless HTTP requests — all state in MySQL database
- Session: PrestaShop cookie-based session
- Cache: Memcached for compiled templates/config
Key Abstractions
Module:
- Purpose: Self-contained feature unit
- Examples:
modules/customfeaturetab/customfeaturetab.php,modules/x13allegro/x13allegro.php - Pattern: Class extending
Module, implementsinstall()/uninstall(), registers hooks
ObjectModel:
- Purpose: ORM for PrestaShop database tables
- Examples:
modules/customfeaturetab/classes/CustomFeatureTabRule.php - Pattern: Class extending
ObjectModelwith static$definitionarray
Override:
- Purpose: Replace core functionality without modifying core files
- Examples:
override/classes/order/Order.phpextendsOrderCore - Pattern:
class X extends XCoreinoverride/directory
Hook:
- Purpose: Extension point for modules
- Execution intercepted:
override/classes/Hook.php(cookiesplus GDPR filter) - Custom hooks:
actionBeforeAddOrder,actionBeforeAddOrderInvoice,actionBeforeAddDeliveryNumber
Entry Points
Frontend:
- URL routing:
override/classes/Dispatcher.php(fsadvancedurl module) - Product pages:
override/controllers/front/ProductController.php - Checkout:
override/controllers/front/OrderController.php(onepagecheckoutps)
Admin Panel:
- URL:
/admin658c34/(randomized for security) - Custom admin tabs registered by modules (e.g., "Karty cech produktu")
Background Scripts:
custom-cron.php— Scheduled tasksexport.php,export-csv.php— Data exportsimport-products.php— Bulk product import
Error Handling
Strategy: Mix — PrestaShop global error handler + per-module ad-hoc
Patterns:
- Custom modules use minimal error handling
die()calls found in empikmarketplace admin controllers- No global exception handling in custom modules
- Cache clear required after PHP class changes
Cross-Cutting Concerns
Caching:
- Memcached for compiled Smarty templates and PS config
- LiteSpeed cache module (
modules/litespeedcache/) - Manual purge required after changes
Translation:
$this->l('Text')in all module PHP files- Primary locale: Polish (
pl-PL) - No separate
.phplanguage files in custom modules
Security:
- Admin URL obfuscation:
admin658c34/ - Cookie consent: cookiesplus module intercepts Hook execution
Architecture analysis: 2026-04-27 Update when major patterns change