diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index e1a050c43f..1280f6b775 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -4,7 +4,7 @@ Thank you for contributing to the PrestaShop developer documentation!
Please take the time to edit the "Answers" rows below with the necessary information.
Check out our contribution guidelines on how to contribute:
-https://devdocs.prestashop.com/8/contribute/documentation/how/
+https://devdocs.prestashop-project.org/8/contribute/documentation/how/
------------------------------------------------------------------------------>
| Questions | Answers
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1589d30cc9..c43ec88de9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,7 +20,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
- hugo-version: '0.82.0'
+ hugo-version: '0.85.0'
extended: true
- name: Find version from branch name (pull request)
@@ -55,4 +55,6 @@ jobs:
mv _current "src/content/$VERSION"
- name: Build
+ env:
+ DEVDOCS_GITHUB_READ_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd src/ && hugo
diff --git a/README.md b/README.md
index 8988633359..a31b83a39f 100644
--- a/README.md
+++ b/README.md
@@ -3,11 +3,11 @@
[](https://github.com/PrestaShop/docs/actions/workflows/build.yml)
[](https://github.com/PrestaShop/docs/actions/workflows/update-site.yml)
-This documentation is available at https://devdocs.prestashop.com/
+This documentation is available at [https://devdocs.prestashop-project.org/](https://devdocs.prestashop-project.org/)
## Contributing
-Contributions are more than welcome! [Find out how](https://devdocs.prestashop.com/8/contribute/documentation/how/).
+Contributions are more than welcome! [Find out how](https://devdocs.prestashop-project.org/8/contribute/documentation/how/).
## Rendering the site locally
diff --git a/_index.md b/_index.md
index 8c0b96dce1..7e56c7d17e 100644
--- a/_index.md
+++ b/_index.md
@@ -3,8 +3,9 @@ title: PrestaShop 8 Documentation
menuTitle: PrestaShop 8
versionId: "8" # this should match the physical directory in devdocs-site
versionGithubPath: "8.x" # this should match the branch name in github
-versionMeta: Dev # only one version can be current!
+versionMeta: Current # only one version can be current!
chapter: true
+hookListUrl: "/8/modules/concepts/hooks/list-of-hooks" # this allows for dynamic hook results in algolia's docsearch
---
# PrestaShop 8 Documentation
diff --git a/basics/_index.md b/basics/_index.md
index e64fdcef06..d88ed4ec46 100755
--- a/basics/_index.md
+++ b/basics/_index.md
@@ -3,6 +3,8 @@ title: Basics
weight: 1
pre: "1. "
chapter: true
+showOnHomepage: true
+icon: fa-play
---
### Chapter 1
diff --git a/basics/deployment/_index.md b/basics/deployment/_index.md
index 0b78074608..71abd64652 100644
--- a/basics/deployment/_index.md
+++ b/basics/deployment/_index.md
@@ -1,6 +1,7 @@
---
title: Deployment
-weight: 18
+weight: 40
+showOnHomepage: true
---
# Deployment
diff --git a/basics/installation/_index.md b/basics/installation/_index.md
index 229d8e08b8..ce60cb1777 100644
--- a/basics/installation/_index.md
+++ b/basics/installation/_index.md
@@ -1,6 +1,7 @@
---
title: Installation
-weight: 15
+weight: 20
+showOnHomepage: true
---
# Installation
diff --git a/basics/installation/configuration.md b/basics/installation/configuration.md
deleted file mode 100644
index b0ae071a25..0000000000
--- a/basics/installation/configuration.md
+++ /dev/null
@@ -1,119 +0,0 @@
----
-title: Configuration
-weight: 30
----
-
-# Configuring PrestaShop
-
-By default, PrestaShop is configured to provide a secure and stable environment to both the shop administrator and the customers.
-
-As a developer, there are several changes that you could and should bring to the default installation in order to help you code better, spot bugs faster, and generally make a great PrestaShop product.
-
-## Disabling the cache and forcing Smarty compilation
-
-When your development has an impact on the front office, whether you are building a theme or simply a module which displays information to the customer, you should force the template file compilation and disable the cache, so as to always see the result of your changes directly.
-
-Go to the “Performance” page under the “Advanced parameters” menu to change the following Smarty settings:
-
-* Template cache: switch it to “Force compilation”.
-* Cache: disable it.
-
-Forcing the compilation of Smarty will always slow down the loading time of the page. Make sure that your production store is set to only recompile templates if there are updated files, and that its cache is enabled.
-
-## Displaying error messages
-
-PrestaShop’s default settings prevent the customer to see any server error message or any debugging code.
-
-You, on the other hand, need this information in order to correct any potential mistake in your code. To that end, open the `/config/defines.inc.php` file, and edit it to set `_PS_MODE_DEV_` to `true`:
-
-```php
-caching = false;` as it is.
-
-`$smarty->compile_check` should be left to `false` in development mode.
-
-`$smarty->debugging` gives access to Smarty debug information when displaying a page. That setting is more easily modified in the “Performance” page of the advanced parameters menu : the “Debug console” option enables you to choose between never displaying Smarty’s debug information, always displaying it, or only displaying it when you add `?SMARTY_DEBUG` to the URL of the page you want to test, which can be very useful.
-
-When in production mode, `$smarty->force_compile` must be set to `false`, as it will give a 30% boost to your page load time.
-
-On the other hand, when editing a `.tpl` file, you must delete the `/var/cache/(dev|prod)/smarty/compile` folder (except the `index.php` file) in order to see your changes applied or clear cache directly from Back-Office.
-
-Note that this setting can be made directly from the back office, in the “Performance” page under the “Advanced parameters” menu.
-
-### parameters.php
-
-This file contains some of important settings such as database connection details and caching mechanism. If you change something in this file, make sure to delete cache files manually from `/var/cache/(dev|prod)` folder.
-
-## Disable the Back-Office token protection
-
-Back-Office pages require the use of a token. If needed, this protection can be disabled using an environment variable:
-
-### Apache with mod_headers
-
-```bash
-SetEnv _TOKEN_ disabled
-```
-
-### Nginx with ngx_http_headers_module
-
-```bash
-add_header _TOKEN_ disabled;
-```
diff --git a/basics/installation/httpd.md b/basics/installation/httpd.md
index b6e41f6481..e21ab89bca 100644
--- a/basics/installation/httpd.md
+++ b/basics/installation/httpd.md
@@ -44,12 +44,13 @@ It may be incomplete, and remember you must adapt it for your own server's needs
## With PHP-FPM
You first have to ensure you have the `php-fpm` binary and Apache's FastCGI installed.
-On a Debian based, packages are `libapache2-mod-fcgid` and `php7.1-fpm`.
+On a Debian based, packages are `libapache2-mod-fcgid` and `php7.2-fpm`.
After installing these packages, fpm service will automatically be started.
PHP-FPM uses so-called pools to handle incoming FastCGI requests.
Here's an example:
+
```ini
; a pool called www
[www]
@@ -57,7 +58,7 @@ user = www-data
group = www-data
; use a unix domain socket
-listen = /var/run/php/php7.1-fpm.sock
+listen = /var/run/php/php7.2-fpm.sock
; or listen on a TCP socket
; listen = 127.0.0.1:9000
@@ -92,7 +93,7 @@ Don't forget to edit this configuration to make it works.
# with mod_rewrite or mod_autoindex
# SetHandler proxy:fcgi://127.0.0.1:9000
- SetHandler proxy:unix:/var/run/php/php7.1-fpm.sock|fcgi://dummy
+ SetHandler proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://dummy
DocumentRoot /path/to/prestashop
diff --git a/basics/installation/install-from-cli.md b/basics/installation/install-from-cli.md
new file mode 100644
index 0000000000..268c6669c1
--- /dev/null
+++ b/basics/installation/install-from-cli.md
@@ -0,0 +1,111 @@
+---
+title: Installing PrestaShop from CLI
+menuTitle: Installation from CLI
+weight: 15
+---
+
+# Installing PrestaShop from CLI
+
+Since version 1.5.4, PrestaShop has a command-line installer.
+
+This special installer makes it possible to install PrestaShop without the need to use a web browser: simply put the content of the zip archive on your web server or pull code from an official PrestaShop repository, and you can install PrestaShop through your command-line interface (CLI).
+
+{{% notice info %}}
+If deploying from sources (PrestaShop repository), you must first install Composer dependencies.
+Install them with `composer install` from project's root directory.
+{{% /notice %}}
+
+The point of having a CLI installer in addition to the regular in-browser installer is to provide a solution to some advanced users, who often prefer command-line interfaces as they tend to give a more concise and powerful means to control a program or operating system. We can see the advantage of CLI installer in Continuous Integration processes.
+
+## How to use it
+
+To use the CLI installer, use your terminal, go to the `/install` (or `/install-dev`) folder, and start the script with this command:
+
+```shell
+php index_cli.php
+```
+
+This command, by default, will display the various available options:
+
+| Argument | Description | Default value | Allowed values |
+| :-------------- | :----------------------------------------- | :--------------------------- | :---------------------------------------------------------------------------------------------------- |
+| `step` | Installation steps to execute | all | all, database, fixtures, theme, modules, postInstall |
+| `language` | Language ISO code to install | en | 2 letters ISO 639-1 code ([ISO 639-1][iso-639-1]) with available translation files in `/translations` |
+| `all_languages` | Installs all available languages | 0 | 0, 1 |
+| `timezone` | Set timezone of instance | Europe/Paris | Valid timezone ([TZ Database][tz-database]) |
+| `base_uri` | Base URI (appended after domain name) | / | Any URI |
+| `domain` | Domain name for the shop (without http/s) | localhost | Any domain name or IP address |
+| `db_server` | Database server hostname | localhost | Any valid MySQL valid server name or IP address |
+| `db_user` | Database server user | root | Any valid MySQL user name |
+| `db_password` | Database server password | "" | The valid password for `db_user` |
+| `db_name` | Database name | prestashop | _string_ |
+| `db_clear` | Drop existing tables | 1 | 0, 1 |
+| `db_create` | Create the database if not exists | 0 | 0, 1 |
+| `prefix` | Prefix of table names | ps\_ | _string_ |
+| `engine` | Engine for MySQL | InnoDB | InnoDB, MyISAM |
+| `name` | Name of the shop | PrestaShop | _string_ |
+| `activity` | Default activity of the shop | 0 | Id of an activity ([Complete list of activities][activities]) |
+| `country` | Country of the shop | fr | 2 letters Alpha-2 code of ISO-3166 list([ISO-3166][iso-3166]) |
+| `firstname` | Admin user firstname | John | _string_ |
+| `lastname` | Admin user lastname | Doe | _string_ |
+| `password` | Admin user password | Correct Horse Battery Staple | _string_ |
+| `email` | Admin user email | pub@prestashop.com | _string_ |
+| `license` | Show PrestaShop license after installation | 0 | 0, 1 |
+| `theme` | Theme name to install | "" (classic) | Theme name (located in `/themes`) |
+| `ssl` | Enable SSL (from PS 1.7.4) | 0 | 0, 1 |
+| `rewrite` | Enable rewrite engine | 1 | 0, 1 |
+| `fixtures` | Install fixtures | 1 | 0, 1 |
+| `modules` | Modules to install, separated by comma | [] (all) | _array_ of module names (located in `/modules`) |
+
+- All the options from the regular in-browser installer are available, with their default values listed above.
+- Almost all default option values can be left as is because you can edit them all from the PrestaShop Back Office once the installation is complete.
+
+{{% notice info %}}
+Note that the e-mail and password are used to create the administrator's Back Office account.
+{{% /notice %}}
+
+To start the installation, we recommend that you provide at least these arguments :
+
+- `domain`. The domain name where your shop will be available.
+- `db_server`. The database server address.
+- `db_name`. The name of the database you want to use. **We strongly recommend that you change the default `prestashop` value**
+- `db_user`. The username for the database you want to use.
+- `db_password`. The password for the database username above.
+- `prefix`. **We strongly recommend that you change the default `ps_` value.**
+- `email`. Your email to connect to the Back Office.
+- `password`. The password to connect to the Back Office.
+
+Example:
+
+```shell
+php index_cli.php
+ --domain=example.com
+ --db_server=sql.example.com
+ --db_name=myshop
+ --db_user=root
+ --db_password=123456789
+ --prefix=myshop_
+ --email=me@example.com
+ --password=mystrongpassword
+```
+
+If the installation completes without any errors, you should see the following confirmation:
+
+```shell
+-- Installation successful! --
+```
+
+{{% notice info %}}
+Before running this command, please note that your database must be created with a `CREATE DATABASE xxx;` statement.
+If the database is not created, please use argument `--db_create=1` to create the database.
+{{% /notice %}}
+
+{{% notice info %}}
+If your MySQL server is configured on a different port than `3306`, please specify it in the `db_server` argument like this :
+`--db_server=sql.example.com:3307`
+{{% /notice %}}
+
+[iso-639-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
+[tz-database]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
+[activities]: https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/General/PreferencesType.php#L211-L230
+[iso-3166]: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
diff --git a/basics/installation/localhost.md b/basics/installation/localhost.md
index 7111319777..dab8bd3ccc 100644
--- a/basics/installation/localhost.md
+++ b/basics/installation/localhost.md
@@ -2,6 +2,7 @@
title: Installing a local environment
menuTitle: Development environment
weight: 15
+mostViewedPage: true
---
# Installing PrestaShop for development
@@ -16,14 +17,14 @@ Read [System Requirements][system-requirements].
Installing any web-application locally requires that you first install the adequate environment, namely the Apache web server, the PHP language interpreter, the MySQL database server, and ideally a MySQL admin tool such as phpMyAdmin tool.
-This is called an *AMP package: Apache+MySQL+PHP and the operating system, giving WAMP (Windows+Apache+MySQL+PHP), MAMP (Mac OS X+…) and LAMP (Linux+…). Since all of the items packaged are open-source, these installers are most of the time free.
+This is called an *AMP package: Apache+MySQL+PHP and the operating system, giving WAMP (Windows+Apache+MySQL+PHP), MAMP (macOS…) and LAMP (Linux+…). Since all of the items packaged are open-source, these installers are most of the time free.
Here is a selection of free AMP installers:
-* [XAMPP](https://www.apachefriends.org/download.html) (Windows, Mac OS X, Linux, Solaris)
+* [XAMPP](https://www.apachefriends.org/download.html) (Windows, macOS, Linux, Solaris)
* [WampServer](http://www.wampserver.com/) (Windows)
* [EasyPHP](https://www.easyphp.org/) (Windows)
-* [MAMP](https://www.mamp.info/en/mamp/) (Windows, Mac OS X)
+* [MAMP](https://www.mamp.info/en/mamp/) (Windows, macOS)
* [Laragon](https://laragon.org/) (Windows)
To install LAMP on your computer follow these steps (tested on Debian Buster).
@@ -123,11 +124,11 @@ If you intend to work on PrestaShop itself, we suggest using Git to clone the so
As stated above, if you decide to work on PrestaShop itself, it's best to clone the PrestaShop repository and work using git. Depending on the version of PrestaShop you want to work on, you will need to choose the right branch:
-* The [develop branch](https://github.com/PrestaShop/PrestaShop/tree/develop) contains the current work in progress for the next minor or major version.
+* The [develop branch](https://github.com/PrestaShop/PrestaShop/tree/8.0.x) contains the current work in progress for the next minor or major version.
- **This is the right branch to contribute new features, refactors, small bug fixes, etc.**
* The maintenance branches (_8.0.x, ..._) contains all patches made for each minor version.
- For example, the _8.0.x_ branch contains all patches from 8.0.0 to 8.0.99.
- - Whenever a new minor or major version is ready for release, a new maintenance branch is created. For example, _8.0.x_ for version 8.0.0, _8.1.x_ for 8.1.0, 8.2.x_ for 8.2.0, and so forth.
+ - Whenever a new minor or major version is ready for release, a new maintenance branch is created. For example, _8.0.x_ for version 8.0.0, _8.1.x_ for 8.1.0, and so forth.
- **Only the most recent maintenance branch accepts new contributions**
{{% /callout %}}
@@ -155,16 +156,26 @@ composer install
# or alternatively:
make composer
```
+
### JavaScript and CSS dependencies
PrestaShop uses NPM to manage dependencies and [Webpack][webpack] to compile them into static assets.
-You only need NodeJS 8.x (14.x recommended [get it here][nodejs]), NPM will take care of it all.
+You only need NodeJS 14.x (16.x recommended [get it here][nodejs]), NPM will take care of it all.
```bash
cd /path/to/prestashop
make assets
```
+You can also compile assets for the particular element of the system:
+
+- `make admin-default` - for the legacy back office theme
+- `make admin-new-theme` - for the new back office theme
+- `make front-core` - front office theme core assets
+- `make front-classic` - front office default theme assets
+- `make front` - all assets for the the front office
+- `make admin` - all assets for the the back office
+
Alternatively, you can [compile assets][compile-assets] manually.
@@ -174,8 +185,6 @@ PrestaShop needs recursive write permissions on several directories:
- ./admin-dev/autoupgrade
- ./app/config
-- ./app/logs
-- ./app/Resources/translations
- ./cache
- ./config
- ./download
@@ -190,13 +199,15 @@ PrestaShop needs recursive write permissions on several directories:
- ./var
You can set up the appropriate permissions using this command:
+
```bash
-$ chmod -R +w admin-dev/autoupgrade app/config app/logs app/Resources/translations cache config download img log mails modules override themes translations upload var
+$ chmod -R +w admin-dev/autoupgrade app/config var/logs cache config download img log mails modules override themes translations upload var
```
If you do not have some of the folders above, please create them before changing permissions. For example:
+
```bash
-$ mkdir log app/logs
+$ mkdir log var/logs
```
To ease up your life on a development environment, we suggest to make Apache run with your own user and group.
@@ -224,7 +235,7 @@ You may find this error message the first time you open up the Back Office.
This problem may arise in case-insensitive file systems like MacOS due to a misconfiguration. Check your Apache configuration and make sure that the root directory path to your PrestaShop matches the capitalization of the actual system path exactly. A typical error is for example having a folder named `/path/to/PrestaShop` (capital P, capital S) and then configuring it in Apache as `/path/to/Prestashop` (missing the capital S).
-[getting-started-guide]: https://doc.prestashop.com/display/PS17/Getting+Started
+[getting-started-guide]: https://docs.prestashop-project.org/v.8-documentation/v/english/getting-started
[system-requirements]: {{< relref "system-requirements" >}}
[clone-the-repository]: {{< relref "/8/themes/getting-started/setting-up-your-local-environment" >}}
[compile-assets]: {{< relref "/8/development/compile-assets" >}}
diff --git a/basics/installation/nginx.md b/basics/installation/nginx.md
index ef958cf3ce..99dcebf1d8 100644
--- a/basics/installation/nginx.md
+++ b/basics/installation/nginx.md
@@ -141,4 +141,4 @@ server {
}
```
-[nginx-scale]: {{< ref "1.7/scale/webservers/nginx" >}}
+[nginx-scale]: {{< ref "8/scale/webservers/nginx" >}}
diff --git a/basics/installation/system-requirements.md b/basics/installation/system-requirements.md
index 7a2178f40e..cbaf9a4a82 100644
--- a/basics/installation/system-requirements.md
+++ b/basics/installation/system-requirements.md
@@ -2,6 +2,7 @@
title: System requirements for PrestaShop 8
menuTitle: System requirements
weight: 10
+mostViewedPage: true
---
+
+# Notable changes in PrestaShop 8.1
+
+## PHP support
+
+PrestaShop 8.1 has the same PHP requirement as Prestashop 8.0.
+
+[PrestaShop 8.0][80-changes] added support for PHP 8.0 and PHP 8.1 and required at least PHP 7.2.5.
+
+## New product page
+
+The new Product page in Back Office has been introduced. [Discover how to extend it with modules in this chapter][new-product-page].
+
+## Notable changes
+
+* Introduction of `_raw` parameter on translations to avoid html escaping in translator. [PR#30415](https://github.com/PrestaShop/PrestaShop/pull/30415)
+* Changed location of Smarty caching type configuration from database to `config/defines.inc.php` [PR#29172](https://github.com/PrestaShop/PrestaShop/pull/29172)
+* Improve extendability of the new product page form in BO: added `NavigationTabType` to create custom tabs in BO product page [PR#28752](https://github.com/PrestaShop/PrestaShop/pull/28752)
+* Moved grid column type classes, see deprecation list below [PR#30800](https://github.com/PrestaShop/PrestaShop/pull/30800)
+* Behavior change: when deleting an image type, its images are now deleted [PR#30510](https://github.com/PrestaShop/PrestaShop/pull/30510)
+* Auto update of modules configuration option is no longer available [PR#30467](https://github.com/PrestaShop/PrestaShop/pull/30467)
+* Added getters in `CmsController`, `OrderConfirmationController`, `ProductController`, `CategoryController`, `ManufacturerController`, `SupplierController` [PR#30408](https://github.com/PrestaShop/PrestaShop/pull/30408)
+* Added `Currency::getDefaultCurrencyId()` method to avoid retrieving `PS_CURRENCY_DEFAULT` from configuration in various classes [PR#30398](https://github.com/PrestaShop/PrestaShop/pull/30398)
+* `actionAjaxDieBefore` now receives its `value` parameter via reference [PR#30347](https://github.com/PrestaShop/PrestaShop/pull/30347)
+* Deprecated `Validate::isAnything()` since it was always returning `true` [PR#30163](https://github.com/PrestaShop/PrestaShop/pull/30163)
+* Refactored frontend sitemap and introduced `actionModifyFrontendSitemap` hook [PR#29797](https://github.com/PrestaShop/PrestaShop/pull/29797)
+* Introduced `actionGenerateDocumentReference` hook to allow overriding order reference [PR#29781](https://github.com/PrestaShop/PrestaShop/pull/29781)
+* Introduced 3 new hooks about Contact Page: `displayContactRightColumn`, `displayContactContent`, `displayContactLeftColumn` in `classic` and `hummingbird` themes, and removed related widget hooks [PR#29516](https://github.com/PrestaShop/PrestaShop/pull/29516)
+* Introduced `Tools::getCurrentUrl()` to retrieve the current URL in a hook [PR#28541](https://github.com/PrestaShop/PrestaShop/pull/28541)
+* BC break: `Shop::getBaseURL()` use secure mode by default [PR#28469](https://github.com/PrestaShop/PrestaShop/pull/28469)
+* Vue was upgraded from 2.6 to 3.2, see below [PR#28463](https://github.com/PrestaShop/PrestaShop/pull/28463)
+* Customer Settings > Customer page is now multistore compatible [PR#27608](https://github.com/PrestaShop/PrestaShop/pull/27608)
+* Introduced `PrestaShop\PrestaShop\Core\Security\PasswordGenerator` class to generate random passwords with multiples types/lengths [PR#31004](https://github.com/PrestaShop/PrestaShop/pull/31004)
+* Introduced `PrestaShop\PrestaShop\Core\Security\Hashing` class to hash a password from a plain text and a salt with md5 [PR#31004](https://github.com/PrestaShop/PrestaShop/pull/31004)
+* Introduced `actionProductPriceCalculation` hook [PR#27927](https://github.com/PrestaShop/PrestaShop/pull/27927)
+* Added a new Smarty variable `theme_dir` in front controllers [PR#30383](https://github.com/PrestaShop/PrestaShop/pull/30383)
+* Added a feature to disable `core.js` loading on custom themes [PR#29995](https://github.com/PrestaShop/PrestaShop/pull/29995). [More informations][corejs-informations]
+* Added supplier url and manufacturer url to Smarty `{url}` helper [PR#30242](https://github.com/PrestaShop/PrestaShop/pull/30342) and [PR#30314](https://github.com/PrestaShop/PrestaShop/pull/30314)
+* Fixed modules autoloaders and service configurations registrations priority [PR#30588](https://github.com/PrestaShop/PrestaShop/pull/30588). [More informations]({{< relref "/8/modules/concepts/services/#advanced-services-parameters-_instanceof-or-interface-binding-manual-tags" >}})
+
+## BC Breaks (Backward Compatibility Breaks)
+
+* `Shop::getBaseURL()` use secure mode by default [PR#28469](https://github.com/PrestaShop/PrestaShop/pull/28469)
+* For the class `PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult`, constructor parameters are now `TaxRulesGroupId $taxRulesGroupId, string $name, bool $active, array $shopAssociationIds` [PR#28812](https://github.com/PrestaShop/PrestaShop/pull/28812)
+* Webservice does now respect the maximum image upload size set in back office (`PS_LIMIT_UPLOAD_IMAGE_VALUE`) [PR#29135](https://github.com/PrestaShop/PrestaShop/pull/29135)
+
+## Deprecations
+
+### PHP
+
+* `PrestaShop\PrestaShop\Core\String\CharacterCleaner` → Its use is not required
+* `Customer::validateController()` → The password check has been moved in controllers and this method is not called anywhere since 1.7.0
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\BooleanColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BooleanColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\ColorColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ColorColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\DataColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DataColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\DisableableLinkColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DisableableLinkColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\LinkGroupColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkGroupColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\OrderPriceColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Order\OrderPriceColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\PreviewColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PreviewColumn`
+* `Prestashop\PrestaShop\Core\Grid\Column\Type\PrivateColumn` → moved to `PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PrivateColumn`
+* `CmsController::$cms` → use `$cmsControllerInstance->getCms()` instead
+* `CmsController::$cms_category` → use `$cmsControllerInstance->getCmsCategory()` instead
+* `Validate::isAnything()` → will be removed in 9.0 since returns always `true`
+
+## Updated dependencies
+
+### PHP libraries
+
+| Library name | Old version | New version |
+|------------------------------------|---------------------------------------------------------------|---------------|
+| api-platform/core | _~ Not present ~_ | ^2.7 |
+| lcobucci/jwt | _~ Not present ~_ | ^3.4.6 |
+| league/oauth2-server | _~ Not present ~_ | ^8.3 |
+| nyholm/psr7 | _~ Not present ~_ | ^1.5 |
+| symfony/psr-http-message-bridge | _~ Not present ~_ | ^2.1 |
+
+### JS libraries
+
+| Library name | Old version | New version |
+|------------------------------------|---------------------------------------------------------------|---------------|
+| vue | 2.6.x | 3.2.x |
+
+{{% notice note %}}
+As `Vue` 2.x [will reach EOL on December 31st, 2023](https://v2.vuejs.org/lts/), `Vue` dependency was bumped to 3.2.
+Every linked dependencies were also bumped to higher version to keep 3.2 compatibility.
+Please refer to: [PR#28463](https://github.com/PrestaShop/PrestaShop/pull/28463) for an exhaustive list.
+{{% /notice %}}
+
+[80-changes]: {{< relref "8/modules/core-updates/8.0.md" >}}
+[corejs-informations]: {{< relref "8/themes/getting-started/theme-yml" >}}
+[new-product-page]: {{< relref "8/modules/sample-modules/extend-product-page" >}}
\ No newline at end of file
diff --git a/modules/core-updates/_index.md b/modules/core-updates/_index.md
index 58e76a01fb..6138600419 100644
--- a/modules/core-updates/_index.md
+++ b/modules/core-updates/_index.md
@@ -2,6 +2,7 @@
title: Core changes
weight: 60
chapter: true
+showOnHomepage: true
---
# Core changes
diff --git a/modules/core-updates/img/password-policy-bo.png b/modules/core-updates/img/password-policy-bo.png
new file mode 100644
index 0000000000..91d58cc581
Binary files /dev/null and b/modules/core-updates/img/password-policy-bo.png differ
diff --git a/modules/core-updates/img/password-policy-fo.png b/modules/core-updates/img/password-policy-fo.png
new file mode 100644
index 0000000000..beb37ddfae
Binary files /dev/null and b/modules/core-updates/img/password-policy-fo.png differ
diff --git a/modules/core-updates/new-password-policy.md b/modules/core-updates/new-password-policy.md
new file mode 100644
index 0000000000..602d10bf07
--- /dev/null
+++ b/modules/core-updates/new-password-policy.md
@@ -0,0 +1,73 @@
+---
+title: New password policy based on zxcvbn
+menuTitle: New password policy
+---
+
+# New password policy introduced in 8.0.x
+
+A new password policy was introduced in 8.0.x for Customers and Employees passwords.
+
+This password policy is based on `Zxcvbn`.
+
+{{% notice note %}}
+`Zxcvbn` is a password strength estimation library that is designed to help developers create secure password policies for their applications. It was developed by DropBox and [is available as an open-source library](https://github.com/dropbox/zxcvbn).
+
+It estimates the strength of a password by analyzing various factors such as its length, the use of special characters, and the presence of common words or patterns. The goal of zxcvbn is to provide a more accurate and user-friendly way of assessing password strength compared to traditional approaches, which often rely on simple checks such as minimum length or the presence of certain types of characters.
+
+To use `Zxcvbn`, you provide the password as input to the library and it returns an estimated strength score. The score is a number between 0 and 4, with higher numbers indicating stronger passwords. This score is then used to provide feedback to users on the strength of their chosen password.
+{{% /notice %}}
+
+When creating / updating a `Customer` account, or an `Employee` account, the `Zxcvnb` api is used to determine the score, and make an instant feedback using Javascript to the `User`:
+
+
+
+
+
+## Changes introduced in PrestaShop by this new policy
+
+This new password policy introduced some backward compatibility breaks:
+
+* File `jquery-passy.js` is no longer available
+* Form field `change-password` is no longer working as it was for [passy](https://timseverien.github.io/passy/) integration
+* The password now requires a correct length whatever is it the Front or the Back Office
+* `AddEmployeeCommand` now requires `hasEnabledGravatar`, `minLength`, `maxLength` and `minScore`
+* `EditEmployeeCommand::setPlainPassword` now requires `minLength`, `maxLength` and `minScore`
+* `Employee\ValueObject::Password` now requires `minLength`, `maxLength` and `minScore`
+* `Employee/EmployeeType` now requires an instance of `ConfigurationInterface`
+* `ChangePasswordType` now requires an instance of `ConfigurationInterface`
+* `Core/Domain/Employee/ValueObject/Password::MIN_LENGTH` and `Core/Domain/Employee/ValueObject/Password::MAX_LENGTH` are no longer available
+* `Employee\ValueObject\Password::__construct` signature changed to `string $password, int $minLength, int $maxLength, int $minScore`
+* `PrestaShopBundle/Form/Admin/Type/ChangePasswordType::__construct` now require a `ConfigurationInterface`
+
+And some deprecations:
+
+* `Validate::isPlaintextPassword` is deprecated
+* `Validate::isPasswdAdmin` is deprecated
+
+{{% notice note %}}
+Please note that the library is loaded asyncronously in `core.js` because of its size.
+{{% /notice %}}
+
+## Upgrade guide for your module / theme
+
+### How to update your code for backend development
+
+If your module is creating / updating `Customers` or `Employees`, make sure to update your code according to the BC breaks and deprecations indicated above.
+
+### How to update your frontend theme
+
+If your theme is creating / updating `Customers` or `Employees`, make sure to update your code according to the BC breaks related to themes (`jquery-passy.js` no longer available, and form field `change-password` no longer working).
+
+If your theme is extending `PrestaShop/classic-theme`,
+
+- make sure your modifications (if any) to `template/customer/_partials/customer-form.tpl` does not change the `div` added around `password fields`:
+
+```
+
+ {form_field field=$field}
+
+```
+
+- make sure your modifications on your theme does not alter the requirement of `_partials/password-policy-template.tpl` in the Javascripts includes.
+
+- make sure your modifications on your theme does not alter the `templates/_partials/form-fields.tpl` file on the password field, [please refer here for requirements](https://github.com/PrestaShop/classic-theme/pull/21/files#diff-2b3eb6586609ac820d08cd566e45c06c2dd477060b2ffadeda1fb1d2941d69b7).
\ No newline at end of file
diff --git a/modules/creation/_index.md b/modules/creation/_index.md
index 405a5ca7e1..36ce1b90aa 100644
--- a/modules/creation/_index.md
+++ b/modules/creation/_index.md
@@ -1,6 +1,7 @@
---
title: "Getting Started"
weight: 10
+showOnHomepage: true
---
# Getting Started
diff --git a/modules/creation/displaying-content-in-front-office.md b/modules/creation/displaying-content-in-front-office.md
index ea1e84e9c0..02b545c9ec 100644
--- a/modules/creation/displaying-content-in-front-office.md
+++ b/modules/creation/displaying-content-in-front-office.md
@@ -64,7 +64,7 @@ Add the following to your mymodule.php file:
{
$this->context->controller->registerStylesheet(
'mymodule-style',
- $this->_path.'views/css/mymodule.css',
+ 'modules/' . $this->name . '/views/css/mymodule.css',
[
'media' => 'all',
'priority' => 1000,
@@ -73,7 +73,7 @@ Add the following to your mymodule.php file:
$this->context->controller->registerJavascript(
'mymodule-javascript',
- $this->_path.'views/js/mymodule.js',
+ 'modules/' . $this->name . '/views/js/mymodule.js',
[
'position' => 'bottom',
'priority' => 1000,
@@ -308,8 +308,11 @@ class mymoduledisplayModuleFrontController extends ModuleFrontController
- *display.tpl*
-```
-Welcome to my shop!
+```smarty
+{extends file='page.tpl'}
+{block name='page_content'}
+ Welcome to my shop!
+{/block}
```
Let's explore `display.php`, our first PrestaShop front-end controller,
@@ -390,8 +393,11 @@ in our TPL file.
- *mymodule.tpl*
-```
-{$my_module_message}
+```smarty
+{extends file='page.tpl'}
+{block name='page_content'}
+ {$my_module_message}
+{/block}
```
PrestaShop adds its own set of variables. For instance,
diff --git a/modules/creation/external-services.md b/modules/creation/external-services.md
index 382674f01f..d35de1f21a 100644
--- a/modules/creation/external-services.md
+++ b/modules/creation/external-services.md
@@ -73,7 +73,7 @@ HTTP requests can be triggered from a shop to an external service.
Several methods allows requests to be sent (in order of preference):
-* [Guzzle](https://github.com/guzzle/guzzle). The version 5 is included from PrestaShop {{< minver v="1.7.0" >}}, but can be included in your module as well for older PS versions.
+* [Guzzle](https://github.com/guzzle/guzzle). The version 7.4 is included from PrestaShop {{< minver v="8.0" >}} (version 5 in {{< minver v="1.7.0" >}}), but can be included in your module as well for older PS versions.
* Loading in memory another version of guzzle in the same namespace will trigger errors on the shop.
* Example with PS Checkout module: [Inclusion in composer.json](https://github.com/PrestaShopCorp/ps_checkout/blob/578135d8bef2d99b8056ebc0bd709e9a87d661e6/composer.json#L28) & [implementation](https://github.com/PrestaShopCorp/ps_checkout/blob/ef48da09735e6e64b42364a703b5a74d41cd24d9/classes/Api/Payment/Dispute.php)
* [\Tools::file_get_contents(...)](https://github.com/PrestaShop/PrestaShop/blob/a07a569b45ab6afc777f25aba505997004e5f70a/classes/Tools.php#L2212-L2223)
diff --git a/modules/creation/good-practices.md b/modules/creation/good-practices.md
index 2168712a9a..fa79b02cce 100644
--- a/modules/creation/good-practices.md
+++ b/modules/creation/good-practices.md
@@ -52,9 +52,9 @@ menuTitle: Good practices
- When your module has forms, you should:
- show a confirmation message if everything went fine or an error message if it did not.
- - make sure information entered by customers are correct. If you ask a sum, it has to be only numbers. More information about the Validate class of PrestaShop [here](https://github.com/PrestaShop/PrestaShop/blob/develop/classes/Validate.php).
+ - make sure information entered by customers are correct. If you ask a sum, it has to be only numbers. More information about the Validate class of PrestaShop [here](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/classes/Validate.php).
-- Consider carefully casting your variables and use pSQL/bqSQL in the SQL requests to avoid any injections (read [Best Practices of the Db Class](https://doc.prestashop.com/display/PS16/Best+Practices+of+the+Db+Class)). Make sure your files are properly protected (especially if your module uses a cron for example) to avoid anyone being able to execute them. As a result, you are required to use a token!
+- Consider carefully casting your variables and use pSQL/bqSQL in the SQL requests to avoid any injections (read [Best Practices of the Db Class](https://docs.prestashop-project.org/1-6-documentation/developer-guide/developer-tutorials/best-practices-of-the-db-class)). Make sure your files are properly protected (especially if your module uses a cron for example) to avoid anyone being able to execute them. As a result, you are required to use a token!
- The use of overrides is permitted, however if we decide that too many (2 / 3 max) have been used and/or the modifications are too dangerous, we will refuse your module. If you're unsure, don't hesitate to get in touch.
@@ -85,9 +85,9 @@ add a preliminary check before using them (I.e with `extension_loaded`). This pr
**A few recommendations for your email templates**
-- Use our [official SDK](https://github.com/PrestaShop/email-templates-sdk) to develop your emails:
+- Use our [official SDK](https://github.com/PrestaShopCorp/email-templates-sdk) to develop your emails:
- Make sure to submit on Addons a valid zip, built with the SDK.
-- Test your emails with the [official module](https://github.com/PrestaShop/email-templates-sdk).
+- Test your emails with the [official module](https://github.com/PrestaShopCorp/email-templates-sdk).
[coding-standards]: {{< ref "8/development/coding-standards" >}}
[display-content-front-office]: {{< ref "8/modules/creation/displaying-content-in-front-office" >}}
diff --git a/modules/creation/module-translation/classic-system.md b/modules/creation/module-translation/classic-system.md
index c000187382..9cbf2bbbe9 100644
--- a/modules/creation/module-translation/classic-system.md
+++ b/modules/creation/module-translation/classic-system.md
@@ -243,7 +243,6 @@ sprintf=['[foo]' => 'some replacement, '%bar%' => 'something else']
{{% /notice %}}
-
#### Interpolating HTML
You may need to add HTML content in your translated string. Writing it directly in the string (original or translated) won't work, as the special characters would be escaped to avoid XSS security issues.
@@ -401,7 +400,7 @@ $this->l('Some '. $var . ' wording');
public function translate($wording) {
$this->l($wording);
}
-```
+```
### Language codes
@@ -415,5 +414,5 @@ In the meantime, refer to this list for the equivalences between language codes
[iso-619-1]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
[ietf-language-tags]: https://en.wikipedia.org/wiki/IETF_language_tag
-[legacy-to-standard]: https://github.com/PrestaShop/PrestaShop/blob/1.7.6.x/app/Resources/legacy-to-standard-locales.json
+[legacy-to-standard]: https://github.com/PrestaShop/PrestaShop/blob/8.0.x/app/Resources/legacy-to-standard-locales.json
[new-translation-system]: {{< ref "new-system" >}}
diff --git a/modules/creation/module-translation/new-system.md b/modules/creation/module-translation/new-system.md
index e6d5128606..ca0940e515 100644
--- a/modules/creation/module-translation/new-system.md
+++ b/modules/creation/module-translation/new-system.md
@@ -52,7 +52,7 @@ To make your module translatable, you need to adapt your module's source code. F
Don't worry if you don't translate everything to all languages right away. Any wording left untranslated will be shown in its original language. Because of this, we suggest writing all your wordings in English, and then translating them to other languages.
{{% /notice %}}
-### Translation domain
+### Translation domain {#translation-domain}
An important part of the new translation system is **Translation Domains**, which replaces the classic system's [contextualization][contextualization]. In the new translation system, all wordings must be linked to at least one translation domain.
@@ -122,12 +122,14 @@ When translating wordings in the module's main class, since it extends the `Modu
version = '1.0.0';
+ $this->author = 'Me';
$this->displayName = $this->trans('My module', [], 'Modules.Mymodule.Mymodule');
- $this->description = $this->trans('Description of my module.', [], 'Modules.Mymodule.Mymodule');
+ $this->description = $this->trans('Description of my module. Made by: %author%, Current Version: %version%', ['%version%' => $this->version ,'%author% => $this->author], 'Modules.Mymodule.Mymodule');
}
}
```
@@ -136,25 +138,25 @@ Since the module is called MyModule, the translation domain should be `Modules.M
#### Module controllers
-`ModuleAdminController` and `ModuleFrontController` can access the module instance via the `$this->module` property.
+`ModuleAdminController` and `ModuleFrontController` can access the module instance and translator via the `$this->module` property and `getTranslator()` public accessor.
```php
title = $this->module->trans('My module title', [], 'Modules.Mymodule.Something');
+ $this->title = $this->module->getTranslator()->trans('My module title', [], 'Modules.Mymodule.Something');
}
}
```
-Symfony controllers work exactly the same as the Core's. Just use `$this->trans` method.
+Symfony controllers work exactly the same as the Core's. Just use `$this->trans()` method.
{{% notice warning %}}
-Be aware that in symfony controllers, the second and third arguments have been swapped to make `$replacements` optional.
+Be aware that in Symfony controllers, the second and third arguments have been swapped to make `$replacements` optional.
{{% /notice %}}
```php
@@ -172,27 +174,32 @@ class SomeAdminController extends FrameworkBundleAdminController
#### Other classes
-Other classes will need to retrieve the module's instance somehow. We recommend passing it as a parameter in the constructor and storing it for later use.
+Other classes will need to retrieve the module's translator instance somehow. We recommend passing it as a parameter in the constructor and storing it for later use.
```php
module = $module
+ $this->translator = $translator
}
public function foo()
{
- $this->text = $this->module->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass');
+ $this->text = $this->translator->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass');
}
}
+
+// from within the module:
+$customModuleClass = new _NAMESPACE_\CustomModuleClass($this->getTranslator());
```
-If you really need to, you can also retrieve a new instance of your module using `Module::getInstanceByName('mymodulename')`. This should be avoided though, as it's not a good practice.
+{{% notice info %}}
+If you really need to, you can also retrieve a new instance of your module using `$module = Module::getInstanceByName('mymodulename')`, and then access the `translator` with `$module->getTranslator()`. This should be avoided though, as it's not a good practice.
+{{% /notice %}}
### Templates
@@ -298,7 +305,7 @@ In Twig files, you can use `trans_default_domain` to set up your default domain.
{% trans_default_domain 'Modules.Mymodule.Foo' %}
{{ 'Hello world'|trans }}
{{ 'Something else'|trans }}
-```
+```
## Distributing your translations
diff --git a/modules/creation/tutorial.md b/modules/creation/tutorial.md
index 9953490226..0091c54aee 100644
--- a/modules/creation/tutorial.md
+++ b/modules/creation/tutorial.md
@@ -10,12 +10,12 @@ weight: 1
Before you start writing code for your PrestaShop module, we recommend reading PrestaShop's [Coding standards]({{< ref "/8/development/coding-standards" >}}). Configuring your IDE hints or using [automated tools](https://github.com/PrestaShop/php-dev-tools) can help you make sure you follow the project's standards properly.
{{% /notice %}}
-Let's create a simple first module; this will enable us to better describe its structure. We will name it **"My module"**.
+Let's create a first simple module, this will allow us to better describe its structure. We will name it **"My module"**.
First, create the module's folder, in PrestaShop's `/modules` folder. Let's call it `mymodule`. This will be the module's "technical" name.
{{% notice tip %}}
-Technical names can only accept lower case alphanumeric characters (`[a-z0-9]`). Although accepted, we strongly discourage using underscores because they don't work with translation domains.
+Technical names can only accept lower case alphanumeric characters (`[a-z0-9]`). [Although accepted, we strongly discourage using underscores because they don't work with translation domains]({{< ref "/8/modules/creation/module-translation/new-system#translation-domain" >}}).
{{% /notice %}}
This folder must contain the main file, a PHP file of the same name as the folder, which will handle most of the processing: `mymodule.php`.
@@ -64,7 +64,7 @@ At this stage, if you place the module's folder on the `/modules` folder, the mo
## The constructor method
-Now, let's fill the class' code block with the essential constructor lines. Since the constructor is the first method to be called when the module is loaded by PrestaShop, this is the best place to set its details.
+Now, let's create the constructor method of the module. Since the constructor is the first method to be called when the module is loaded by PrestaShop, this is the best place to set its details.
```php
name = 'mymodule';
@@ -243,51 +243,14 @@ public function uninstall()
As you can see, our three blocks of code (`__construct()`, `install()` and `uninstall()`) all make use of a new object, `Configuration`.
-This is a PrestaShop-specific object that allows to easily manage all the shop's settings. It stores its data on the `ps_configuration` database table.
+This PrestaShop-specific object allows you to easily manage all the shop's settings. It stores its data on the `PREFIX_configuration` database table.
-### The main methods
-
-This component has three main methods, allowing you to perform basic CRUD operations:
-
-`Configuration::get('myVariable')`
-: Retrieves a specific value from the database.
-
-`Configuration::updateValue('myVariable', $value)`
-: Updates an existing setting with a new value. If the setting does not yet exist, it creates it with that value.
-
-`Configuration::deleteByName('myVariable')`
-: Deletes the setting.
-
-
-Note that when using `updateValue()`, the content of `$value` can be anything, be it a string, a number, a serialized PHP array or a JSON object. As long as you properly code the data handling function, anything goes. For instance, here is how to handle a PHP array using the `Configuration` object:
-
-```php
-}}).
+You can read more about this component in [Legacy Configuration object]({{< ref "/8/development/components/configuration/backward-compatibility" >}}) and [Configuration storage]({{< ref "/8/development/components/configuration" >}}).
{{% /notice %}}
-### Retrieving external values from the ps_configuration data table
-
-You are not limited to your own variables: PrestaShop stores all its own configuration settings in the `ps_configuration` database table. There are literally hundreds of settings, and you can access them just as easily as you would access your own. For instance:
-
-- `Configuration::get('PS_LANG_DEFAULT')`: retrieves the ID for the default language.
-- `Configuration::get('PS_TIMEZONE')`: retrieves the name of the current timezone, in standard TZ format (see: [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)).
-- `Configuration::get('PS_DISTANCE_UNIT')`: retrieves the default distance unit ("km" for kilometers, etc.).
-- `Configuration::get('PS_SHOP_EMAIL')`: retrieves the main contact e-mail address.
-- `Configuration::get('PS_NB_DAYS_NEW_PRODUCT')`: retrieves the number of days during which a newly-added product is considered "New" by PrestaShop.
-
-Dive into the `ps_configuration` table to discover many other settings!
-
## The Shop object
The `install()` method also references this:
@@ -326,8 +289,32 @@ There are many free icon libraries available on the web. Here are a few:
## Installing the module
+You have two options to install a module: from the back office interface or using the Symfony Console component (CLI-base installation)
+
+### Install module from the back office interface
+
Now that all basics are in place, reload the back office's "Module Catalog" page, in the "Front office features" section, you should find your module. Install it (or reset it if it is already installed).
+### Install module from CLI using the Symfony Console component
+
+Access your project's directory with a CLI, and run:
+
+```shell
+php bin/console prestashop:module install mymodule
+```
+
+Where `mymodule` is your module's name.
+
+To uninstall the module, run the following:
+
+```shell
+php bin/console prestashop:module uninstall mymodule
+```
+
+For more informations, please read [the reference of the ModuleCommand]({{< ref "/8/development/components/console/prestashop-module" >}})
+
+### The config.xml file
+
During the module's installation, PrestaShop automatically creates a small `config.xml` file in the module's folder, which stores the module's information. You should be very careful when editing this file by hand.
## Keeping things secure
@@ -347,9 +334,5 @@ header('Location: ../');
exit;
```
-## Further reading
-
-{{< children />}}
-
[existing-tab-sections]: {{< ref "/8/modules/concepts/module-class/#tab" >}}
-[multistore]: {{< ref "/8/development/multistore/" >}}
+[multistore]: {{< ref "/8/development/multistore/" >}}
\ No newline at end of file
diff --git a/modules/introduction.md b/modules/introduction.md
index 0756e235ff..112ff40531 100644
--- a/modules/introduction.md
+++ b/modules/introduction.md
@@ -39,7 +39,7 @@ Modules can:
PrestaShop 1.7 was built so that modules that were written for PS 1.6 can work almost as-is — save for minor changes and a cosmetic update, the template files being in need of adapting to the 1.7 default theme.
-The major module development changes in PrestaShop 1.7 are explained in details [in this Build article](https://build.prestashop.com/news/module-development-changes-in-17/), and are integrated into this updated documentation. If you already know how to create a module that works with PS 1.6, we strongly advise you to read that article from top to bottom in order to get up to speed with 1.7 development.
+The major module development changes in PrestaShop 1.7 are explained in details [in this Build article](https://build.prestashop-project.org/news/module-development-changes-in-17/), and are integrated into this updated documentation. If you already know how to create a module that works with PS 1.6, we strongly advise you to read that article from top to bottom in order to get up to speed with 1.7 development.
Some native modules have had their names changed in PrestaShop 1.7. [See the full list here]({{< ref "/8/development/native-modules/_index.md#module-name-changes-since-16" >}}).
diff --git a/modules/payment/_index.md b/modules/payment/_index.md
index d5adb798d3..077d27dbcd 100644
--- a/modules/payment/_index.md
+++ b/modules/payment/_index.md
@@ -32,7 +32,7 @@ To make a payment module for PrestaShop 1.7, you'll have to respect some element
- You'll have to register the two following methods: `hookPaymentOptions()` & `hookPaymentReturn()` and register these hooks.
- You must not have a submit button into your module's HTML code. It will automatically be generated by PrestaShop.
-In the `hookPaymentOptions()` method, you have to return an array of *[PaymentOption](https://github.com/PrestaShop/PrestaShop/blob/develop/src/Core/Payment/PaymentOption.php)*.
+In the `hookPaymentOptions()` method, you have to return an array of *[PaymentOption](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Payment/PaymentOption.php)*.
How to generate your PaymentOption
----------------------------------
@@ -76,11 +76,25 @@ We have identified four cases of payment module:
The minimal variables to set are `$callToActionText` and `$form`. You can check the `getEmbeddedPaymentOption()` method of *[paymentexample](https://github.com/PrestaShop/paymentexample)* to have an example.
-#### iFrame
+#### iframe
-: The payment form is displayed on the merchant's website, but inside an iFrame.
+: The payment form is displayed on the merchant's website, but inside an iframe.
The minimal variables to set are `$callToActionText` and `$additionalInformation`. You can check the `getIframePaymentOption()` method of *[paymentexample](https://github.com/PrestaShop/paymentexample)* to have an example.
+
+Payment modules rules
+---------------------
+
+We do have extra rules for Payment Modules as this type of modules require higher security.
+Note that there are some modules which create the Order with a pending order status during the payment processing (1), while others wait for the payment system's approval to create it (2). But none of them create an order before the customer passed the payment service (bank, PayPal...).
+
+* Make sure you double check the id_cart before creating the order.
+ * The purpose is to make sure another customer cannot validate a cart which isn't his.
+
+* if (2), make sure the amount you use to validateOrder() comes from the external payment system. Do not use Cart->getOrderTotal();
+ * For security reasons, always proceed as explained.
+
+* For (2), when receiving a call to process the payment, make sure you double check the source of the call using a signature or a token. Those values must not be known of all.
Migrating from 1.6 to 1.7
-------------------------
@@ -89,7 +103,7 @@ Migrating from 1.6 to 1.7
You need to change the *payment* hook where your module is hooked on by *paymentOption*. **It's not a display hook anymore**, so you must not use the `$this->display()` method to retrieve a template, but use the `$this->context->smarty->fetch()` method instead.
-Then, implement the `hookPaymentOptions()` function to return an array of *[PaymentOption](https://github.com/PrestaShop/PrestaShop/blob/develop/src/Core/Payment/PaymentOption.php)*.
+Then, implement the `hookPaymentOptions()` function to return an array of *[PaymentOption](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Payment/PaymentOption.php)*.
Next, you'll need to identify the type of your payment module to know which variables are mandatory.
diff --git a/modules/sample-modules/_index.md b/modules/sample-modules/_index.md
index 9299da1f67..18bb9c6a36 100644
--- a/modules/sample-modules/_index.md
+++ b/modules/sample-modules/_index.md
@@ -1,10 +1,47 @@
---
-title: Sample modules
+title: Sample modules and how to's
weight: 80
+showOnHomepage: true
---
-# Sample modules
+# Sample modules and how to guides
+
+The PrestaShop Community has made example modules and how-to guides to help you understand how to implement hooks, admin grids, manage entities... and a lot more.
{{% children %}}
+## Example modules repository
+
* [See all our example modules (GitHub)](https://github.com/PrestaShop/example-modules)
+
+This repository hosts example modules built and maintained by project members and the community.
+These modules demonstrate good use cases for developers willing to customize the software.
+
+### Extending Symfony pages
+
+- [Extending a Symfony form - how to insert a field inside an existing form](https://github.com/PrestaShop/example-modules/tree/master/demoextendsymfonyform1)
+- [Demo Extending a Symfony Form - 2](https://github.com/PrestaShop/example-modules/tree/master/demoextendsymfonyform2) - how to insert an input inside a Symfony form - 2
+- [Demo Extending a Symfony Form - 3](https://github.com/PrestaShop/example-modules/tree/master/demoextendsymfonyform3) - how to use CQRS in a module
+- [Demo View Order Hooks](https://github.com/PrestaShop/example-modules/tree/master/demovieworderhooks)
+- [Demo Extend a Grid](https://github.com/PrestaShop/example-modules/tree/master/demoextendgrid)
+- [Demo Extend Product Form V2](https://github.com/PrestaShop/example-modules/tree/master/demoproductform)
+
+### Using a tool / concept
+
+#### Symfony
+
+- [Demo Creating a Symfony Console command](https://github.com/PrestaShop/example-modules/tree/master/democonsolecommand)
+- [Demo Using PrestaShop Symfony Form Types](https://github.com/PrestaShop/example-modules/tree/master/demosymfonyform)
+- [Demo Creating modern Controllers and associate Tabs to them](https://github.com/PrestaShop/example-modules/tree/master/democontrollertabs)
+
+#### Database
+
+- [Demo Using Doctrine entities](https://github.com/PrestaShop/example-modules/tree/master/demodoctrine)
+- [Demo How to override an ObjectModel](https://github.com/PrestaShop/example-modules/tree/master/demooverrideobjectmodel)
+
+#### Other
+
+- [Demo Adding a Mail Theme](https://github.com/PrestaShop/example-modules/tree/master/example_module_mailtheme)
+- [Demo Javascript Router component usage](https://github.com/PrestaShop/example-modules/tree/master/demojsrouting)
+- [Demo Multistore form](https://github.com/PrestaShop/example-modules/tree/master/demomultistoreform)
+- [Demo Grid](https://github.com/PrestaShop/example-modules/tree/master/demo_grid)
\ No newline at end of file
diff --git a/modules/sample-modules/extend-product-page.md b/modules/sample-modules/extend-product-page.md
new file mode 100644
index 0000000000..3f2d3ee8d0
--- /dev/null
+++ b/modules/sample-modules/extend-product-page.md
@@ -0,0 +1,576 @@
+---
+title: Extending the new product page form
+weight: 3
+---
+
+# Extending the new product page form {{< minver v="8.1.0" >}}
+
+The new Back Office product page introduced in {{< minver v="8.1.0" >}} removed several hooks which were previously available on the page. Complete list of removed hooks:
+
+- `displayAdminProductsCombinationBottom`
+- `displayAdminProductsSeoStepBottom`
+- `displayAdminProductsShippingStepBottom`
+- `displayAdminProductsQuantitiesStepBottom`
+- `displayAdminProductsMainStepLeftColumnBottom`
+- `displayAdminProductsMainStepLeftColumnMiddle`
+- `displayAdminProductsMainStepRightColumnBottom`
+- `displayAdminProductsOptionsStepTop`
+- `displayAdminProductsOptionsStepBottom`
+- `displayAdminProductsPriceStepBottom`
+
+The only `displayAdminProduct*` hook that was not removed is:
+
+- `displayAdminProductsExtra`
+
+{{% notice info %}}
+Although kept for backward compatibility, this hook (`displayAdminProductsExtra`) is not recommended for new modules.
+{{% /notice %}}
+
+In this guide, we will discover how to extend the product page by adding custom fields, in the old and new ways of doing this.
+
+Finally, we will discover how to add a new tab to the product page, which is possible for a new product page from PrestaShop 8.1.
+
+## Add a custom field, before {{< minver v="8.1.0" >}}
+
+A custom field, before {{< minver v="8.1.0" >}}, was added by hooking to one of the `displayAdminProducts` hooks.
+
+For example, to add a custom field, in the `SEO` tab, you had to create a module with this content:
+
+`demooldhooks.php`:
+
+```php
+declare(strict_types=1);
+
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+
+class DemoOldHooks extends Module
+{
+ public function __construct()
+ {
+ // [...]
+ }
+
+ /**
+ * @return bool
+ */
+ public function install()
+ {
+ return parent::install() && $this->registerHook(['displayAdminProductsSeoStepBottom']);
+ }
+
+ public function hookDisplayAdminProductsSeoStepBottom($params)
+ {
+ $productId = $params['id_product'];
+ $formFactory = $this->get('form.factory');
+ $twig = $this->get('twig');
+
+ $product = new Product($productId);
+
+ $form = $formFactory
+ ->createNamedBuilder('seo_special_field', TextType::class, "")
+ ->getForm();
+
+ $template = '@Modules/demooldhooks/views/templates/seo_special_field.html.twig';
+
+ return $twig->render($template, [
+ 'seo_special_field' => $form->createView()
+ ]);
+ }
+}
+```
+
+`views/templates/seo_special_field.html.twig`:
+
+```php
+
SEO Special field
+{{ form_widget(seo_special_field) }}
+```
+
+Before {{< minver v="8.1.0" >}}, that would produce:
+
+
+
+From {{< minver v="8.1.0" >}}, this field won't be displayed as a hook (`displayAdminProductsSeoStepBottom`) is no longer available.
+
+## Add a custom field, from {{< minver v="8.1.0" >}}
+
+To do exactly the same, from {{< minver v="8.1.0" >}}, we will implement `actionProductFormBuilderModifier` hook and modify product's FormBuilder.
+
+First, create a module, with a `composer.json` file, [as instructed here]({{< relref "/8/modules/concepts/composer" >}}).
+
+`demonewhooks.php`:
+
+```php
+declare(strict_types=1);
+
+use DemoNewHooks\Form\Modifier\ProductFormModifier;
+
+class DemoNewHooks extends Module
+{
+ public function __construct()
+ {
+ // [...]
+ }
+
+ /**
+ * @return bool
+ */
+ public function install()
+ {
+ return parent::install() && $this->registerHook(['actionProductFormBuilderModifier']);
+ }
+
+ /**
+ * Modify product form builder
+ *
+ * @param array $params
+ */
+ public function hookActionProductFormBuilderModifier(array $params): void
+ {
+ /** @var ProductFormModifier $productFormModifier */
+ $productFormModifier = $this->get(ProductFormModifier::class);
+ $productId = (int) $params['id'];
+
+ $productFormModifier->modify($productId, $params['form_builder']);
+ }
+}
+```
+
+`config/services.yml`:
+
+```yml
+services:
+ DemoNewHooks\Form\Modifier\ProductFormModifier:
+ autowire: true
+ public: true
+ arguments:
+ $formBuilderModifier: '@form.form_builder_modifier'
+```
+
+`src/Form/Modifier/ProductFormModifier.php`:
+
+```php
+declare(strict_types=1);
+
+namespace DemoNewHooks\Form\Modifier;
+
+use PrestaShopBundle\Form\FormBuilderModifier;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\FormBuilderInterface;
+
+final class ProductFormModifier
+{
+ /**
+ * @var FormBuilderModifier
+ */
+ private $formBuilderModifier;
+
+ /**
+ * @param FormBuilderModifier $formBuilderModifier
+ */
+ public function __construct(
+ FormBuilderModifier $formBuilderModifier
+ ) {
+ $this->formBuilderModifier = $formBuilderModifier;
+ }
+
+ /**
+ * @param int|null $productId
+ * @param FormBuilderInterface $productFormBuilder
+ */
+ public function modify(
+ int $productId,
+ FormBuilderInterface $productFormBuilder
+ ): void {
+
+ $seoTabFormBuilder = $productFormBuilder->get('seo');
+ $this->formBuilderModifier->addAfter(
+ $seoTabFormBuilder, // the tab
+ 'tags', // the input/form from which to insert after/before
+ 'demo_module_custom_field', // your field name
+ TextType::class, // your field type
+ [
+ 'label' => 'SEO Special Field', // you can remove the label if you dont need it by passing 'label' => false
+ 'label_attr' => [ // customize label with any HTML attribute
+ 'title' => 'h2',
+ 'class' => 'text-info',
+ ],
+ 'attr' => [
+ 'placeholder' => 'SEO Special field',
+ ],
+ // this is just an example, but in real case scenario, you could have some data provider class to handle more complex cases
+ 'data' => "",
+ 'empty_data' => '',
+ 'form_theme' => '@PrestaShop/Admin/TwigTemplateForm/prestashop_ui_kit_base.html.twig',
+ ]
+ );
+ }
+}
+```
+
+This module uses a Form Builder Modifier (`FormBuilderModifier`), and adds a `TextType` field to the `SEO` tab form, after the existing `tags` form element.
+
+`FormBuilderModifier` is hooked to the `actionProductFormBuilderModifier`.
+
+These changes produces the below's:
+
+
+
+{{% notice note %}}
+This new way of adding custom fields to the product page allows you for more precise positioning. You can now position your fields/forms exactly where you want.
+{{% /notice %}}
+
+## Cheatsheet for old/new hooks / new hooks
+
+### Hook: actionProductFormBuilderModifier
+
+- Hook : [`action