This repository provides a Command that better supports PrestaShop legacy classes using the current PrestaShop Console and a list of useful commands that you can use and reuse for learning purposes.
This module is released under AFL license.
Donwload the zip release and install it like any other module.
cd modules
git clone https://github.com/friends-of-presta/fop_console.git
cd fop_console
composer install
Install the module in the backoffice or in command line like this :
cd ../../
php bin/console pr:mo install fop_console
fop:clear-cacheClear the cache folder super fastfop:debug-modeEnable or Disable debug modefop:shop-statusDisplay shop(s) status(es)fop:maintenanceget status or change maintenance mode, list or add maintenance ip addressfop:images:generate:categoriesRegenerate categories thumbnailsfop:images:generate:manufacturersRegenerate manufacturers thumbnailsfop:images:generate:productsRegenerate products thumbnailsfop:images:generate:storesRegenerate stores thumbnailsfop:images:generate:suppliersRegenerate suppliers thumbnailsfop:generate:htaccessGenerate the .htaccess filefop:generate:robotsGenerate the robots.txt filefop:theme-resetReset current (or selected) themefop:add-hook: Create a new hook in databasefop:unhook-module: Ungraft module on specific hookfop:hook-module: Graft module on specific hookfop:latest-products: Displays the latest productsfop:export: Exports object models in XMLfop:check-containerHealth check of the Service Container, for now list the services we can't use in Symfony commands
The official documentation from PrestaShop and Symfony Core teams are still right, but you needs to extends our class.
<?php
// psr-4 autoloader
// if the command is located at src/Commands
namespace FOP\Console\Commands;
// or if command is located in a subfolder
namespace FOP\Console\Commands\Domain; // e.g. namespace FOP\Console\Commands\Configuration
use FOP\Console\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class MyCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fop:mycommand') // e.g 'fop:shop-status'
// or
->setName('fop:domain:mycommand') // e.g 'fop:configuration:export'
->setDescription('Describe the command on a user perspective.');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->text('Hello friends of PrestaShop!');
return 0; // return 0 on success or 1 on failure.
}
}The current strategy is to configure a Context before the execution of the Command. This works well but we like to make it more configurable from the Console arguments.
Feel free to add more commands, post some issues or new PR : contributions are very welcome.
| Prestashop Version | Compatible |
|---|---|
| 1.7.0.x | ❌ |
| 1.7.1.x | ❌ |
| 1.7.2.x | ❌ |
| 1.7.3.x | ❌ |
| 1.7.4.x | ❌ |
| 1.7.5.x | ✔️ |
| 1.7.6.x | ✔️ |
| 1.7.7.x | ✔️ |
| Php Version | Compatible |
|---|---|
| 5.6 | ❌ |
| 7.0 | ❌ |
| 7.1 | ❌ |
| 7.2 | ✔️ |
| 7.3 | ✔️ |
| 7.4 | |
| 8.0 |