25,19 €
Elevate your e-commerce game and beat the competition by unleashing the power of PrestaShop 8.x with Symfony-based modules, customizable themes, and much more
Purchase of the print or Kindle book includes a free PDF eBook
Key Features
Understand the data and object architecture of the legacy and new Symfony core of PrestaShop
Create modules to add features such as content blocks, payment options, and carriers to your store
Learn to customize themes and override existing module templates
Book Description
After version 1.7, PrestaShop underwent a host of changes, including migration to a Symfony-based system from an outdated legacy code. This migration brought about significant changes for developers, from routine maintenance to module development. Practical Module Development for PrestaShop 8 is curated to help you explore the system architecture, including migrated and non-migrated controllers, with a concise data structure overview. You’ll understand how hooks enable module customization and optimize the CMS.
Through the creation of seven modules, you’ll learn about the structure of modules, hook registration, the creation of front-office controllers, and Symfony back-office controllers. By using Doctrine entities, services, CQRS, grids, and forms, you’ll be guided through the creation of standard, payment and carrier modules. Additionally, you'll customize and override themes to achieve your desired e-commerce store look.
By the end of this book, you’ll be well equipped to provide modern solutions with PrestaShop that meet client requirements.
What you will learn
Understand the structure of PrestaShop’s core
Explore hooks and their functions
Create a hello world module
Build modules to display blocks in the front office with different styles
Design a module to add fields to the category pages and manage them
Fashion a blogging module with front and modern back-office controllers
Fabricate payment and carrier modules to improve the user experience
Customize a theme by creating a child theme
Who this book is for
If you are a junior or advanced PHP developer already using PrestaShop as a simple user willing to know more or to solve online sellers' problems by creating modules as a professional, this book is definitely for you. In order to learn from this book, you should have a basic knowledge of the Symfony framework. This book will be a really good help for the module developers expecting to move from the old legacy environment to the modern one. Other CMS developers can use that book as a tool to compare and move to PrestaShop.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 318
Veröffentlichungsjahr: 2023
Create modern, customizable, and dynamic online stores using efficient modules
Louis AUTHIE
BIRMINGHAM—MUMBAI
Copyright © 2023 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Alok Dhuri
Publishing Product Manager: Himani Dewan
Content Development Editor: Rosal Colaco
Technical Editor: Jubit Pincy
Copy Editor: Safis Editing
Project Coordinator: Manisha Singh
Proofreader: Safis Editing
Indexer: Pratik Shirodkar
Production Designer: Alishon Mendonca
Developer Relations Marketing Executives: Deepak Kumar and Mayank Singh
First published: April 2023
Production reference: 1070423
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-83763-596-2
www.packtpub.com
To my honey, Alice, and my lovely boys, Tom and Noé.
– Louis AUTHIE
Louis AUTHIE is a freelance full-stack developer with over 25 years of experience in PHP. He graduated from the ENAC, Toulouse, France in 2011 as an engineer and from the CNAM Paris, France as an analyst programmer in 2017.
Since 2012, he’s developed and maintained modules and themes from various versions of PrestaShop. Becoming an associate for Label Naturel’s bedding e-shop in 2016 improved his awareness of online sellers’ challenges. In 2019, he started contributing to the PrestaShop open source project, first to the documentation, then to back-office migration and bug fixes. Louis co-founded Web-Helpers, a web agency, in 2020, and teaches professionals in PHP, WordPress, PrestaShop, and Symfony development as a consultant trainer.
I want to thank my girlfriend and our beloved boys who supported me during this writing adventure, even if they won’t understand a word of this book! Thanks to my family for their good care. Thanks to all the Packt Publishing staff who guided me during the whole process, and special thanks to my amazing reviewers, Hervé Hennes and Franck Lefevre.
All the royalties of this book will be donated to the Friends of PrestaShop association, which constantly contributes to the PrestaShop Project and manages a very helpful Slack channel.
Hervé Hennes, the lead developer at Advisa, is a senior PrestaShop developer, and Magento certified. His famous blog at h-hennes is a must-read for all PrestaShop and Magento developers.
Franck Lèfevre has been a self-made PHP developer for more than 15 years. Working as a freelance developer, he helps businesses to solve their technical problems. He is a big expert on PrestaShop and remains the main PrestaShop open source project contributor. He is also an indie maker and the creator of the Skypaper application.
Since version 1.7, PrestaShop began its migration from the old legacy core to a brand new Symfony-based system, this has resulted in many changes for developers, from maintenance to module development, and that’s what this book is all about.
The 16 chapters are grouped into 3 sections, each of which can be read individually. Feel free to go directly to what you need; there are no rules! However, it is best to read everything if you want to get the big picture of the system.
The first section explains how the legacy and the Symfony core work together and explores the main components of PrestaShop. There, we use many reverse engineering analyses. Even if it can be tough sometimes, the general idea is to show us how and where to search into the core objects so as to be able to find answers and go further.
The second section explains how to create various types of modules, with many hands-on examples. This practical approach will enable us to face most of our everyday requests from the simplest Hello World! to a full blogging module. Carrier and payment modules are also covered.
The third section provides the best practices and solutions to customize the themes and graphical parts of PrestaShop: child theme creation, module template and asset overrides, and asset bundling with Webpack.
As you can see, many aspects of PrestaShop are covered in this book, and our method is different from the general feature listings available in the developers’ documentation. The main target is to provide a practical approach with examples, which is lacking on the web or in the multiple available sources of information.
I hope you will enjoy your journey into the PrestaShop development world and that this book will become a useful toolbox!
If you are a PHP developer already using PrestaShop as a simple user wanting to know more or solve online sellers’ problems by creating modules as a professional, either in a web agency or freelance, this book is definitely for you. In order to learn from this book, you should have a basic knowledge of the Symfony framework. This book will be a really good help for the module developers expecting to move from the old legacy environment to Symfony. Magento or WooCommerce developers can use this book as a tool to compare and move to PrestaShop.
Chapter 1, Quick Overview of the System, explores the structure of PrestaShop.
Chapter 2, Configuration and Initialization of PrestaShop, explains the initialization process of PrestaShop and how to configure it.
Chapter 3, The Front Office, shows how front office pages are generated in PrestaShop.
Chapter 4, The Back Office, shows how Symfony-based and legacy-based back office pages are processed.
Chapter 5, The Hooks, explains what Hooks are, and why they are so important for PrestaShop module developers.
Chapter 6, The Themes, covers the structure of a theme.
Chapter 7, What Are Modules? Let’s Create a Hello World Module, shows you how to create your first simple module.
Chapter 8, A Reinsurance Block Module, shows you how to create a module to increase the rate of conversion for your shop.
Chapter 9, A Customer Callback Request Module, shows you how to create a modern module using Symfony and find a way to get customer details to increase the rate of purchase.
Chapter 10, Category Extension Module, shows you how to create a category extension module to add fields to your category page in the back office and provide them to the front office.
Chapter 11, A Simple Blogging Module, shows you how to create a simple blog module with posts and post categories to apply all the most useful pieces of knowledge in module development.
Chapter 12, A Cash Payment Module, shows you how to create a payment module with its specificities.
Chapter 13, A Drive Delivery Module, shows you how to create a carrier module with a pickup relay point choice in the checkout process.
Chapter 14, How To Create a Child Theme, explains how to extend an existing theme by creating a child theme.
Chapter 15, Overriding Some Templates, teaches you how to override module templates and assets to make them fit in a theme graphical context.
Chapter 16, Assets Compiling with Webpack, offers a simple guide to use the Webpack bundler.
You will need to be an intermediate PHP developer, having a basic knowledge of Symfony and knowing how to use PrestaShop and its back office. You will also need an operational PrestaShop v1.7.x or 8.x version installed, functional, and accessible. All the code examples have been tested using PrestaShop 1.7.8.8 and 8.1.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Practical-Module-Development-for-Prestashop-8. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/9XyJg
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Usually, handling a form submission is done with the help of the handle() method of the FormHandler instance.”
A block of code is set as follows:
$this->hookDispatcher->dispatchWithParameters('actionAfterCreate' . Container::camelize($form->getName()) . 'FormHandler', [ 'id' => $id, 'form_data' => &$data, ]);Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Let’s install the module by browsing the Modules | Module Manager page of the PrestaShop BO.”
Tips or important notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read Practical Module Development for Prestashop 8, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link belowhttps://packt.link/free-ebook/9781837635962
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyMastering the mechanics of PrestaShop is a prerequisite for a good understanding of how modules are embedded in to the system. In this first part, we will explain the data structure and present the architecture of the whole system from the front-office to back-office controllers (migrated or not). Then, we will learn how Hooks work and enable modules to customize and improve the CMS. Finally, we will discover the themes, defining the graphical appearance of the front office.
This part has the following chapters:
Chapter 1, Quick Overview of The SystemChapter 2, Configuration and Initialization of PrestaShopChapter 3, The Front OfficeChapter 4, The Back OfficeChapter 5, The HooksChapter 6, The ThemesKnowing how data storage works and how the system is structured, we can dive into the initialization routines of PrestaShop. All this description of the CMS will enable us to master it, to understand how modules embed into the system, and how we will be able to use its components. By following the initialization process, we will see when and how the system is configured and how we can set some important constants to ease our development and change the database connection and cookies parameters.
In this chapter, we will cover the following main topics:
The legacy Front Office(FO) controller initializationThe legacy Back Office (BO) and Symfony admin controller initializationThe most important constants to set as a developerThe Dispatcher classBy the end of this chapter, you will know how an FO and a BO page initialize their controllers to generate the view even with a new Symfony-based one. You will understand how and when the main configuration and settings constants are set and how to manage them.
As we will explore the environment of PrestaShop to understand how everything is articulated, you will have to use the following tools to do reverse engineering:
Any PHP code editorAn (S)FTP client to browse your website files (only if you work on a remote server, not necessary if you work on a local server)