Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 30 ยท Practice and Review

PrestaShop Interview Questions

Prepare for a PrestaShop developer interview: clear answers on architecture, hooks vs overrides, ObjectModel, the Symfony migration, security and performance.

PrestaShop interviews tend to mix two kinds of questions. Concept questions ask what something is ("what is the difference between a hook and an override?"). Judgment questions ask what you would do ("a client wants to change how the cart total is displayed; how do you approach it without touching core files?"). Good answers are short, name the trade-off, and show that you have seen the consequences in a real shop.

This lesson collects common questions with compact answers, grouped by topic and linked to the lessons that explain each idea. PrestaShop cannot run on this site, so any real code here is read-only, and the two runnable examples at the end are plain-PHP stand-ins, not PrestaShop code. Class names and details can differ between PrestaShop 8 and 9, so say "in the version I use" when you are not sure. Admitting a version difference is better than guessing. Cover the answers, say yours aloud, then compare.

flowchart TD
    Q["Interview topics"] --> A["Architecture"]
    Q --> B["Hooks and overrides"]
    Q --> C["ObjectModel and data"]
    Q --> D["Symfony migration"]
    Q --> E["Security"]
    Q --> F["Performance"]

Six areas cover most PrestaShop developer interviews.

Architecture

How is PrestaShop built?

It is a PHP application with two generations of code living side by side. The older legacy layer has ObjectModel classes (Product, Cart, Order), controllers in controllers/ and Smarty templates. The newer layer is built on Symfony: back office pages written as Symfony controllers with Twig templates, a service container, Doctrine for some data and a command/query architecture in the core. The front office uses Smarty and themes. See What PrestaShop Is and How It Is Built.

What is a module, and what is a theme?

A module adds behaviour. It is a folder in modules/ whose main class extends Module (or a subclass such as PaymentModule) and whose name matches the folder. A theme controls presentation: templates, CSS, JavaScript and config/theme.yml. Modules can add output to themes through hooks. See Anatomy of a Module.

What does a minimal module need?

A folder named like the module, a main PHP file with a class of that name in PascalCase, a constructor that sets name, tab, version, author and the compatibility range, and an install() that calls parent::install() and registers hooks. A logo and index.php stubs in folders are customary. See Your First Module.

What does the Context give you?

A shared object with the current request's state: customer, cart, language, currency, shop, link, smarty, controller. You use it instead of globals. Read it, but never assume a value exists: an ajax or webhook request may have no cart or customer.

What is multistore and why should a module care?

One installation can host several shops that share a database. A module that stores settings or data must decide whether it is per shop, per shop group or global, for example with the shop arguments of Configuration::get/updateValue. Forgetting this is a classic bug in modules sold to bigger merchants.

Hooks and overrides

What is a hook?

A named place in the code where modules can plug in. Display hooks (displayProductAdditionalInfo) return HTML. Action hooks (actionValidateOrder) signal an event and may let modules change data passed to them. A module registers with registerHook() and implements a method named hook plus the hook name. See Hooks: How Modules Plug In.

In what order do modules run on a hook?

By the position of each module on that hook, which the merchant can change in the back office. Modules that depend on running before or after others are fragile for this reason.

What is an override?

A class in override/ that extends a core class and replaces some of its methods; PrestaShop makes the core class load your version. They exist for cases hooks cannot cover. See Overrides vs Hooks.

Why are overrides risky?

  • Conflicts. Only one module can override a given method. A second one cannot be installed cleanly.
  • Upgrades. The core method may change; your copy silently keeps the old logic.
  • Hidden behaviour. Code that looks standard no longer is, which makes debugging harder.
  • Uninstall pitfalls. If the override file is edited by hand or merged by several modules, removing the module can leave a broken class.

What do you try before writing an override?

In this order: a hook that already exists; a new hook added with a small core-adjacent change in a module that dispatches it; a Symfony service decoration or event on the modern side; and only then an override, as small as possible, calling parent::. Document why it is needed.

How do you create a hook other modules can use?

Register it (it can be created on first use), call Hook::exec('actionAcmeThingHappened', $params) where it applies, and document the parameters. Keep the params stable: they are an API. See Creating and Dispatching Your Own Hooks.

ObjectModel and data

What is an ObjectModel?

A base class for entities stored in the database. A child class declares public static $definition with the table, primary key, fields (type, validation, size, required) and flags such as multilang and multishop. It then gets add(), update(), delete(), validateFields() and loading by id. See ObjectModel and Entities.

How do you read or write custom tables?

Either define an ObjectModel for the table or use the Db class (Db::getInstance()->executeS(), getValue(), insert(), update(), delete()). With Db, prefix tables with _DB_PREFIX_, escape strings with pSQL() and cast numbers with (int).

How do you handle module upgrades?

Raise the module's version, and add upgrade/upgrade-X.Y.Z.php files with a function upgrade_module_X_Y_Z($module) that returns true on success. PrestaShop runs the files newer than the stored version, in version order. See Tables, Installers and Upgrades.

How do you change an order's state safely?

Through the core: OrderHistory with changeIdOrderState() and addWithemail(), not by updating the table directly. The core handles stock, invoices, emails and hooks such as actionOrderStatusPostUpdate. See Working with Products, Carts and Orders and Order Lifecycle.

