jeffsenso/prestashop-skills / skills/prestashop-module-development
prestashop-module-development
VerifiedComplete PrestaShop module development workflow using modern architecture and best practices. Use when: creating new PrestaShop modules, updating legacy modules to modern code, implementing hooks and actions, setting up module configuration pages, adding front office features, handling database operations, implementing security measures, managing translations, creating cart rules and vouchers, building Symfony console commands, or modernizing existing PrestaShop modules from legacy patterns to current standards.
ps9-core-ai/MULTISTORE.md
View on GitHub# Multi-store — Cross-cutting Guide
Multi-store affects forms, configuration reads/writes, repositories, and queries throughout almost every domain. Incorrect scoping is a common source of bugs.
## Core concept: ShopConstraint
`ShopConstraint` (in `src/Core/Domain/Shop/ValueObject/ShopConstraint.php`) defines the scope of an operation:
| Factory method | Scope |
|---------------|-------|
| `ShopConstraint::allShops()` | All shops — write applies everywhere |
| `ShopConstraint::shopGroup($id)` | All shops in one group |
| `ShopConstraint::shop($id)` | Single shop only |
Always pass `ShopConstraint` explicitly when a command or query is scope-sensitive. Never infer scope from the current context inside a handler.
## Configuration reads and writes
Use `src/Adapter/Configuration.php` (wraps `Configuration` ObjectModel):
```php
// Read — always pass ShopConstraint
$value = $this->configuration->get('MY_KEY', null, $shopConstraint);
// Write — always pass ShopConstraint
$this->configuration->set('MY_KEY', $value, $shopConstraint);
```
**Never** call `Configuration::get()` / `Configuration::updateValue()` static methods in new code — they ignore shop scope.
## Settings pages: AbstractMultistoreConfiguration
For back-office settings forms that must support per-shop overrides, extend `src/Core/Configuration/AbstractMultistoreConfiguration.php`. It:
- Automatically handles the "use shop default" checkbox rendered per field
- Reads and writes using `ShopConstraint` derived from the current admin context
- Requires implementing `getConfiguration()` and `updateConfiguration(array $data)`
See `src/Adapter/Configuration/` for concrete examples.
## Repositories
`AbstractMultiShopObjectModelRepository` extends `AbstractObjectModelRepository` with `ShopConstraintTrait`. Methods like `getObjectModel()` and `updateObjectModel()` accept an optional `ShopConstraint`. Use it when the entity can have per-shop overrides.
## Commands and Queries
- Commands that modify per-shop data must accept a `ShopConstraint` parameter
- Inject `ShopContext` (from `src/Core/Context/ShopContext.php`) to get the current shop's constraint: `$shopContext->getShopConstraint()`
- Handlers must never read `Context::getContext()->shop` directly — use the injected `ShopContext`
## Non-obvious patterns
- `ShopConstraint::allShops()` write does **not** override existing per-shop values — it only sets the "all shops" default. Per-shop overrides take precedence at read time.
- Deleting a per-shop override (reverting to the all-shops value) requires calling `configuration->delete($key, $shopConstraint)`, not setting it to null.
- Grid filters are not multi-store aware by default — scope filtering must be added manually to the Doctrine query builder if needed.
## Related
- [Configuration Component](Component/Configuration/CONTEXT.md) — `AbstractMultistoreConfiguration`, `Configuration` adapter
- [Context Component](Component/Context/CONTEXT.md) — `ShopContext::getShopConstraint()`
- [Database Component](Component/Database/CONTEXT.md) — `AbstractMultiShopObjectModelRepository`
- [Shop Domain](Domain/Shop/CONTEXT.md) — `ShopConstraint` value object lives here
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |