PrestaShop Module Development Tutorial
Learn PrestaShop Module Development step by step: 30 lessons in 10 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What PrestaShop Is and How It Is Built Learn what PrestaShop is, how modules and themes differ, how the legacy ObjectModel and Symfony layers fit together, and what PrestaShop 8 and 9 change.
- Setting Up a Development Environment Set up a local PrestaShop with Docker or a classic stack, turn on dev mode and debugging, clear caches and use the console. Includes a requirements checker.
Module Basics
- Anatomy of a Module Learn the folder layout of a PrestaShop module, the main class, config.xml, logo, naming rules, install and uninstall, and composer autoloading with a mini loader.
- Your First Module Build a minimal PrestaShop module step by step: constructor properties, version compatibility, display name, a hook, installing it in the back office, plus a registry stand-in.
- A Module Configuration Page Build a settings page for a PrestaShop module with getContent(), HelperForm, Configuration::get and updateValue, validation and flash messages, with a runnable stand-in.
Hooks
- Hooks: How Modules Plug In Understand PrestaShop hooks: display and action hooks, registerHook, hookDisplay and hookAction methods, execution order and positions, discovery, with a dispatcher you can run.
- Common Front Office Hooks Learn the PrestaShop hooks you use most on the storefront: displayHeader, actionFrontControllerSetMedia, displayProductAdditionalInfo and displayShoppingCart.
- Creating and Dispatching Your Own Hooks Add your own extension points to a PrestaShop module with Hook::exec: naming, registering hooks in the database, aliases, collecting results and versioning parameters.
- Overrides vs Hooks Understand PrestaShop class and controller overrides, why they conflict between modules, and which safer alternatives (hooks, service decoration) to use instead.
Front Office
- Module Front Controllers Build your own storefront pages and AJAX endpoints with ModuleFrontController: file layout, friendly URLs, initContent, JSON responses, redirects and tokens.
- Smarty Templates and Theme Integration Learn Smarty basics for PrestaShop modules: assign and fetch, escaping, template resolution, theme overrides of module templates, hooks in themes and child themes.
ObjectModel and Data
- ObjectModel and Entities Define your own database entities with PrestaShop's ObjectModel: the $definition array, field types, validation, multilingual fields, CRUD methods, Db and pSQL.
- Tables, Installers and Upgrades Create tables when a PrestaShop module installs, ship upgrade-x.y.z.php files, handle the table prefix and clean up on uninstall, with a runnable migration stand-in.
- Working with Products, Carts and Orders Read and change products, carts, orders, customers and addresses from a PrestaShop module: price and tax helpers, order states and safe practices, with stand-ins.
Back Office with Symfony
- The Symfony Back Office Add modern back office pages to a PrestaShop module: Symfony controllers, routes.yml, services, admin security and the difference from legacy admin controllers.
- Twig, Forms and Grids Build back office screens in a PrestaShop module: Twig templates, Symfony forms with data providers and handlers, and the Grid component with filters and bulk actions.
APIs and Integrations
- The Webservice API Use the PrestaShop Webservice: enable it, create keys with permissions, query resources in XML or JSON with filters and display, and add a custom resource from a module.
- The Admin API in PrestaShop 9 Understand the PrestaShop 9 Admin API: OAuth2 client credentials, scopes, API Platform resources and custom endpoints, with a runnable token and scope stand-in.
- Payment Modules Build a PrestaShop payment module the right way: PaymentModule, hookPaymentOptions, PaymentOption, validateOrder, return pages and idempotent webhooks, with a runnable stand-in.
Quality and Security
- Translations and Multilingual Modules Make a PrestaShop module speak every language: trans() domains, Smarty and Twig translation, XLIFF catalogs, multilingual fields and currency formatting, with a runnable translator.
- Security in Modules Secure your PrestaShop modules: pSQL and casting for SQL, sanitizing input, CSRF tokens, output escaping in Smarty and Twig, safe uploads and access checks, with vulnerable-versus-safe demos.
- Performance and Caching Keep PrestaShop modules fast: Smarty template caching with cache ids, in-request caching, avoiding N+1 queries in hooks, loading assets only where needed and profiling, with runnable query counters.
- Testing Modules Test PrestaShop modules with PHPUnit: keep logic out of core classes, wrap Configuration and Context behind interfaces, run integration tests in Docker, and use static analysis. Includes a runnable mini test harness.
Projects
- Project: Delivery Estimate Module Build a complete PrestaShop module that shows an estimated delivery window on the product page, with a cutoff time, business days, holidays, a config page, a template and tests.
- Project: Wishlist Lite Module Build a small PrestaShop wishlist module: a table, an ajax front controller, customer context, a product page button and a clean uninstall, with runnable SQLite stand-ins.
- Project: Order Export to CSV Add an Export CSV bulk action to the PrestaShop orders grid: a Symfony route, permission checks, a streamed CSV and safe cell values, with runnable stand-ins.
- Project: A Simple Payment Gateway Module Build a redirect-style PrestaShop payment module: a payment option, redirect and return, signed webhook verification and safe order creation, with runnable stand-ins.
Practice and Review
- Practice Exercises with Solutions Ten hands-on PrestaShop module exercises on hooks, configuration, ObjectModel, upgrades, controllers, templates and security, each with a runnable plain-PHP solution.
- PrestaShop Interview Questions Prepare for a PrestaShop developer interview: clear answers on architecture, hooks vs overrides, ObjectModel, the Symfony migration, security and performance.
- PrestaShop Module Cheat Sheet A quick PrestaShop module reference: skeleton, naming rules, common hooks, Configuration/Db/Tools calls, console commands, routing YAML and an upgrade checklist.