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
$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);
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, it will be equal to
ps_. We didn't use it for the
insert method since the
update methods automatically add the prefix.
Then retrieve the configuration values and assign all these variables to Smarty. You should end up with something...