Skip to content
Back to skills

Prestashop Upgrade Toolbox Module Rewrite

ASecurity

Rewrite, as a module of your own for PrestaShop 9, the legacy behaviour a migration decided to rewrite — a core override, a 1.6-only module, a script the old shop served outside the dispatcher, a custom integration (ERP or logistics bridge, export, blog) — from a specification taken from the old shop's real behaviour, on the staging with the migrated data, with the module's own data carried by a replayable script and a proof by effect. Use when the modules decision (prestashop-upgrade-toolbox...

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
developmentpythongophpbashrailsgitdatabasesecurity

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add PrestaShopCorp/PrestaShop-Upgrade-Toolbox --skill prestashop-upgrade-toolbox-module-rewrite --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Prestashop Upgrade Toolbox Module Rewrite?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Prestashop Upgrade Toolbox Module Rewrite
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/prestashopcorp-prestashop-upgrade-toolbox-module-rewrite/badge)](https://www.skillsdirectory.com/skills/prestashopcorp-prestashop-upgrade-toolbox-module-rewrite)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: prestashop-upgrade-toolbox-module-rewrite
description: >
  Rewrite, as a module of your own for PrestaShop 9, the legacy behaviour a migration decided to
  rewrite — a core override, a 1.6-only module, a script the old shop served outside the
  dispatcher, a custom integration (ERP or logistics bridge, export, blog) — from a specification
  taken from the old shop's real behaviour, on the staging with the migrated data, with the
  module's own data carried by a replayable script and a proof by effect. Use when the modules
  decision (prestashop-upgrade-toolbox-modules) says "rewrite"; when an override must become a module +
  hook; when a 1.6 module has no PrestaShop 9 version and must be ported; when a directly-called script
  must become a front controller. NOT for payment or shipping modules: those are never rewritten,
  always taken from the PrestaShop Marketplace or the provider. NOT for deciding a module's fate
  (see prestashop-upgrade-toolbox-modules), NOT for a brand-new feature unrelated to the migration.
---

# Rewriting legacy behaviour as a module (phase 5)

Shared context: **`prestashop-upgrade-toolbox-core`**. The decision that sends a module here is taken
and written in **`prestashop-upgrade-toolbox-modules`** (`migration/02-modules.md`, one row per module);
this skill does the rewrite, and writes its progress in the same file.

**The founding rule: never touch the core.** Not a file of `classes/`, `controllers/` or `src/`, not
the `override/` folder. Every behaviour the old shop got from an override becomes a module + hook.
**The old shop's behaviour is the specification, never its code**: legacy code is read to
understand what it did, not copied.

## Out of scope: payment and shipping

**A payment or shipping module is never rewritten.** It is kept or updated to the vendor's
version for the target, or replaced by a module from the PrestaShop Marketplace or the
provider's official module. That decision belongs to `prestashop-upgrade-toolbox-modules`. When no such
module exists for the target, the merchant chooses another provider or an integrator: this skill
does not write one. The same holds for anything the Marketplace already sells (connectors,
tracking): buying is the default, a rewrite needs a written reason.

## 1. The specification, before any code

Write it in `02-modules.md`, under the module's row, before the first line of code:

- **What the old shop did**, from the audit's card (workstream C) and the override's diff method by
  method (`prestashop-upgrade-toolbox-audit/scripts/override-map.py`): each business rule, condition,
  hard-coded id or URL, third party.
- **What it touched**: its tables and their most recent rows, configuration keys, the callers found
  in the access logs and crontabs (`access_surfaces.py`) for a script served directly.
- **What stays, what goes**: every rule kept, changed or dropped, with who decided.
- **The acceptance criteria, as effects**: what a journey must produce for the rewrite to count —
  the order at this status, the file with these columns, the e-mail received, the payload the ERP
  would receive. These are the proof of §6.
- **What it does when its input is missing.** An importer that sets things by absence — stock at 0
  for a product missing from the feed, a customer deleted because absent from a file — wipes the
  catalogue or the customers the day the feed is absent, empty or truncated. The old script often
  did exactly that. The rewrite refuses, and says why: input absent or empty, header not the
  expected one, fewer rows than a share of the last good run, more records to zero or delete than
  a cap — overridden only by an explicit force flag. These refusals are acceptance criteria too.
- **A large rewrite goes in slices**: one behaviour group at a time, each with its specification,
  its acceptance and its proof, and every earlier slice replayed after each new one.

## 2. Where to work

- On the **staging** — the target version, the migrated data, the target's PHP — never on the
  production, never on the old shop.
- The module's code **in version control** with the project, not edited in place on a server.
- Debug mode on the staging only. Anything that writes to a third party stays **off**: a setting,
  off by default, and a dry-run that logs the payload it would send.

## 3. The skeleton

```bash
python3 scripts/scaffold_module.py <name> "<Display name>" --dest <project>/modules \
  [--author "<who maintains it>"] [--admin-controller]
```

A blank, valid PrestaShop 9 module: main class, `_PS_VERSION_` guards, `index.php` in every
folder, the PSR-4 autoloader its `src/` needs, `config/services.yml`, and with `--admin-controller`
a Symfony back-office controller stub (`PrestaShopAdminController`, `#[AdminSecurity]`). It
refuses a folder that already exists. Then write the real
logic into it, following [references/module-standards.md](references/module-standards.md).

## 4. Porting the legacy behaviour

[references/porting-legacy.md](references/porting-legacy.md) holds the method and the version
facts: an override method → the hook or service that replaces it; a 1.6 hook → its name on the
target, or its alias, or no successor (a design choice, written in the decision); `$this->l()` →
the translation system; a script served directly → a module front controller with the access
control the script lacked; the PHP the target runs.

## 5. The module's own data

- **Tables**: created in `install()` with `_DB_PREFIX_` — never a hard-coded prefix, the target's is
  random — and dropped in `uninstall()` only when the merchant agreed the data can go.
- **Carrying the old module's data** (reviews, points, wish lists, an ERP's mapping): a script of
  its own, idempotent, reading the old tables the transplant brought and writing through the new
  module's classes, with its post-condition (counts equal to the source's). It is **replayed on the
  day**, on the freshly reloaded database: list it in the decisions table, "day-J script" column.
