ecomyseo/prestashop_skills / prestashop-module-routes
prestashop-module-routes
VerifiedSkill for defining custom front-office routes and Pretty URLs in PrestaShop modules.
PrestaShop Module Routes Skill
This skill explains how to use the moduleRoutes hook to create user-friendly (Pretty) URLs for your module's front controllers.
1. Technical Guide
Registering the Hook
The module must be registered to the moduleRoutes hook.
public function install()
{
return parent::install() && $this->registerHook('moduleRoutes');
}
Implementing hookModuleRoutes
This hook must return an array of route definitions.
public function hookModuleRoutes()
{
return [
'module-mymodule-list' => [
'rule' => 'custom-path/list',
'keywords' => [],
'controller' => 'list', // references controllers/front/list.php
'params' => [
'fc' => 'module',
'module' => $this->name
]
],
'module-mymodule-view' => [
'rule' => 'custom-path/view/{id}-{slug}',
'keywords' => [
'id' => ['regexp' => '[0-9]+', 'param' => 'id'],
'slug' => ['regexp' => '[_a-zA-Z0-9\-\.]+', 'param' => 'slug'],
],
'controller' => 'view',
'params' => [
'fc' => 'module',
'module' => $this->name
]
]
];
}
Generating URLs with Pretty Routes
$link = $this->context->link->getModuleLink('mymodule', 'view', ['id' => 10, 'slug' => 'my-product']);
// Output: https://store.com/custom-path/view/10-my-product
2. Professional Development Guide
Friendly URLs Requirement
- These routes only work if Traffic & SEO > Set up URLs > Friendly URL is enabled in the Back Office.
- If Friendly URLs are disabled, PrestaShop fallbacks to the standard
?fc=module&module=...query parameters.
Regex Best Practices
- Always use specific regex for parameters like
id([0-9]+) to avoid route collisions. - The
ruleshould be unique enough to not clash with CMS pages or Category pages.
3. User Guide
How to use
- Install the module.
- Go to Traffic & SEO and save URLs to regenerate
.htaccessif needed (usually automatic). - Access your module via the custom rules defined.
Rules & Best Practices
- Uniqueness: Route names (keys in the array) must be unique.
- Compatibility: This method works across PrestaShop 1.7, 8, and 9 for legacy Front Controllers.
- SEO: Use keywords in URLs to improve SEO ranking for module-generated pages.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |