Architecture¶
Overview¶
The module is a standard PrestaShop 9+ module built on Symfony 6.4. PrestaShop provides the Symfony container, Doctrine DBAL, and all framework classes — the module does not bundle its own Symfony installation.
PrestaShop Core
└── Symfony Container / Doctrine DBAL / Hooks
└── fabfacebookpixel module
├── Admin SPA (Vue 3) ← backoffice configuration UI
├── Admin API Controllers ← REST endpoints consumed by the SPA
├── Front Controllers ← consumer (event poll), catalog export download
├── Hooks (fabfacebookpixel.php)← event capture, JS injection
├── Services
│ ├── CAEventBuilder ← builds + sends CA events, persists FbpEvent rows
│ ├── CatalogExportService ← chunked CSV generation pipeline
│ └── Logger ← writes to var/logs/
├── Repositories ← thin Doctrine/raw-DB data access layer
└── Entities ← Doctrine entities (FbpPixel, FbpPixelSetting, etc.)
Symfony DI¶
Services are declared in config/services.yml, config/admin/services.yml, and config/front/services.yml. The module uses constructor injection throughout. The main module class (FabFacebookPixel) is not a Symfony service itself — it uses $this->get(ServiceClass::class) to pull services from the container when needed inside hooks.
Database schema¶
All module tables are prefixed with fbp_. Created on install via install/install.sql, dropped on uninstall via uninstall/uninstall.sql.
| Table | Purpose |
|---|---|
fbp_pixel_setting |
Per-shop global settings (description field, image format, iubenda flag, debug flag, etc.) |
fbp_pixel |
Pixel configurations (Pixel ID, CA token, test code) |
fbp_pixel_country |
Country scope per pixel (many-to-many) |
fbp_pixel_currency |
Currency scope per pixel (many-to-many) |
fbp_catalog_exporter |
Catalog export configurations |
fbp_catalog_exporter_category |
Category filter per exporter |
fbp_catalog_exporter_manufacturer |
Manufacturer filter per exporter |
fbp_catalog_exporter_supplier |
Supplier filter per exporter |
fbp_category_mapping |
PS category → Google/Facebook taxonomy mapping |
fbp_attribute_mapping |
PS attribute/feature → Facebook column mapping |
fbp_google_category |
Google taxonomy cache |
fbp_facebook_category |
Facebook taxonomy cache |
fbp_guest_context |
Browser context per PS guest (UA, IP, _fbp, _fbc) |
fbp_event |
Event queue: one row per fired event, tracks CA sent / JS sent status |
fbp_cache_setting |
Module cache configuration (timeout, enabled flag) |
Multi-store / multi-language / multi-currency¶
- Pixel selection is resolved per-request from the visitor's country and currency.
- Pixel settings (
fbp_pixel_setting) are scoped byid_shop. - Catalog export configurations each have their own
id_shop,id_lang,id_currency,id_country. - Category and attribute mappings are scoped by
id_shop.
Caching¶
Two separate cache instances:
| Cache | Scope | Backend |
|---|---|---|
| Frontend cache | Hook handlers (no container) | Symfony\Component\Cache\Adapter\FilesystemAdapter writing to _PS_CACHE_DIR_/modules/fabfacebookpixel |
| Backoffice cache | Symfony services | DI-injected via fabfacebookpixel.cache.di (Symfony Cache component) |
Cache keys for the frontend cache: FabFacebookPixel_PixelRow_{shopId}_{countryId}_{currencyId}, FabFacebookPixel_PixelSettingRow_{shopId}.