Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion controllers/front/CommentGrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function display()

$idProducts = array_unique(array_map('intval', $idProducts));

/** @var ProductCommentRepository $commentRepository */
/** @var ProductCommentRepository|null $commentRepository */
$commentRepository = $this->context->controller->getContainer()->get('product_comment_repository');

if (!$commentRepository instanceof ProductCommentRepository) {
Expand Down
8 changes: 6 additions & 2 deletions productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use PrestaShop\Module\ProductComment\Form\ProductCommentCriterionFormDataProvider;
use PrestaShop\Module\ProductComment\Repository\ProductCommentCriterionRepository;
use PrestaShop\Module\ProductComment\Repository\ProductCommentRepository;
use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray;
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;

class ProductComments extends Module implements WidgetInterface
Expand Down Expand Up @@ -929,7 +930,7 @@ public function hookDisplayFooterProduct($params)
/**
* Inject data about productcomments in the product object for frontoffice. This is the older way of adding the data before PrestaShop 9.2.
*
* @param array $params
* @param array{object: ProductLazyArray} $params
*
* @return array
*/
Expand All @@ -943,7 +944,10 @@ public function hookFilterProductContent(array $params)
$averageRating = $commentRepository->getAverageGrade($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE'));
$nbComments = $commentRepository->getCommentsNumber($params['object']->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE'));

/* @phpstan-ignore-next-line */
/*
* @phpstan-ignore-next-line
* Needs #[AllowDynamicProperties] on ProductLazyArray class to avoid error in PHP 8.2+
*/
$params['object']->productComments = [
'averageRating' => $averageRating,
'nbComments' => $nbComments,
Expand Down
Loading