Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getReviewRatingMatrix example
$data
->
setReviews
(
$this
->
loadProductReviews
(
$product
,
$request
,
$resolverContext
->
getSalesChannelContext
(
)
)
)
;
}
}
private
function
loadProductReviews
(
SalesChannelProductEntity
$product
, Request
$request
, SalesChannelContext
$context
)
: ProductReviewResult
{
$reviewCriteria
=
$this
->
createReviewCriteria
(
$request
,
$context
)
;
$reviews
=
$this
->productReviewRoute
->
load
(
$product
->
getParentId
(
)
??
$product
->
getId
(
)
,
$request
,
$context
,
$reviewCriteria
)
->
getResult
(
)
;
$matrix
=
$this
->
getReviewRatingMatrix
(
$reviews
)
;
$reviewResult
= ProductReviewResult::
createFrom
(
$reviews
)
;
$reviewResult
->
setMatrix
(
$matrix
)
;
$reviewResult
->
setProductId
(
$product
->
getId
(
)
)
;
$reviewResult
->
setCustomerReview
(
$this
->
getCustomerReview
(
$product
->
getId
(
)
,
$context
)
)
;
$reviewResult
->
setTotalReviews
(
$matrix
->
getTotalReviewCount
(
)
)
;
$reviewResult
->
setProductId
(
$product
->
getId
(
)
)
;
$reviewResult
->
setParentId
(
$product
->
getParentId
(
)
??
$product
->
getId
(
)
)
;
return
$reviewResult
;
}