Reputation: 3
I find in internet a CRUD module (create, read, update, delete) and it works very well in backoffice of Prestashop 1.7.7.6
And now I want to select data from module table and display in front office prestashop product page tpl file
How can i do ?
please help me
Thanks You very much in advance
structure of crud module moduletest :
- Classes / Moduletesttabletest.php
- Controllers / Admin / Adminmoduletest.php
- moduletest.php
Display Data from database table of module to Prestashop Product Page - Prestashop 1.7.7.6
Upvotes: 0
Views: 1217
Reputation: 71
You need to select hook there data will be displayed
Than add this hook to your moduletest.php file in two places.
For example to show data on product page near price block you can use hook ProductPriceBlock
There is public function install() in yor module. It will register hook, so prestashop knows that it`s function need to be called
public function install()
{ ....
$this->registerHook('header') &&
$this->registerHook('backOfficeHeader') &&
++$this->registerHook('displayProductPriceBlock');
}
At the end of file before closing code block "}" add code to retrive and display data to according function:
public function hookdisplayProductPriceBlock($params) { // your code goes here }
Reset module in modules Modules manager - this will actualy register hook after you make changes to source code
To use template you need according tpl file in /views/templates/front/ subdirectory of module and call it by
$this->display(__FILE__, 'my-template.tpl');
Upvotes: 1