From 97979aaca806074e54ed2dfd374465eaa327cc81 Mon Sep 17 00:00:00 2001 From: rodriciru Date: Thu, 9 Jun 2022 17:00:40 +0200 Subject: [PATCH 1/3] begin able to expose comments for use in theme --- productcomments.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/productcomments.php b/productcomments.php index b3069ee0..fcc891cc 100644 --- a/productcomments.php +++ b/productcomments.php @@ -927,8 +927,9 @@ public function hookDisplayFooterProduct($params) * * @return void */ - public function hookFilterProductContent(array $params) + public function hookFilterProductContent(array $params) { + require_once dirname(__FILE__) . '/ProductComment.php'; if (empty($params['object']->id)) { return; } @@ -937,11 +938,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 ]; } From f2d3a88d4161dbf51da90bd5d2abb5c6687b9120 Mon Sep 17 00:00:00 2001 From: rodriciru Date: Thu, 9 Jun 2022 17:02:12 +0200 Subject: [PATCH 2/3] Remove space --- productcomments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/productcomments.php b/productcomments.php index fcc891cc..14e5c540 100644 --- a/productcomments.php +++ b/productcomments.php @@ -927,7 +927,7 @@ public function hookDisplayFooterProduct($params) * * @return void */ - public function hookFilterProductContent(array $params) + public function hookFilterProductContent(array $params) { require_once dirname(__FILE__) . '/ProductComment.php'; if (empty($params['object']->id)) { From 7f3aef8d97fa0076a9883a9101295ee43eec6675 Mon Sep 17 00:00:00 2001 From: rodriciru Date: Wed, 29 Mar 2023 15:07:43 +0000 Subject: [PATCH 3/3] Make ProductComment and ProductCommentCriterion class available for all --- productcomments.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/productcomments.php b/productcomments.php index 2fdc1798..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')); @@ -932,7 +932,6 @@ public function hookDisplayFooterProduct($params) */ public function hookFilterProductContent(array $params) { - require_once dirname(__FILE__) . '/ProductComment.php'; if (empty($params['object']->id)) { return $params; }