Skip to content

jeffsenso/prestashop-skills / skills/prestashop-module-development

prestashop-module-development

Verified

Complete 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.

FileKindSize
CHANGELOG.mdmarkdown12.9 KB
README.mdmarkdown3.5 KB
SKILL.mdskill md21.7 KB
ps9-core-ai/CONTEXT.mdmarkdown6.4 KB
ps9-core-ai/Component/BackOfficeHelp/CONTEXT.mdmarkdown1.0 KB
ps9-core-ai/Component/Behat/CONTEXT.mdmarkdown7.7 KB
ps9-core-ai/Component/CQRS/CONTEXT.mdmarkdown6.8 KB
ps9-core-ai/Component/Configuration/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Component/Console/CONTEXT.mdmarkdown1.1 KB
ps9-core-ai/Component/Context/CONTEXT.mdmarkdown1.8 KB
ps9-core-ai/Component/ContextStateManager/CONTEXT.mdmarkdown2.0 KB
ps9-core-ai/Component/Controller/CONTEXT.mdmarkdown4.7 KB
ps9-core-ai/Component/Cookie/CONTEXT.mdmarkdown1.3 KB
ps9-core-ai/Component/Database/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Component/Export/CONTEXT.mdmarkdown964 B
ps9-core-ai/Component/FacetedSearch/CONTEXT.mdmarkdown1.3 KB
ps9-core-ai/Component/Forms/CONTEXT.mdmarkdown6.1 KB
ps9-core-ai/Component/Grid/CONTEXT.mdmarkdown5.2 KB
ps9-core-ai/Component/Hook/CONTEXT.mdmarkdown1.1 KB
ps9-core-ai/Component/Import/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Component/Javascript/CONTEXT.mdmarkdown3.9 KB
ps9-core-ai/Component/Link/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Component/Locale/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Component/MailTemplate/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Component/Migration/CONTEXT.mdmarkdown10.6 KB
ps9-core-ai/Component/Playwright/CONTEXT.mdmarkdown6.4 KB
ps9-core-ai/Component/PositionUpdater/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Component/Router/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Component/Smarty/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Component/TinyMCE/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Component/Twig/CONTEXT.mdmarkdown3.9 KB
ps9-core-ai/Domain/Address/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/Alias/CONTEXT.mdmarkdown1.3 KB
ps9-core-ai/Domain/ApiClient/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Attachment/CONTEXT.mdmarkdown1.2 KB
ps9-core-ai/Domain/AttributeGroup/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Carrier/CONTEXT.mdmarkdown1.8 KB
ps9-core-ai/Domain/Cart/CONTEXT.mdmarkdown2.1 KB
ps9-core-ai/Domain/CartRule/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/CatalogPriceRule/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Category/CONTEXT.mdmarkdown1.8 KB
ps9-core-ai/Domain/CmsPage/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/CmsPageCategory/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Combination/CONTEXT.mdmarkdown2.4 KB
ps9-core-ai/Domain/Configuration/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Contact/CONTEXT.mdmarkdown1.2 KB
ps9-core-ai/Domain/Country/CONTEXT.mdmarkdown1.8 KB
ps9-core-ai/Domain/CreditSlip/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Domain/Currency/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Customer/CONTEXT.mdmarkdown2.0 KB
ps9-core-ai/Domain/CustomerMessage/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/CustomerService/CONTEXT.mdmarkdown2.3 KB
ps9-core-ai/Domain/Discount/CONTEXT.mdmarkdown2.4 KB
ps9-core-ai/Domain/Employee/CONTEXT.mdmarkdown2.3 KB
ps9-core-ai/Domain/Feature/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/Hook/CONTEXT.mdmarkdown1.1 KB
ps9-core-ai/Domain/ImageSettings/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Language/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/MailTemplate/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Manufacturer/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Meta/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Module/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/Notification/CONTEXT.mdmarkdown1.3 KB
ps9-core-ai/Domain/Order/CONTEXT.mdmarkdown2.6 KB
ps9-core-ai/Domain/OrderMessage/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/OrderReturn/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/OrderReturnState/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/OrderState/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Position/CONTEXT.mdmarkdown996 B
ps9-core-ai/Domain/Product/CONTEXT.mdmarkdown2.7 KB
ps9-core-ai/Domain/Profile/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Search/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/SearchEngine/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Security/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Shipment/CONTEXT.mdmarkdown1.8 KB
ps9-core-ai/Domain/Shop/CONTEXT.mdmarkdown2.0 KB
ps9-core-ai/Domain/ShowcaseCard/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Domain/SqlManagement/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/State/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Store/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Supplier/CONTEXT.mdmarkdown2.1 KB
ps9-core-ai/Domain/Tab/CONTEXT.mdmarkdown1.5 KB
ps9-core-ai/Domain/Tag/CONTEXT.mdmarkdown1.4 KB
ps9-core-ai/Domain/Tax/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/TaxRulesGroup/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Theme/CONTEXT.mdmarkdown1.7 KB
ps9-core-ai/Domain/Title/CONTEXT.mdmarkdown1.6 KB
ps9-core-ai/Domain/Webservice/CONTEXT.mdmarkdown1.9 KB
ps9-core-ai/Domain/Zone/CONTEXT.mdmarkdown1.3 KB
ps9-core-ai/GOTCHAS.mdmarkdown3.9 KB
ps9-core-ai/MULTISTORE.mdmarkdown3.1 KB
ps9-core-ai/STRUCTURE.mdmarkdown11.1 KB
ps9-core-ai/bin/generate-ai-index.shscript17.9 KB
ps9-core-ai/generated/cqrs.mdmarkdown16.1 KB
ps9-core-ai/generated/entities.mdmarkdown2.7 KB
ps9-core-ai/generated/hooks.mdmarkdown3.7 KB
ps9-core-ai/generated/routes.mdmarkdown88.8 KB
references/cart-rules.mdmarkdown8.9 KB
references/configuration-management.mdmarkdown11.9 KB
references/configuration-page.mdmarkdown11.0 KB
references/database-and-entities.mdmarkdown5.7 KB
references/debugging.mdmarkdown5.9 KB
references/entity-doctrine.mdmarkdown12.5 KB
references/forms.mdmarkdown8.5 KB
references/grid-system.mdmarkdown41.0 KB
references/hooks-and-front-office.mdmarkdown8.2 KB
references/legacy-conversion.mdmarkdown3.5 KB
references/module-class-and-installer.mdmarkdown13.7 KB
references/module-structure.mdmarkdown3.4 KB
references/security.mdmarkdown2.4 KB
references/services-and-di.mdmarkdown20.8 KB
references/services-split.mdmarkdown6.0 KB
references/theme-template-injection.mdmarkdown7.4 KB
references/translations.mdmarkdown8.6 KB
references/validation.mdmarkdown2.5 KB
scripts/grid.bundle.jsscript4.4 KB
scripts/translatable-form.bundle.jsscript9.8 KB

