prestashop-module
Skill2 starsChanged 4 months agoMITView on GitHub
PrestaShop module development guide. Covers module structure, hooks, controllers, database schemas, payment modules, and overrides in PHP/Smarty.
- Reads credentials
- Deletes or force-pushes
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- allure-reportsSkill
- android-nativeSkill
- appian-lowcodeSkill
- appium-mobileSkill
- behave-bddSkill
- BiDiWave Cross-BrowserSkill
- BiDiWave Network InterceptionSkill
- CDPWave DebuggingSkill
- CDPWave TestingSkill
- db2-oracleSkill
- ebook-writerSkill
- flask-apiSkill
- flet-desktopSkill
- google-crawling-indexingSkill
- google-ranking-appearanceSkill
- google-seo-fundamentalsSkill
- google-seo-monitoringSkill
- jinja2-templatesSkill
- jmeter-load-testingSkill
- k6-load-testingSkill
- karate-api-testingSkill
- octane-almSkill
- paramiko-sshSkill
- postman-api-automationSkill
- prompt-engineering-best-practicesSkill
- pytest-advancedSkill
- robot-frameworkSkill
- salesforce-devSkill
- sonarqube-quality-gatesSkill
- sql-serverSkill
- Skill NameSkill
- testcontainersSkill
- wave-ecosystem-guideSkill
- WaveXis AccessibilitySkill
- WaveXis CI/CD IntegrationSkill
- wavexis-cli-automationSkill
- wavexis-mcp-agent-integrationSkill
- WaveXis Network TestingSkill
- WaveXis Performance AuditSkill
- WaveXis Session RecordingSkill
- WaveXis Web ScrapingSkill
- webdriverioSkill
- wordpress-themesSkill
- xctest-iosSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 286
Use Tools::safeOutput() and pSQL() for output escaping and SQL sanitization.
- Very specific: line 287
Use Validate class for input validation.
- Distinctive: line 288
Follow PrestaShop coding standards (PSR-2 for newer versions).
- Very specific: line 289
Use Hook::exec() instead of direct class overrides when possible.
- Very specific: line 292
Use Db::getInstance()->insert()/update()/delete() for safe queries.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PrestaShop Module Development
1. Module Structure
mymodule/
mymodule.php # Main module class (extends Module)
config.xml # Module metadata
logo.png # 32x32 icon
README.md
config/
_front.yml # Front controller routes
_admin.yml # Admin controller routes
src/
Controller/
Admin/
AdminMyModuleController.php
Front/
MyModuleFrontController.php
Entity/
MyEntity.php
Repository/
MyEntityRepository.php
Form/
MyModuleFormType.php
views/
templates/
admin/
configure.tpl / .html.twig
front/
my_page.tpl / .html.twig
css/
js/
img/
sql/
install.php
uninstall.php
translations/
es.php
fr.php
upgrade/
upgrade-1.1.0.php2. Main Module Class
<?php
// mymodule.php
if (!defined('_PS_VERSION_')) {
exit;
}
class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'front_office_features';
$this->version = '1.0.0';
$this->author = 'Mathias Paulenko Echeverz';
$this->need_instance = 0;
$this->ps_versions_compliancy = ['min' => '1.7.0.0', 'max' => '8.99.99'];
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('My Module');
$this->description = $this->l('Description of my module.');
}
public function install()
{
return parent::install()
&& $this->registerHook('displayHome')
&& $this->registerHook('displayHeader')
&& $this->installDb();
}
public function uninstall()
{
return parent::uninstall() && $this->uninstallDb();
}
private function installDb()
{
$sql = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mymodule_data` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`value` TEXT,
PRIMARY KEY (`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8mb4;';
return Db::getInstance()->execute($sql);
}
private function uninstallDb()
{
return Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mymodule_data`');
}
}3. Hooks
Display Hooks
public function hookDisplayHome($params)
{
$this->context->smarty->assign([
'my_var' => 'Hello from my module!',
]);
return $this->display(__FILE__, 'views/templates/front/home_block.tpl');
}
public function hookDisplayHeader()
{
$this->context->controller->addCSS($this->_path . 'views/css/mymodule.css');
$this->context->controller->addJS($this->_path . 'views/js/mymodule.js');
}Action Hooks
public function hookActionValidateOrder($params)
{
$order = $params['order'];
$customer = new Customer($order->id_customer);
// Custom logic after order validation
Db::getInstance()->insert('mymodule_data', [
'name' => 'order_' . $order->id,
'value' => json_encode([
'customer_email' => $customer->email,
'total' => $order->total_paid,
]),
]);
}4. Admin Controller
<?php
// src/Controller/Admin/AdminMyModuleController.php
namespace MyModule\Controller\Admin;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class AdminMyModuleController extends FrameworkBundleAdminController
{
public function indexAction(Request $request): Response
{
$form = $this->createForm(MyModuleFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// Process form data
$this->addFlash('success', $this->trans('Settings saved', 'Modules.Mymodule.Admin'));
}
return $this->render('@Modules/mymodule/views/templates/admin/configure.html.twig', [
'form' => $form->createView(),
]);
}
}5. Payment Module
class MyPaymentModule extends PaymentModule
{
public function __construct()
{
parent::__construct();
$this->name = 'mypayment';
$this->tab = 'payments_gateways';
$this->version = '1.0.0';
}
public function getPaymentOptions()
{
$paymentOption = new PaymentOption();
$paymentOption->setCallToActionText($this->l('Pay with My Gateway'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', [], true))
->setAdditionalInformation($this->fetch('module:mypayment/views/templates/hook/payment_option.tpl'));
return [$paymentOption];
}
public function hookPaymentOptions($params)
{
if (!$this->active) {
return;
}
if (!$this->checkCurrency($params['cart'])) {
return;
}
return $this->getPaymentOptions();
}
}6. Smarty Templates
{* views/templates/front/my_page.tpl *}
<div class="mymodule-block">
<h2>{$my_var|escape:'html':'UTF-8'}</h2>
{foreach from=$items item=item}
<div class="item">
<h3>{$item.name|escape:'html':'UTF-8'}</h3>
<p>{$item.description|escape:'html':'UTF-8'}</p>
</div>
{/foreach}
</div>7. Configuration and Translations
Configuration
// Save configuration
Configuration::updateValue('MYMODULE_API_KEY', 'secret_key');
// Retrieve configuration
$apiKey = Configuration::get('MYMODULE_API_KEY');Translations
// In code
$this->l('Hello World');
// translations/es.php
$GLOBALS['$_MODULE']['mymodule_123abc'] = 'Hola Mundo';8. Overrides (Use Sparingly)
// override/classes/Cart.php
class Cart extends CartCore
{
public function getProducts($refresh = false, $id_product = false, $id_country = null)
{
$products = parent::getProducts($refresh, $id_product, $id_country);
// Custom modification
foreach ($products as &$product) {
$product['custom_field'] = MyModule::getCustomValue($product['id_product']);
}
return $products;
}
}9. Best Practices
- Use
Tools::safeOutput()andpSQL()for output escaping and SQL sanitization. - Use
Validateclass for input validation. - Follow PrestaShop coding standards (PSR-2 for newer versions).
- Use
Hook::exec()instead of direct class overrides when possible. - Support multistore with
Shop::getContextShopID(). - Clear cache after configuration changes.
- Use
Db::getInstance()->insert()/update()/delete()for safe queries.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

