### PrestaShop CLI Installation Example Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/install-from-cli.md Use this command to perform a full PrestaShop installation via the command line. Ensure all required arguments are provided. ```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 ``` -------------------------------- ### Start PrestaShop Docker Installation Source: https://github.com/prestashop/docs/blob/9.x/contribute/contribute-pull-requests/contribute_using_docker.md Navigate to the cloned PrestaShop directory and start the Docker Compose services to install and run PrestaShop. This process can take 10-15 minutes. ```bash cd PrestaShop docker compose up ``` -------------------------------- ### Start PrestaShop Docker Environment Source: https://github.com/prestashop/docs/blob/9.x/themes/getting-started/environment-setup.md Start the PrestaShop Docker environment using the appropriate compose file. Use 'docker-compose-prestashop.yml' for a standard installation or 'docker-compose-flashlight.yml' for a faster startup with Flashlight. ```bash # Standard PrestaShop docker compose -f docker/docker-compose-prestashop.yml up -d # Or Flashlight (faster startup) docker compose -f docker/docker-compose-flashlight.yml up -d ``` -------------------------------- ### CLI Installer Usage Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/install-from-cli.md Instructions on how to run the CLI installer and its available arguments. ```APIDOC ## CLI Installer Usage To use the CLI installer, navigate to the `/install` (or `/install-dev`) folder in your terminal and execute the following command: ```shell php index_cli.php ``` This command will display the available options for installation. ### Arguments | 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_ | | `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 | ``` -------------------------------- ### Define PHP environment setup template Source: https://github.com/prestashop/docs/blob/9.x/modules/testing/ci-cd.md A reusable YAML anchor for installing PHP dependencies via Composer. ```yaml .before_script_php_template: &before_script_php before_script: - apt-get update && apt-get install wget git zip unzip -y - wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - php composer-setup.php - php -r "unlink('composer-setup.php'); unlink('installer.sig');" ``` -------------------------------- ### Display update:start help Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/update/update-from-the-cli.md View the available arguments and options for the update:start command. ```text $ php bin/console update:start --help ``` -------------------------------- ### Implement advanced install() method Source: https://github.com/prestashop/docs/blob/9.x/modules/creation/tutorial.md An expanded install method that handles multistore context and initializes configuration settings. ```php public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } return ( parent::install() && Configuration::updateValue('MYMODULE_NAME', 'my module') ); } ``` -------------------------------- ### Install a Module via Console Source: https://github.com/prestashop/docs/blob/9.x/development/components/console/_index.md Install a specific module using its name. This is useful for automating module setup. ```bash php bin/console prestashop:module install ps_banner ``` -------------------------------- ### Install Local Test Environment Source: https://github.com/prestashop/docs/blob/9.x/admin-api/contribute-to-core-api.md Commands to set up a local testing environment for the module, including installing dependencies, setting up assets, and installing a PrestaShop shop with fixture data. ```bash composer install # Setup your tests in local, it will: # - clone the repository # - build the assets # - install a shop with fixtures data (a working DB is needed), you can edit your DB access in the parameters.php.dist file (or in parameters.php once you have installed your local env) composer setup-local-tests ``` ```bash # To test with your parameters composer setup-local-tests -- --update-local-parameters ``` ```bash # To test with 9.0.x branch composer setup-local-tests -- --force --core-branch=9.0.x ``` -------------------------------- ### Implement basic install() method Source: https://github.com/prestashop/docs/blob/9.x/modules/creation/tutorial.md The minimal implementation of the install method, which simply calls the parent class method. ```php public function install() { return parent::install(); } ``` -------------------------------- ### Subscribing to a Single Hook Source: https://github.com/prestashop/docs/blob/9.x/development/components/hook/subscribing-to-hook.md Example of registering a single hook during the module installation process. ```php class Somemodule extends Module { public function install() { return ( parent::install() && $this->registerHook('registerGDPRConsent') // <-- shorthand to Hook::registerHook() ); } } ``` -------------------------------- ### Install Dependencies Source: https://github.com/prestashop/docs/blob/9.x/themes/hummingbird/development-workflow.md Installs exact dependency versions from the lockfile. Run this command first to set up the project environment. ```bash npm ci ``` -------------------------------- ### Install Windows Build Tools Source: https://github.com/prestashop/docs/blob/9.x/development/compile-assets.md On Windows, you might need to install `windows-build-tools` globally to ensure `node-gyp` functions correctly, which is often required during `npm install`. ```bash npm i --global windows-build-tools ``` -------------------------------- ### Create Installer Class for Module Setup in PHP Source: https://github.com/prestashop/docs/blob/9.x/modules/sample-modules/extending-sf-form-with-upload-image-field.md The Installer class handles module installation and uninstallation, including registering hooks and managing database table creation and deletion. It uses PrestaShop's Db class for database operations. ```php registerHooks($module)) { return false; } if (!$this->installDatabase()) { return false; } return true; } /** * Module's uninstallation entry point. * * @return bool */ public function uninstall(): bool { return $this->uninstallDatabase(); } /** * Install the database modifications required for this module. * * @return bool */ private function installDatabase(): bool { $queries = [ 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'supplier_extra_image` ( `id_extra_image` int(11) NOT NULL AUTO_INCREMENT, `id_supplier` int(11) NOT NULL, `image_name` varchar(64) NOT NULL, PRIMARY KEY (`id_extra_image`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;`, ]; return $this->executeQueries($queries); } /** * Uninstall database modifications. * * @return bool */ private function uninstallDatabase(): bool { $queries = [ 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'supplier_extra_image`', ]; return $this->executeQueries($queries); } /** * Register hooks for the module. * * @param Module $module * * @return bool */ private function registerHooks(Module $module): bool { $hooks = [ 'actionSupplierFormBuilderModifier', 'actionAfterCreateSupplierFormHandler', 'actionAfterUpdateSupplierFormHandler', ]; return (bool) $module->registerHook($hooks); } /** * A helper that executes multiple database queries. * * @param array $queries * * @return bool */ private function executeQueries(array $queries): bool { foreach ($queries as $query) { if (!Db::getInstance()->execute($query)) { return false; } } return true; } } ``` -------------------------------- ### Install Vue CLI and Initialize Project Source: https://github.com/prestashop/docs/blob/9.x/modules/concepts/templating/vuejs/_index.md Commands to install the Vue CLI globally and create a new project in the _dev directory. ```bash $ npm install -g @vue/cli ``` ```bash $ vue create _dev ``` -------------------------------- ### Example Nginx Server Configuration Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/nginx.md This is a comprehensive example Nginx configuration file for a PrestaShop installation. It includes settings for basic server operation, SSL, logging, and various rewrite rules for handling static assets and API requests. Remember to edit the placeholder values to match your specific domain and file paths. ```nginx server { # IPv4. listen 80; listen 443 ssl http2; # IPv6. # listen [::]:80; # listen [::]:443 ssl http2; # [EDIT] Your domain name(s) go here. server_name example.com www.example.com; # [EDIT] Path to your domain Nginx logs. # more details: https://docs.nginx.com/nginx/admin-guide/monitoring/logging/#setting-up-the-access_log access_log /var/log/nginx/example.com-access.log combined; # more details: https://nginx.org/en/docs/ngx_core_module.html#error_log error_log /var/log/nginx/example.com-error.log info; # [EDIT] Path to your SSL certificates (take a look at Certbot https://certbot.eff.org). ssl_certificate /etc/ssl/fullchain.pem; ssl_certificate_key /etc/ssl/privkey.pem; # [EDIT] Path to your PrestaShop directory. root /path/to/prestashop; index index.php; # This should match the `post_max_size` and/or `upload_max_filesize` settings # in your php.ini. client_max_body_size 16M; # Redirect 404 errors to PrestaShop. error_page 404 /index.php?controller=404; # HSTS (Force clients to interact with your website using HTTPS only). # For enhanced security, register your site here: https://hstspreload.org/. # WARNING: Don't use this if your site is not fully on HTTPS! # add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" preload; always; # XSS Protection # add_header X-XSS-Protection "1; mode=block"; # Clickjacking # add_header X-Frame-Options "SAMEORIGIN"; # X-Content Type Options # add_header X-Content-Type-Options nosniff; # Secure Cookie # add_header Set-Cookie "Path=/; HttpOnly; Secure"; # [EDIT] If you are using multiple languages. # rewrite ^/fr$ /fr/ redirect; # rewrite ^/fr/(.*) /$1; # Watch out: if you encounter issues with a quick view or shopping cart, you might want to use a different rule: # rewrite '^/((?!js|qq)[a-z]{2})/(.*)' /index.php?isolang=$1&$args last; # see: https://github.com/PrestaShop/PrestaShop/issues/14921#issuecomment-948932833 # Images. rewrite ^/(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$1$2.$3 last; rewrite ^/(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$1$2$3.$4 last; rewrite ^/(d)(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$1$2$3$4.$5 last; rewrite ^/(d)(d)(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.$6 last; rewrite ^/(d)(d)(d)(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.$7 last; rewrite ^/(d)(d)(d)(d)(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.$8 last; rewrite ^/(d)(d)(d)(d)(d)(d)(d)(-[w-]+)?/.+.(jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.$9 last; rewrite ^/(d)(d)(d)(d)(d)(d)(d)(d)(-[w-]+)?/.+.(?jpe?g|png|webp|avif)$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.$ext last; # Categories rewrite ^/c/([w.-]+)/.+.(jpe?g|png|webp|avif)$ /img/c/$1.$2 last; # AlphaImageLoader for IE and FancyBox. rewrite ^images_ie/?([^/]+).(gif|jpe?g|png|webp|avif)$ js/jquery/plugins/fancybox/images/$1.$2 last; # Web service API. rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; # Installation sandbox. rewrite ^(/install(?:-dev)?/sandbox)/.* /$1/test.php last; location / { try_files $uri $uri/ /index.php$is_args$args; } # [EDIT] Replace 'admin-dev' in this block with the name of your admin directory. location /admin-dev/ { try_files $uri $uri/ /admin-dev/index.php$is_args$args; } # .htaccess, .DS_Store, .htpasswd, etc. location ~ /.(?!well-known) { deny all; } # Source code directories. location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|var|vendor)/ { deny all; } # vendor in modules directory. location ~ ^/modules/.*/vendor/ { deny all; } # Prevent exposing other sensitive files. location ~ .(log|tpl|twig|sass|yml)$ { deny all; } # Prevent injection of PHP files. location /img { location ~ .php$ { deny all; } } location /upload { location ~ .php$ { deny all; } } location ~ [^/].php(/|$) { # Split $uri to $fastcgi_script_name and $fastcgi_path_info. fastcgi_split_path_info ^(.+?.php)(/.*); ``` -------------------------------- ### Install a Module Source: https://github.com/prestashop/docs/blob/9.x/modules/testing/resources.md Installs a specified module. Use `php app/console` for versions prior to 1.7.4. ```bash php bin/console prestashop:module install paypal ``` -------------------------------- ### Run PrestaShop CLI Installer Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/install-from-cli.md Execute the CLI installer script from the /install or /install-dev directory. This command, by default, displays available installation options. ```shell php index_cli.php ``` -------------------------------- ### Example: Generate XML Hooks List Source: https://github.com/prestashop/docs/blob/9.x/development/components/console/prestashop-update-hooks-documentation.md This example demonstrates how to generate an XML file containing all discovered hooks from the PrestaShop codebase. ```bash php bin/console prestashop:update:hooks-documentation xml hooks-list.xml ``` -------------------------------- ### Install Dependencies Source: https://github.com/prestashop/docs/blob/9.x/development/compile-assets.md Run this command in the root of a subproject to install necessary dependencies for asset compilation. This is typically done once. ```bash npm install ``` -------------------------------- ### Integrate Installer with Main Module Class in PHP Source: https://github.com/prestashop/docs/blob/9.x/modules/sample-modules/extending-sf-form-with-upload-image-field.md This snippet shows how to use the Installer class within the main module class to manage the module's installation and uninstallation processes. It calls the parent install/uninstall methods and then delegates to the installer. ```php install($this); } /** * @return bool */ public function uninstall() { $installer = new Installer(); return $installer->uninstall() && parent::uninstall(); } ``` -------------------------------- ### Clone and install the PrestaShop shop creator Source: https://github.com/prestashop/docs/blob/9.x/scale/benchmark/_index.md Use these commands to download the shop creator tool and install its dependencies. ```text git clone https://github.com/PrestaShop/prestashop-shop-creator cd prestashop-shop-creator composer install ``` -------------------------------- ### Install Dependencies and Build Theme Assets Source: https://github.com/prestashop/docs/blob/9.x/themes/getting-started/quick-start.md Install project dependencies using npm and compile source files into production-ready assets for your theme. ```bash npm ci npm run build ``` -------------------------------- ### Install and Enable Module via CLI Source: https://github.com/prestashop/docs/blob/9.x/modules/creation/adding-configuration-page-modern.md Use the PrestaShop console commands to install and enable your module from the command line. ```bash php bin/console prestashop:module install demosymfonyformsimple php bin/console prestashop:module enable demosymfonyformsimple ``` -------------------------------- ### General Routing Configuration Example Source: https://github.com/prestashop/docs/blob/9.x/development/architecture/modern/controller-routing.md A general example of a route definition in YAML, showing path, methods, controller, and legacy controller/link mappings. ```yaml route_name: path: some/url methods: [GET] defaults: _controller: 'PrestaShopBundle\Controller\Path\To\ControllerClass::{actionName}Action' _legacy_controller: LegacyController _legacy_link: {LegacyController}:{actionName} ``` -------------------------------- ### Hook Call Example Source: https://github.com/prestashop/docs/blob/9.x/modules/concepts/hooks/list-of-hooks/displayAdminProductsMainStepRightColumnBottom.md This example shows how to call the displayAdminProductsMainStepRightColumnBottom hook in the origin file (Twig template). ```APIDOC ## Call of the Hook in the origin file ### Description This section shows how the hook is called within the PrestaShop core files. ### Method Twig Function ### Endpoint N/A (Core function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```php {{ renderhook('displayAdminProductsMainStepRightColumnBottom', { 'id_product': productId }) }} ``` ### Response #### Success Response (200) Modules hooked to this action can return HTML content to be displayed. #### Response Example ```html
Module content
``` ``` -------------------------------- ### Manually Set Start Parameter for Data Export Source: https://github.com/prestashop/docs/blob/9.x/development/components/export/csv-response.md Specify a custom starting point for data retrieval using the setStart() method, in conjunction with setLimit() and the data callback. ```php return (new CsvResponse()) ->setHeadersData($headersData) ->setData($dataCallback) ->setStart($start) ->setLimit($limit); ``` -------------------------------- ### Configure shop creator parameters Source: https://github.com/prestashop/docs/blob/9.x/scale/benchmark/_index.md Example of the configuration prompts provided when setting up the shop creator. ```text Creating the "app/config/config.yml" file Some parameters are missing. Please provide them. shop_id (1): customers (100): manufacturers (100): suppliers (10): addresses (100): aliases (100): categories (100): warehouses (2): carriers (3): specific_prices (100): attribute_groups (10): products (100): attributes (10): carts (1000): cart_rules (100): customizations (10): features (100): feature_values (5): orders (10): guests (10): order_histories (6): range_prices (100): range_weights (100): product_attributes (5): images (100): order_messages (100): deliveries (100): connections (1000): product_suppliers (10): order_carriers (2): order_details (10): feature_products (5): stores (100): profiles (10): stock_availables (1): langs ([fr_FR, en_US]): ``` -------------------------------- ### Initialize library with Composer Source: https://github.com/prestashop/docs/blob/9.x/webservice/tutorials/prestashop-webservice-lib/setup-library.md Usage example after setting up Composer autoloading. ```php registerHook('actionGetExtraMailTemplateVars'); } public function hookActionGetExtraMailTemplateVars($hookArgs) { dump($hookArgs); // Adapted from PrestaShop Email Manager Module $hookArgs['extra_template_vars']['{password}'] = '*******'; } ``` ### Response #### Success Response (200) Modifies the `$hookArgs['extra_template_vars']` array with new key-value pairs. #### Response Example (No direct response, modifies array in place) ``` -------------------------------- ### API Resource Boolean Field Example Source: https://github.com/prestashop/docs/blob/9.x/admin-api/contribute-to-core-api.md Illustrates the naming convention for boolean fields, which should not start with 'is'. Use a direct name like 'enabled' or 'ready'. ```php public bool $ready; ``` -------------------------------- ### Start the Docker stack Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/prestashop-flashlight.md Initialize the PrestaShop Flashlight containers using Docker Compose. ```bash docker compose up ``` -------------------------------- ### API Resource Localized Property Example Source: https://github.com/prestashop/docs/blob/9.x/admin-api/contribute-to-core-api.md Demonstrates the naming convention for localized properties, which should not start with 'localized'. The #[LocalizedValue] attribute is used for automatic locale conversion. ```php public array $names; ``` -------------------------------- ### Clone Hummingbird and Initialize New Theme Source: https://github.com/prestashop/docs/blob/9.x/themes/create-a-theme/from-hummingbird.md Clone the Hummingbird theme and detach it from its Git history to start a new project. This is typically run from the `/themes/` directory of your PrestaShop installation. ```bash git clone https://github.com/PrestaShop/hummingbird.git mytheme cd mytheme rm -rf .git && git init # Detach from Hummingbird's history and start your own git add -A && git commit -m "Initial commit from Hummingbird" ``` -------------------------------- ### Initialize PrestaShop Docker environment Source: https://github.com/prestashop/docs/blob/9.x/admin-api/setup-development-environment.md Clones the repository and starts the Docker containers for local development. ```bash git clone -b 9.0.x git@github.com:PrestaShop/PrestaShop.git prestashop-90x cd prestashop-90x make docker-start # The installation runs in background and takes a few minutes, you can run this command to see its progress make docker-logs # Once you see the message "Starting web server now" you're good to go ``` -------------------------------- ### Execute update:check-modules Command (All Modules Compatible) Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/update/update-from-the-cli.md Run the `update:check-modules` command with the admin directory argument. This example shows the output when all installed modules are compatible with the target PrestaShop version. ```text $ php bin/console update:check-modules admin-dev Prestashop version: 8.2.4 Retrieving modules informations, please wait... Retrieving modules informations: Done. ✔ There is no action needed on the installed modules for this update. ``` -------------------------------- ### Example output of the about command Source: https://github.com/prestashop/docs/blob/9.x/development/components/console/about.md This shows the expected output format including Symfony kernel, PHP, and PrestaShop specific sections. ```bash $ php bin/console about -------------------- ------------------------------------------- Symfony -------------------- ------------------------------------------- Version 6.4.26 Long-Term Support Yes End of maintenance 11/2026 (in +327 days) End of life 11/2027 (in +692 days) -------------------- ------------------------------------------- Kernel -------------------- ------------------------------------------- Type AdminKernel Environment dev Debug true Charset UTF-8 Cache directory ./var/cache/dev/admin (16.7 MiB) Build directory ./var/cache/dev/admin (16.7 MiB) Log directory ./var/logs (82 KiB) -------------------- ------------------------------------------- PHP -------------------- ------------------------------------------- Version 8.4.6 Architecture 64 bits Intl locale en_US_POSIX Timezone Europe/Warsaw (2026-01-07T15:39:24+01:00) OPcache true APCu false Xdebug false -------------------- ------------------------------------------- -------------- ------- PrestaShop -------------- ------- Version 9.1.0 Debug mode false Smarty Cache true -------------- ------- ``` -------------------------------- ### PHP CRUD Integration Test for Attribute Groups Source: https://github.com/prestashop/docs/blob/9.x/admin-api/contribute-to-core-api.md This PHP code defines an integration test for the attribute group API endpoint. It covers setup, teardown, and testing of GET, POST, PATCH, and DELETE operations. Use this to ensure API contract adherence and data integrity. ```php [ 'GET', '/attributes/group/1', ]; yield 'create endpoint' => [ 'POST', '/attributes/group', ]; yield 'patch endpoint' => [ 'PATCH', '/attributes/group/1', ]; yield 'delete endpoint' => [ 'DELETE', '/attributes/group/1', ]; yield 'list endpoint' => [ 'GET', '/attributes/groups', ]; yield 'bulk delete endpoint' => [ 'PUT', '/attributes/groups/delete', ]; } public function testAddAttributeGroup(): int { $itemsCount = $this->countItems('/attributes/groups', ['attribute_group_read']); $postData = [ 'names' => [ 'en-US' => 'name en', 'fr-FR' => 'name fr', ], 'publicNames' => [ 'en-US' => 'public name en', 'fr-FR' => 'public name fr', ], 'type' => 'select', 'shopIds' => [1], ]; // Create an attribute group, the POST endpoint returns the created item as JSON $attributeGroup = $this->createItem('/attributes/group', $postData, ['attribute_group_write']); $this->assertArrayHasKey('attributeGroupId', $attributeGroup); $attributeGroupId = $attributeGroup['attributeGroupId']; // IMPORTANT: Assert the FULL response data, not individual fields (CI requirement) // This ensures the complete API contract is tested $this->assertEquals( ['attributeGroupId' => $attributeGroupId] + $postData, $attributeGroup ); $newItemsCount = $this->countItems('/attributes/groups', ['attribute_group_read']); $this->assertEquals($itemsCount + 1, $newItemsCount); return $attributeGroupId; } /** * @depends testAddAttributeGroup * * @param int $attributeGroupId * * @return int */ public function testGetAttributeGroup(int $attributeGroupId): int { $attributeGroup = $this->getItem('/attributes/group/' . $attributeGroupId, ['attribute_group_read']); $this->assertEquals([ 'attributeGroupId' => $attributeGroupId, 'names' => [ 'en-US' => 'name en', 'fr-FR' => 'name fr', ], 'publicNames' => [ 'en-US' => 'public name en', 'fr-FR' => 'public name fr', ], 'type' => 'select', 'shopIds' => [1], ], $attributeGroup); return $attributeGroupId; } /** * @depends testGetAttributeGroup * * @param int $attributeGroupId * * @return int */ public function testPartialUpdateAttributeGroup(int $attributeGroupId): int { $patchData = [ 'names' => [ 'en-US' => 'updated name en', 'fr-FR' => 'updated name fr', ], 'publicNames' => [ 'en-US' => 'updated public name en', 'fr-FR' => 'updated public name fr', ], 'type' => 'radio', 'shopIds' => [1], ]; $updatedAttributeGroup = $this->partialUpdateItem('/attributes/group/' . $attributeGroupId, $patchData, ['attribute_group_write']); $this->assertEquals(['attributeGroupId' => $attributeGroupId] + $patchData, $updatedAttributeGroup); } } ``` -------------------------------- ### Query string examples for shop context Source: https://github.com/prestashop/docs/blob/9.x/admin-api/multi-shop.md Use query string parameters to specify the shop context for API requests. The `shopId` targets a single shop, `shopIds` targets a comma-separated list of shops, `shopGroupId` targets all shops within a group, and `allShops` targets every shop in the installation. ```bash # Single shop curl --location 'http://yourdomain.test/admin-api/contacts/1?shopId=2' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' ``` ```bash # A specific set of shops curl --location 'http://yourdomain.test/admin-api/contacts/1?shopIds=2,3' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' ``` ```bash # Every shop in a group curl --location 'http://yourdomain.test/admin-api/contacts/1?shopGroupId=1' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' ``` ```bash # All shops curl --location 'http://yourdomain.test/admin-api/contacts/1?allShops=1' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' ``` -------------------------------- ### Create PrestaShopWebservice instance Source: https://github.com/prestashop/docs/blob/9.x/webservice/tutorials/prestashop-webservice-lib/setup-library.md Instantiate the client with the store URL, authentication key, and debug mode flag. ```php * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ declare(strict_types=1); namespace PrestaShop\Module\DemoViewOrderHooks\Install; use Db; class InstallerFactory { public static function create(): Installer { return new Installer( new FixturesInstaller(Db::getInstance()) ); } } ``` -------------------------------- ### Email Route Configuration with Index Action Source: https://github.com/prestashop/docs/blob/9.x/development/architecture/modern/controller-routing.md This example shows equivalent notations for the 'index' action, demonstrating how `index`, `list`, or no action name can be used. ```yaml admin_emails: path: /emails methods: [GET] defaults: _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:index' _legacy_controller: AdminEmails _legacy_link: - AdminEmails - AdminEmails:index - AdminEmails:list ``` -------------------------------- ### Manual library installation Source: https://github.com/prestashop/docs/blob/9.x/webservice/tutorials/prestashop-webservice-lib/setup-library.md Load the library manually if not using Composer. ```php registerHook('registerGDPRConsent'); } public function hookRegisterGDPRConsent($parameters) { // This is where you can modify/alter the behavior of PrestaShop. // The content of $parameters will depend on what is sent when the hook is dispatched. } ``` -------------------------------- ### Verify Docker and Docker Compose Installation Source: https://github.com/prestashop/docs/blob/9.x/themes/getting-started/requirements.md Run these commands to check if Docker and Docker Compose are installed and to verify their versions. Requires Docker to be installed and running. ```bash docker --version docker compose version ``` -------------------------------- ### Create Log and Var Logs Directories Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/_index.md Create the 'log' and 'var/logs' directories if they do not already exist, before setting permissions. ```bash $mkdir log var/logs ``` -------------------------------- ### Export with auto-install Source: https://github.com/prestashop/docs/blob/9.x/development/components/console/prestashop-translation-export-module.md Automatically installs the module before exporting if it is not already installed. ```bash php bin/console prestashop:translation:export-module mymodule --auto-install ``` -------------------------------- ### Create a backup with images included Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/update/update-from-the-cli.md Executes the backup:create command to back up files, database, and images. The admin directory name is required. ```bash php bin/console backup:create admin123 --include-images=1 ``` -------------------------------- ### Display help for backup:create command Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/update/update-from-the-cli.md Use this command to view detailed help and options for creating a backup. The admin directory name is a mandatory argument. ```bash php bin/console backup:create --help ``` -------------------------------- ### Initialize and Configure ChoiceColumn Source: https://github.com/prestashop/docs/blob/9.x/development/components/grid/columns-reference/choice.md Demonstrates how to create and configure a ChoiceColumn instance with various options including field, route, choice provider, color field, and record route parameters. ```php setName('Status'); $choiceColumn->setOptions([ 'field' => 'current_state', 'route' => 'admin_orders_list_update_status', 'choice_provider' => $this->orderStatesChoiceProvider, 'color_field' => 'color', 'record_route_params' => [ 'id_order' => 'orderId', ], ]); $columns = new ColumnCollection(); $columns->add($choiceColumn); ``` -------------------------------- ### Blank Schema Example Source: https://github.com/prestashop/docs/blob/9.x/webservice/resources/translated_configurations.md An example of the XML structure for a blank translated configuration. ```APIDOC ## Blank Schema Example ### Description This provides an XML representation of an empty translated configuration structure. ### Request Example ```xml ``` ``` -------------------------------- ### PrestaShop Installation Success Confirmation Source: https://github.com/prestashop/docs/blob/9.x/basics/installation/advanced/install-from-cli.md This message indicates that the PrestaShop installation has completed successfully. ```shell -- Installation successful! -- ``` -------------------------------- ### Save API Documentation to File Source: https://github.com/prestashop/docs/blob/9.x/development/components/console/prestashop-generate-apidoc.md This example demonstrates how to redirect the command's output to a JSON file for further use. ```bash php bin/console prestashop:generate:apidoc > api-docs.json ``` -------------------------------- ### PHPUnit Output Example Source: https://github.com/prestashop/docs/blob/9.x/modules/testing/advanced-checks.md Example output showing successful execution of unit tests. ```text $ php vendor/bin/phpunit tests PHPUnit 5.7.27 by Sebastian Bergmann and contributors. ................... 19 / 19 (100%) Time: 40 ms, Memory: 4.00MB OK (19 tests, 28 assertions) ``` -------------------------------- ### Display backup:restore help Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/update/update-from-the-cli.md View the help documentation and available options for the backup:restore command. ```text $ php bin/console backup:restore --help Description: Restore the store to a previous state from a backup file. Usage: backup:restore [options] [--] Arguments: admin-dir The admin directory name. Options: --backup=BACKUP Specify the backup name to restore (this can be found in your folder /autoupgrade/backup/) -h, --help Display help for the given command. When no command is given display help for the list command -q, --quiet Do not output any message -V, --version Display this application version --ansi|--no-ansi Force (or disable --no-ansi) ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: This command allows you to restore the store to a previous state from a backup file.See https://devdocs.prestashop-project.org/9/basics/keeping-up-to-date/upgrade-module/upgrade-cli/#rollback-cli for more details ``` -------------------------------- ### Install MySQL utilities Source: https://github.com/prestashop/docs/blob/9.x/basics/keeping-up-to-date/migration.md Installs the necessary package to access the mysqldiff tool on Ubuntu systems. ```bash apt install mysql-utilities ``` -------------------------------- ### Example Build Output Source: https://github.com/prestashop/docs/blob/9.x/modules/concepts/templating/vuejs/_index.md Terminal output showing successful compilation of Vue.js files into the PrestaShop views directory. ```text $ npm run dev [...] DONE Compiled successfully in 2679ms 19:17:27 File Size Gzipped ../views/js/chunk-vendors.js 121.79 KiB 44.16 KiB ../views/js/app.js 5.41 KiB 1.94 KiB Images and other types of assets omitted. DONE Build complete. The ../views directory is ready to be deployed. INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html ``` -------------------------------- ### PHPStan Output Example Source: https://github.com/prestashop/docs/blob/9.x/modules/testing/advanced-checks.md Example output showing a detected compatibility error during static analysis. ```text $ _PS_ROOT_DIR_=/var/www/html vendor/bin/phpstan analyse --configuration=tests/phpstan/phpstan.neon ------ ------------------------------------------------------------------ Line controllers/admin/AdminAjaxPoppromoController.php ------ ------------------------------------------------------------------ 428 Call to an undefined static method ImageType::getFormatedName(). ------ ------------------------------------------------------------------ [ERROR] Found 1 error ``` -------------------------------- ### Install Dependencies and Build Theme Source: https://github.com/prestashop/docs/blob/9.x/themes/create-a-theme/from-hummingbird.md Install project dependencies using `npm ci` for reproducible builds and then compile the theme assets with `npm run build`. Use `npm run watch` for automatic recompilation during development. ```bash npm ci # Installs exact versions from the lockfile. Use this instead of npm install for reproducible builds npm run build ``` -------------------------------- ### TranslateType Usage Example Source: https://github.com/prestashop/docs/blob/9.x/development/components/form/types-reference/translate-type.md Example of how to use the TranslateType in a form builder, including options for translation. ```APIDOC ## TranslateType Usage Example ### Description This example demonstrates how to integrate the `TranslateType` into a Symfony form builder. It shows how to configure options such as the input type, locales, tab visibility, and labels for translatable fields. ### Method N/A (This is a form type usage example, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```php $builder->add('custom_value', TranslateType::class, [ 'type' => FormType\TextType::class, 'options' => [], 'locales' => $this->locales, 'hideTabs' => true, 'required' => false, 'label' => $this->translator->trans('OR Customized value', [], 'Admin.Catalog.Feature'), ]); ``` ### Response N/A (This is a form type usage example, not an API endpoint) ``` -------------------------------- ### TranslatableChoiceType Usage Example Source: https://github.com/prestashop/docs/blob/9.x/development/components/form/types-reference/translatable-choice-type.md Example of how to use TranslatableChoiceType in a form builder, demonstrating its options and attributes. ```APIDOC ## TranslatableChoiceType ### Description Class TranslatableChoiceType adds translatable choice types with custom inner type to forms. Language selection uses a dropdown. ### Namespace PrestaShopBundle\Form\Admin\Type ### Type Options | Option | Type | Default value | Description | | :----------- | :----- | :-------------------------------- | :---------------------------------------------------------------------------------------- | ### Code Example ```php $builder->add('template', TranslatableChoiceType::class, [ 'label' => $this->trans('Template', 'Admin.Shopparameters.Feature'), 'hint' => $this->trans('Select an email template that will be sent after setting this status.', 'Admin.Shopparameters.Help'), 'required' => false, 'choices' => $this->templates, 'row_attr' => $this->templateAttributes + [ 'class' => 'order_state_template_select', ], 'button' => [ 'label' => $this->trans('Preview', 'Admin.Actions'), 'icon' => 'visibility', 'class' => 'btn btn-primary', 'id' => 'order_state_template_preview', ], ]) ``` ```