ps9-core-ai/Component/Behat/CONTEXT.md

View on GitHub
# Behat Component

## Purpose

Integration testing infrastructure using Behat (BDD). Tests exercise the CQRS layer (commands, queries, handlers) through Gherkin scenarios, validating business logic without a browser. Does not test UI — that's Playwright's role.

## Layers

| Layer | Path |
|-------|------|
| Feature files (Gherkin) | `tests/Integration/Behaviour/Features/Scenario/{Domain}/` |
| Feature contexts (PHP) | `tests/Integration/Behaviour/Features/Context/Domain/{Domain}/` |
| Behat config | `tests/Integration/Behaviour/behat.yml` |
| Shared helpers | `tests/Integration/Behaviour/Features/Context/` (base classes, shared contexts) |

## Key concepts

### Feature context classes — two layers

There are two distinct context layers:

- **`Context/Domain/{Domain}/`** — CQRS-based contexts. Built during migration. Use command bus and query bus to exercise the modern domain layer. These are what the migration skills create.
- **`Context/`** (root, non-Domain) — legacy-based contexts. Use ObjectModel and legacy classes directly. These exist for domains that have NOT been migrated yet but need fixture manipulation (e.g. creating a carrier in a test for another domain).

**During migration, always create contexts in `Context/Domain/`.** Never favor a legacy context if a CQRS-based step exists for the same action. Legacy contexts are only acceptable when the domain has no CQRS layer yet and you need fixtures.

All domain contexts:
- Extend `AbstractDomainFeatureContext` (which provides command bus, query bus, shared storage)
- Implement step definitions as PHP methods with `@Given`, `@When`, `@Then` annotations and regex patterns
- One context class per domain is the typical case (e.g. `TaxFeatureContext`, `ManufacturerFeatureContext`). Complex domains with many commands (e.g. Product, Order) can be split into sub-contexts under `Context/Domain/{Domain}/` — register each in `behat.yml`
- Contexts are NOT Symfony services — they are registered in `behat.yml`, not via DI

### Context registration

Contexts are declared in `tests/Integration/Behaviour/behat.yml` under the appropriate suite:

```yaml
domain:
    contexts:
        - PrestaShop\Tests\Integration\Behaviour\Features\Context\Domain\{Domain}\{Domain}FeatureContext
```

Run `php vendor/bin/behat --dry-run` after registration to verify all steps are matched.

### Entity references (referenceToId / referencesToIds)

- Use `$this->referenceToId($reference)` to resolve a string reference (e.g. `"tax_1"`) to an integer ID
- Use `$this->referencesToIds($references)` for lists
- After creating an entity, store it: `$this->shareStorage->set($reference, $newId)`
- Never hardcode integer IDs in step definitions — always use string references

