Jump to content

[SOLVED] how to access module function from all presta context


lsantos2015

Recommended Posts

Hello.

 

I had build a module, where I have 2 functions that i need to access from other parts of Prestashop. The module is on front, but i need to access those 2 functions from all parts, including backoffice..

 

Where should I put those functions to be able to call them from anywhere ?

 

Just one more detail about DB access.. 

 

I added a new .php file, to check some info, how can I use the connection from Prestashop to make a SQL Query and echo a value to a variable ?

 

Regards

Luis

Link to comment
Share on other sites

in this case, if you want to run these functions both from back and front office, moreover, also from other modules and controllers you have to create an override of controllers, unfortunately. the best thing, two files: /classes/controller/AdminController.php and /classes/controller/FrontController.php

  • Like 1
Link to comment
Share on other sites

Hello..

 

Tarek.Fellah.. didn't got much help with connection or use of DB classes/functions..

 

Vekia..

Thanks for the reply.

 

What i did is, with a java file, I have a live function that when you are entering text on a textfield, it checks live if a user is available or not, and for that I have a new check.php file, that is extra from prestashop engine.. and here, I don't know how to call any prestashop function, regarding DB, as nothing seems to work..

 

how can I call on a new extra .php file, the prestashop DB core functions ?

 

example: 

 

<?php

$var = $_POST['java_var'];

$query = "SELECT * FROM "._DB_PREFIX_."table WHERE field = '$var'";
$result= Db::getInstance()->ExecuteS($query);
while($row = mysql_fetch_array($result)) { 
   $data=$row['field'];
}
 
this does not work.. how can I make this work ?
 
Thanks for the help in advance..
Regards
Luis
Edited by lsantos2015 (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...