dostoyevski Posted December 1, 2022 Share Posted December 1, 2022 hello there! I have this hook where it connects to a database. When the connection is successful it works fine. But when the connection fails it does not let me enter the main page. How can I make prestashop continue even if there is an error in the connection to the database? public function hookHeader() { $this->context->controller->addJS($this->_path . '/views/js/front.js'); $this->context->controller->addCSS($this->_path . '/views/css/front.css'); $database = Configuration::get('MIMODULOMISMADB_ACCOUNT_NOMBREDB', null); $user = Configuration::get('MIMODULOMISMADB_ACCOUNT_USUARIO', null); $password = Configuration::get('MIMODULOMISMADB_ACCOUNT_PASSWORD', null); try { $db = new DbMySQLi("localhost", $user, $password, $database, true); } catch (PrestaShopWebserviceException $ex) { mail("[email protected]", "conexion fallida", "hola"); echo 'Other error : <br />' . $ex->getMessage(); } } Link to comment Share on other sites More sharing options...
dostoyevski Posted December 2, 2022 Author Share Posted December 2, 2022 I have replaced the catch with this line: catch (PrestaShopException $ex) and now the page loads but the add to cart buttons do not work Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now