From a3bd7022a67e8b91b789bcbc8c0e922a2d09b058 Mon Sep 17 00:00:00 2001 From: Jin JI Date: Wed, 4 Sep 2024 10:15:19 +0200 Subject: [PATCH] feat: install ps_account on dashboard hook --- src/Traits/Hooks/UseDashboardZoneOne.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Traits/Hooks/UseDashboardZoneOne.php b/src/Traits/Hooks/UseDashboardZoneOne.php index 480a968ed..95bf126e2 100755 --- a/src/Traits/Hooks/UseDashboardZoneOne.php +++ b/src/Traits/Hooks/UseDashboardZoneOne.php @@ -95,7 +95,17 @@ protected function loadPsAccounts(): string $accountsService = $accountsFacade->getPsAccountsService(); if ($this->ensurePsAccountIsEnabled()) $this->get('mbo.ps_eventbus.installer')->install(); } catch (\PrestaShop\PsAccountsInstaller\Installer\Exception\InstallerException $e) { - ErrorHelper::reportError($e); + $accountsInstaller = $this->get('mbo.ps_accounts.installer'); + // Seems the module is not here, try to install it + $accountsInstaller->install(); + $accountsFacade = $this->get('mbo.ps_accounts.facade'); + try { + $accountsService = $accountsFacade->getPsAccountsService(); + } catch (\Exception $e) { + // Installation seems to not work properly + $accountsService = $accountsFacade = null; + ErrorHelper::reportError($e); + } } if (null !== $accountsFacade && null !== $accountsService) {