Definition of Override

In object-oriented programming and specifically within PrestaShop development, the term Override refers to a technique that allows a developer to modify or extend the behavior of the CMS's original code (the Core) without physically altering the native system files.

How Overrides Work Technically

Imagine PrestaShop has a default PHP class called Product.php, which handles calculating and displaying product information. If your e-commerce store requires a highly customized, non-standard price calculation logic, directly editing the original Product.php file would be a critical mistake. Upon the next PrestaShop upgrade, that file would be replaced by the new official version, irreparably deleting your custom work.

The Override solves this problem. The system utilizes a special folder (simply named /override/) where the programmer can create a new file extending the original class (e.g., class Product extends ProductCore). When PrestaShop loads a page, it first checks if a directive exists in the override folder; if found, it executes your custom code instead of the standard one.

Historically in PrestaShop, it has been possible to override almost anything: from Classes (which manage data), to Controllers (which manage display logic), to Theme files (to alter design without touching original template files).

The Risks of Overriding and the Evolution to Symfony

Although it was the most widespread practice in PrestaShop versions 1.5 and 1.6, the abuse of overrides is now considered the primary cause of e-commerce fragility and technical debt.

The main problems associated with overrides include:

  • Module Conflicts: If two modules purchased from different developers attempt to override the same controller (for example, the Cart controller), the system will crash, returning a fatal error or a blank page.
  • Upgrade Blockers: If the structure of PrestaShop's native code changes in a newer version, the old custom code sitting in the override folder will still execute, breaking site functionality and preventing a smooth transition to newer CMS versions.

Modern Alternatives: Hooks and Decorators

With the transition to modern versions of PrestaShop (8 and beyond) based on the Symfony framework, official development guidelines strongly advise against using overrides to implement new business logic. The modern approach mandates the use of non-invasive architectural techniques.

Today, developers rely on the powerful Hook system to inject visual content or manipulate data on the fly. For deep logic modifications tied to services, developers use Decorators or Subscribers linked to the Command Bus. These allow altering a Symfony service's behavior without overwriting it, ensuring total security, modularity, and painless platform upgrades.