Displaying comments

The last step will be to display comments filled in by customers on the front office, and we will also use the configuration values we created in the previous chapter. Let's begin by creating a method named assignProductTabContent, where we will retrieve the concerned id_product parameter (which is in the GET value):

$id_product = Tools::getValue('id_product');

Then make the SQL request to retrieve all comments concerning the products of the page you are on:

$comments = Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'mymod_comment WHERE id_product = '.(int)$id_product);

Note

You should have noticed that I used the _DB_PREFIX_ constant, which corresponds to the prefix you chose when you installed your shop. In most cases, ...

Get PrestaShop Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.