How to install a PrestaShop 9 module on PrestaShop 8.1.x (Fix version incompatibility + getTwig error)
If a module refuses to install on
PrestaShop 8.1.x and shows a version incompatibility error or the following exception:
Oops... looks like an unexpected error occurred
Attempted to call an undefined method named "getTwig"
it means the module was developed for
PrestaShop 9 and requires small compatibility adjustments.
Step 1 — Remove version restriction
- Download and extract the module ZIP file.
- Open the main module file (for example: module_name.php).
- Find the line:
$this->ps_versions_compliancy = ['min' => '9.0', 'max' => '9.9.99'];
- Replace it with:
$this->ps_versions_compliancy = ['min' => '8.0.0', 'max' => '9.9.99'];
- Save the file.
Step 2 — Fix the "getTwig" error (PrestaShop 8 compatibility)
PrestaShop 8 modules do not include the getTwig() helper expected by some PrestaShop 9 modules.
You must manually add this method.
- Open the same module file (module_name.php).
- Scroll to the end of the class.
- Locate the final closing brace:
}
- Add the following method BEFORE this line (inside the class).
Example:
The method must be added
before the last bracket, for example
between lines 950 and 951.
Insert:
/* ===== PS8 compatibility fix ===== */
protected function getTwig()
{
if (class_exists('\PrestaShop\PrestaShop\Adapter\SymfonyContainer')) {
return \PrestaShop\PrestaShop\Adapter\SymfonyContainer::getInstance()->get('twig');
}
throw new \Exception('Twig service not available.');
}
/* ===== end fix ===== */
Make sure the method is added
inside the class, not after it.
Step 3 — Repackage the module
- Re-zip the module folder.
- The ZIP root must contain the module directory itself (not nested folders).
- Upload the ZIP again via:
Back Office → Modules → Module Manager → Upload a module
Important Notes
- This workaround only enables installation on PrestaShop 8.1.x.
- Some modules may still use PrestaShop 9-specific services or APIs.
- Additional small fixes may be required depending on the module.

After applying these steps, the module should install and work normally on PrestaShop 8.1.x.