PrestaShark Posted July 12, 2016 Share Posted July 12, 2016 I have quite simple Prestashop module that i want to rework to use own database table with separate language etc. Previously this module was writen without multilingual function with simple ps_configuration table use. public function hookDisplayFooter($params) { $value = Configuration::get('MYMODULE_SETTINGS'); and now i have public function hookDisplayFooter($params) { $value = Tools::getValue('mymodule_settings'); Everything works good but i can't get the mymodle_settings values in this function anymore. This my input array. array( 'type' => 'text', 'label' => $this->l('Settings'), 'desc' => $this->l('My module settings.'), 'name' => 'mymodule_settings', 'lang' => true, 'size' => 64, ), This is my database table `mymodule_settings` varchar(255) NOT NULL, The mymodule_settings values are correctly placed in database and i see them in module BO, and the question is how to get them to $value = in function hookDisplayFooter 1 Link to comment Share on other sites More sharing options...
vekia Posted July 12, 2016 Share Posted July 12, 2016 tools::getValue returns value stored in $_POST / $_GET variable it does not return the database entries. if your module has got own table in db you have to use Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(''); function 1 Link to comment Share on other sites More sharing options...
coeos.pro Posted July 12, 2016 Share Posted July 12, 2016 this can help you : https://www.prestashop.com/blog/en/best-practices-class-db-prestashop-1-5/ 1 Link to comment Share on other sites More sharing options...
PrestaShark Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) Thanks Vekia for clue So in this case this should looks like this? public function hookDisplayFooter($params) { $sql = 'SELECT mymodule_settings FROM '._DB_PREFIX_.'mymodule'; $value = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); It works. But is this a good attempt and "Best Practices" to make it? PS. coeos.pro yes! I found this too -> 7. The getRow($sql, $use_cache = 1) method was the hint Edited July 12, 2016 by PrestaShark (see edit history) 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