Skip to main content

Prestashop Override Class -

Create override file: /override/classes/Product.php

The override class must extend the *Core version of the original class (e.g., ProductCore ). 4. How the Override System Works (Flow) graph TD A[Request calls e.g. 'new Cart()'] --> B[Autoloader looks for class Cart] B --> CExists in /override/classes/ ? C -->|Yes| D[Load /override/classes/Cart.php] C -->|No| E[Load /classes/Cart.php] D --> F[Class Cart extends CartCore] F --> G[Execute override methods] E --> H[Execute original CartCore methods] PrestaShop uses a custom Autoload class that scans /override/ at runtime (or caches the mapping). When a class is instantiated, the autoloader loads the override version if present. 5. Creating an Override (Example) Goal: Modify the getProductPrice method in Product class to apply a special discount for VIP customers. prestashop override class

Write the override:

Locate original class – /classes/Product.php → method public static function getProductPrice(...) inside ProductCore . Create override file: /override/classes/Product