Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose comments for theme #140

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 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
3 changes: 3 additions & 0 deletions productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ public function hookDisplayFooterProduct($params)
*/
public function hookFilterProductContent(array $params)
{
require_once dirname(__FILE__) . '/ProductComment.php';
rodriciru marked this conversation as resolved.
Show resolved Hide resolved
if (empty($params['object']->id)) {
return;
}
Expand All @@ -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
];
}

Expand Down