Symfony migration

Which parts of the back office are Symfony?

Migrated pages (for example Orders, Products in recent versions, Customers, many Advanced Parameters pages) use Symfony controllers, Twig, the Form component and the Grid component. Pages that are not migrated still use the legacy AdminController with Smarty. Which pages are migrated depends on the PrestaShop version. See The Symfony Back Office.

How does a module add a Symfony page?

It ships config/routes.yml and config/services.yml, and a controller class loaded through the module's Composer autoload. The route maps to the controller, and security is declared on the action with the admin security annotation or attribute, depending on the version. See Twig, Forms and Grids.

How do you extend a migrated grid or form?

Through hooks named after the grid or form: for grids, action<GridId>GridDefinitionModifier to change columns, filters and bulk actions, and action<GridId>GridQueryBuilderModifier to change the query. Forms have comparable hooks. This is the modern replacement for many overrides.

What is new in PrestaShop 9 for developers?

It continues the move to newer Symfony and PHP, and introduces an Admin API based on API Platform with OAuth 2 authentication, next to the older Webservice. Exact requirements and endpoints change between releases, so check the release notes of the version you target. See The Admin API in PrestaShop 9.

Security

How do you prevent SQL injection in a module?

Never put raw input in SQL. Cast numbers ((int)), escape strings with pSQL() (or bqSQL() for identifiers in backticks), read input with Tools::getValue() and, where you can, use ObjectModel or query builders. See Security in Modules.

How do you prevent XSS?

Escape on output, in the right context: Smarty |escape:'html':'UTF-8' for HTML text, |escape:'javascript' or JSON encoding in scripts, |intval for ids, and in Twig the default autoescape. Mark output as raw only when your own code produced the markup.

How do you prevent CSRF?

Include a token in state-changing forms and ajax calls and verify it on the server: the static front token (Tools::getToken(false)) in the front office and admin tokens in the back office. Symfony forms add their own CSRF token. A GET request must never change data.

What must a webhook controller do?

Not trust the caller. Verify an HMAC signature over the raw body with hash_equals, check the event type, make processing idempotent and answer quickly. See Payment Modules, Webhooks and Signatures and Idempotency.

How do you handle file uploads?

Check the real type and size, never trust the client file name, store outside paths that execute PHP, generate your own file names and, for images, use the core's image validation helpers. Restrict who can upload in the back office with permissions.

Performance

What are common performance mistakes in modules?

Queries inside loops (N+1), loading full objects when one column is needed, heavy work in hooks that run on every page, large unminified assets, and putting user-specific data into cached output. See Performance and Caching.

How does caching work?

Smarty can cache compiled and rendered templates; PrestaShop has a database query cache option and a configurable cache backend; the Performance page offers combine/compress/cache for CSS and JavaScript; and HTTP caching can be added in front (a CDN or reverse proxy), which requires pages that look identical for all visitors.

How do you find what is slow?

Turn on the debug profiler in a development copy, compare query counts and times, read the slow query log, and measure again after each change. Never guess.

Two stand-ins to explore

The first stand-in contrasts a hook chain with an override chain. Two modules want to change the price label. With hooks, both run in position order; with overrides, the second module cannot even be installed.

PHP Hooks coexist, overrides collide

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

This is the conflict interviewers want to hear about: hooks scale to many modules, overrides do not.

The second stand-in measures the N+1 problem. A hook that runs for ten products either asks the database ten times or once. A counter wrapper makes the difference visible.

PHP Counting queries: N+1 versus one query

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Eleven queries become two, and the answer is identical. A product list with 48 items makes the gap far bigger, which is why listing hooks are the first place to look.

How to answer well

  • Start with the definition in one sentence, then give the trade-off.
  • Give an example from a real module you wrote: "I needed to show a delivery date, so I used displayProductAdditionalInfo".
  • Say which PrestaShop version you tested on.
  • For "how would you" questions, name the first thing you would check (existing hooks, permissions, multistore, cache) before writing code.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why are overrides considered riskier than hooks?

    Method ownership is exclusive, and an overridden copy of core logic can drift after an upgrade. Hooks let many modules cooperate.
  2. 2. What is the correct way to extend a migrated grid such as the orders list?

    Grid hooks exist for exactly this and keep the core untouched.
  3. 3. Which input handling is correct when building SQL with the Db class?

    Tools::getValue only reads the request; you must still cast or escape for SQL.
  4. 4. A hook runs for every product in a list and executes one query per product. What is this called and how do you fix it?

    One query per item grows with the list. A single IN query or a join returns the same data in one round trip.

Summary

  • PrestaShop combines legacy ObjectModel/Smarty code with a growing Symfony/Twig layer; know where each is used.
  • Prefer hooks and grid or form hooks over overrides; know exactly why overrides conflict.
  • Treat all input as untrusted: cast, escape, verify tokens and signatures, escape output.
  • Use ObjectModel or Db carefully, upgrade with versioned files and change order states through core classes.
  • Look for N+1 queries and cacheability first when a page is slow.

Finish with the quick-lookup page PrestaShop Module Cheat Sheet.