- **A change to the module's tables during acceptance**: an upgrade script
  (`upgrade/upgrade-<version>.php`) and a bumped version, so the day's database gets the same
  structure.

## 6. The proof

- Installed on the staging with `php bin/console prestashop:module install <name>` (as the web
  server's user, `--env=prod`), then the front answers 200 and the back office does not 500.
- **Uninstall and reinstall once, on a copy**, and nothing of it remains in between (hooks, tab,
  configuration keys, tables): `install()` and `uninstall()` are symmetric.
- **Each acceptance criterion of §1 played to its effect**, log cited in `02-modules.md` — the
  journey the gate of `02-modules` asks for. Each assertion prints how many cases it checked, and
  zero fails: a query that broke, a session that was not open, a filter that matched nothing make
  a test that passes on nothing (`prestashop-upgrade-toolbox-core/references/control-self-audit.md`).
- **A differential test where the old code can still run**: the old script, read-only, on the
  reference copy, and the new command on the staging, from the same input — the outputs compared
  line by line. Identical is the proof; a difference is a defect, or a change written in the
  specification.
- **Acceptance scripts touch real migrated data, and the staging is carried over to the new
  production**: what a test leaves behind can ship. Before it acts, a script checks the guardrails
  (mail off, third parties off or dry-run) and snapshots every row it will touch — and checks the
  snapshot is not empty. It restores them even when it stops on an error, and proves the
  restoration by a query against the reference copy (zero difference), never by re-reading an
  object the core may have cached ([references/module-standards.md](references/module-standards.md),
  "Gotchas").
- **No core file changed**: the project's `git diff` outside `modules/` and the theme is empty.

## 7. On the day

The rewritten module ships with the site's files: its code is already on the server. Its state —
rows, hooks, settings — comes with the staging carry-over; **it is not reinstalled**. Only its
day-J data script, if it has one, runs on the reloaded database (runbook).

## Done

- every module decided "rewrite" has its specification and acceptance criteria in `02-modules.md`;
- no payment or shipping module rewritten;
- each rewrite built from the skeleton, installed on the staging, front 200 and back office healthy,
  uninstall/reinstall leaving nothing behind;
- each acceptance criterion proven by its effect, log cited;
- the module's data script listed as a day-J script and replayed once on a freshly reloaded
  database, its counts equal to the source's;
- no core file changed.

Files in this skill

  • SKILL.md8.6 KB
  • references/module-standards.md7.9 KB
  • references/porting-legacy.md5.2 KB
  • scripts/scaffold_module.py7.9 KB
  • tests/test_scaffold_module.py5.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.