Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProductReviewsLoadedEvent example
throw
RoutingException::
missingRequestParameter
(
'productId'
)
;
}
$criteria
=
$this
->
createCriteria
(
$request
,
$context
)
;
$reviews
=
$this
->route
->
load
(
$productId
,
$request
,
$context
,
$criteria
)
->
getResult
(
)
;
$reviews
= StorefrontSearchResult::
createFrom
(
$reviews
)
;
$this
->eventDispatcher->
dispatch
(
new
ProductReviewsLoadedEvent
(
$reviews
,
$context
,
$request
)
)
;
$reviewResult
= ReviewLoaderResult::
createFrom
(
$reviews
)
;
$reviewResult
->
setProductId
(
$request
->
get
(
'productId'
)
)
;
$reviewResult
->
setParentId
(
$request
->
get
(
'parentId'
)
)
;
$aggregation
=
$reviews
->
getAggregations
(
)
->
get
(
'ratingMatrix'
)
;
$matrix
=
new
RatingMatrix
(
[
]
)
;
if
(
$aggregation
instanceof TermsResult
)
{
$matrix
=
new
RatingMatrix
(
$aggregation
->
getBuckets
(
)
)
;
}