diff --git a/productcomments.php b/productcomments.php index fb9ee754..e836f8f9 100644 --- a/productcomments.php +++ b/productcomments.php @@ -28,13 +28,16 @@ exit; } +include_once dirname(__FILE__) . '/ProductComment.php'; +include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; + use PrestaShop\Module\ProductComment\Repository\ProductCommentCriterionRepository; use PrestaShop\Module\ProductComment\Repository\ProductCommentRepository; use PrestaShop\PrestaShop\Core\Module\WidgetInterface; class ProductComments extends Module implements WidgetInterface { - const INSTALL_SQL_FILE = 'install.sql'; + public const INSTALL_SQL_FILE = 'install.sql'; private $_html = ''; @@ -271,9 +274,6 @@ protected function _postProcess() public function getContent() { - include_once dirname(__FILE__) . '/ProductComment.php'; - include_once dirname(__FILE__) . '/ProductCommentCriterion.php'; - $this->_html = ''; if (Tools::isSubmit('updateproductcommentscriterion')) { $this->_html .= $this->renderCriterionForm((int) Tools::getValue('id_product_comment_criterion')); @@ -940,11 +940,13 @@ public function hookFilterProductContent(array $params) $averageRating = $productCommentRepository->getAverageGrade($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE')); $nbComments = $productCommentRepository->getCommentsNumber($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE')); + $comments = ProductComment::getByProduct($params['object']->id); /* @phpstan-ignore-next-line */ $params['object']->productComments = [ 'averageRating' => $averageRating, 'nbComments' => $nbComments, + 'comments' => $comments ]; return $params;