Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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;
Expand Down