v8x-v9x Google My Business: Customer Reviews & Ratings (Prestashop) 9.0.2

GALOMEN

Member
XNullUser
Joined
Nov 20, 2021
Messages
133
Reaction score
1
Points
18
NullCash
63
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​

  1. Download and extract the module ZIP file.
  2. Open the main module file (for example: module_name.php).
  3. Find the line:
$this->ps_versions_compliancy = ['min' => '9.0', 'max' => '9.9.99'];

  1. Replace it with:
$this->ps_versions_compliancy = ['min' => '8.0.0', 'max' => '9.9.99'];

  1. 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.

  1. Open the same module file (module_name.php).
  2. Scroll to the end of the class.
  3. Locate the final closing brace:
}

  1. 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​

  1. Re-zip the module folder.
  2. The ZIP root must contain the module directory itself (not nested folders).
  3. 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.
 
Top