### Stateless steps (critical rule)

**Steps must be stateless.** A step should never perform an action, save intermediate state, and then rely on a separate step to assert the result.

Bad (stateful — assertion depends on state saved by a previous step):
```gherkin
When I add a tax with name "VAT"
Then the last created tax should have name "VAT"
```

Good (stateless — action and assertion are self-contained):
```gherkin
When I add a tax "vat_ref" with name "VAT"
Then tax "vat_ref" name should be "VAT"
```

Bad (stateful — the Then step asserts data stored in memory by the When step):
```gherkin
When I query the product "product1"
Then I get the following properties:
  | name | product name |
```

Good (stateless — single step queries and asserts in one go):
```gherkin
When I query the product "product1" I should get the following properties:
  | name | product name |
```

The key principle: each step must independently load its data from the database. Never store query results in memory for a later step to assert — this hides which data is actually being checked and leads to false positives when a previous step's state leaks into the assertion.

### Command bus / Query bus access

- `$this->getCommandBus()->handle(...)` for write operations
- `$this->getQueryBus()->handle(...)` for read/verification operations
- Never instantiate handlers directly — always go through the bus

### Multilingual data in steps

- Use `$this->localizeByRows($table)` to convert a Gherkin `TableNode` into an array keyed by language ID — this is the standard helper for multilingual step definitions

### Error scenarios

- Error steps catch **typed domain exceptions**, not generic `\Exception`
- Pattern: `When I add a tax with invalid data` / `Then I should get an error "{ExceptionType}"`
- The context stores the caught exception and a subsequent Then step asserts its type

### Bulk action steps

- Pass multiple references as a comma-separated string: `When I bulk delete taxes "ref_1,ref_2,ref_3"`
- Use `$this->referencesToIds($references)` to resolve the list

### Deterministic steps

- Step definitions must be **deterministic** — no random data, no timing dependencies. Use fixed values or references

### Available tags (from CommonFeatureContext)

These tags trigger hooks defined in `CommonFeatureContext`. Add them to your `Feature:` or `Scenario:` line to activate.

**Database restoration:**

| Tag | Level | What it does |
|---|---|---|
| `@restore-all-tables-before-feature` | Feature | Restores all DB tables + cleans SharedStorage before the feature |
| `@restore-all-tables-after-feature` | Feature | Restores all DB tables + cleans SharedStorage after the feature |
| `@reset-all-tables-before-scenario` | Scenario | Restores all DB tables + cleans SharedStorage before each scenario |
| `@reset-all-tables-after-scenario` | Scenario | Restores all DB tables + cleans SharedStorage after each scenario |

**Kernel and cache:**

| Tag | Level | What it does |
|---|---|---|
| `@reboot-kernel-before-feature` | Feature | Reboots Symfony kernel (forces service recreation) |
| `@reboot-kernel-after-feature` | Feature | Reboots Symfony kernel after feature |
| `@reboot-kernel-before-scenario` | Scenario | Reboots Symfony kernel before each scenario |
| `@clear-cache-before-feature` | Feature | Clears all static caches |
| `@clear-cache-after-feature` | Feature | Clears all static caches |
| `@clear-cache-before-scenario` | Scenario | Clears all static caches |
| `@clear-cache-after-scenario` | Scenario | Clears all static caches |

**Resource cleanup:**

| Tag | Level | What it does |
|---|---|---|
| `@reset-downloads-after-feature` | Feature | Resets downloads directory |
| `@reset-img-after-feature` | Feature | Resets images directory |
| `@reset-test-modules-after-feature` | Feature | Resets test modules |

**Context mocking:**

| Tag | Level | What it does |
|---|---|---|
| `@mock-context-on-feature` | Feature | Mocks legacy Context before feature, resets after |
| `@mock-context-on-scenario` | Scenario | Mocks legacy Context before scenario, resets after |

**Automatic hooks (always active, no tag needed):**

- `@BeforeStep`: clears Doctrine EntityManager for fresh data at each step
- `@AfterStep`: checks for unhandled exceptions from previous steps
- `@BeforeScenario`: clears stored exceptions

The most commonly used tag is `@restore-all-tables-before-feature` — use it on any feature that modifies database state.

## Canonical examples

- `tests/Integration/Behaviour/Features/Context/Domain/Tax/TaxFeatureContext.php` — simple domain context
- `tests/Integration/Behaviour/Features/Scenario/Tax/` — simple CRUD scenarios
- `tests/Integration/Behaviour/Features/Context/Domain/Manufacturer/ManufacturerFeatureContext.php` — with sub-resources

## Skills

| Skill | Trigger |
|-------|---------|
| [`create-behat-context`](skills/create-behat-context/SKILL.md) | "create behat context for {Domain}" |
| [`write-behat-scenarios`](skills/write-behat-scenarios/SKILL.md) | "write behat scenarios for {Domain}" |

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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall