Contents
PrestaShop
An open-source online shop: modules, hooks, Smarty templates, configuration and controllers.
1.Getting started
- What PrestaShop isWhat this online shop engine is, what it gives you right after installation and what a developer does with it.
- Installation and debug modeHow to install PrestaShop with the wizard or from the console, where the back office lives and how to turn on error display.
- Project foldersWhat the folders of an installed shop contain, which ones are yours and which ones must not be touched.
- Core conceptsFront office and back office, modules, hooks, themes, the two cores and the Context object — the vocabulary needed to read PrestaShop code.
2.The module
- The first moduleBuilding a module from scratch: the folder, the main class, constructor fields one by one, the install and uninstall methods, installing from the console.
- Display hooksHow a module adds a block to a storefront page: subscribing to a display hook, the handler method, hook parameters and a list of common hooks.
- Action hooksHow a module reacts to shop events: an order is placed, a customer registers, a product is deleted. Parameters and a list of common action hooks.
- Smarty templatesHow to move a module's HTML into a template: the views/templates folder, passing variables, Smarty conditions and loops, escaping.
- Styles and scriptsHow to load a module's CSS and JavaScript in the front office and the back office: the views/css and views/js folders, registerStylesheet, registerJavascript, passing data to a script.
- TranslationsHow to make a module's strings translatable: the trans method in PHP, the l function in Smarty templates, translation domains and the back office translations page.
3.Settings and data
- The Configuration storageWhere a module keeps its settings: the Configuration class, reading, writing and deleting values, defaults on install.
- The settings pageHow to give a module a settings page in the back office: the getContent method, a form with one field, handling the submit and success and error messages.
- HelperForm fieldsField types of the settings form: a switch, a select, a textarea. Hints, field values and checks with the Validate class.
- Module tablesHow a module creates its own table on install, drops it on uninstall and changes the structure with an upgrade script in the upgrade folder.
- Queries: Db and DbQueryHow to read and write data in a module table: the Db class, the DbQuery builder, insert, update, delete and protecting values.
- The ObjectModel classHow to describe a table row with a class: extending ObjectModel, the definition array, creating, loading, changing and deleting records with field validation.
- Core objectsHow to read shop data from a module: product, category, customer, cart and order, prices, images and links to pages.
4.Pages and the back office
- A module page in the front officeHow to give a module its own page: a ModuleFrontController in the controllers/front folder, a page template and a link through getModuleLink.
- Forms and AJAX in the front officeHow to accept a form in a module controller: the postProcess method, the token check, error and success messages, a JSON response for AJAX requests.
- A back office page: ModuleAdminControllerHow to quickly build a back office list of your table's records: the legacy ModuleAdminController, column descriptions and row actions.
- Back office menu itemsHow to add a module page to the back office menu: the tabs property, parent sections, icons, hidden tabs and permissions.
- Symfony services in a moduleHow to keep module classes in the src folder with a namespace: Composer autoload, the config/services.yml file and getting a service from the container.
- A back office page on SymfonyThe modern way to build a back office page: a route in config/routes.yml, a controller in src/Controller and a Twig template.
- Extending back office grids and formsHow to add your own column to the customers grid and your own field to a back office form with hooks, without changing core code.
5.The shop
- OverridesWhat an override is in PrestaShop, how a module replaces a method of a core class, why it is a last resort and what to use instead.
- A payment modulePayment module basics: the PaymentModule class, the paymentOptions hook, the validation controller and the validateOrder method that creates an order.
- A shipping moduleA short look at a carrier module: the CarrierModule class, creating a carrier on install and calculating the shipping cost with your own code.
- Sending emailHow a module sends an email: the Mail::Send method, mail templates in the mails folder, template variables and checking that it was sent.
- Themes and the child themeHow to change the look of the shop without losing your edits: a child theme, the theme.yml file, overriding theme templates and module templates.
- The web serviceThe shop's built-in API: how to enable the web service, create a key with permissions, read products and orders and create records with HTTP requests.
6.Going live
- Console commands and cronHow to add your own bin/console command to a module, register it as a service and run it on a schedule with cron.
- Performance and going livePrestaShop cache and performance settings, clearing the cache and a checklist before opening the shop to customers.
- Releasing and upgrading a moduleHow to prepare a module for another shop: the final structure, the version number, upgrade scripts, building the archive and installing from the back office.