Question

Currently, reviews for each product only display assigned to one product. https://prnt.sc/rhmt1q

Any solution to display all opinions in this tab from the website and add above each opinion the name of the product to which the opinion relates?

We sell clothing, so the products change dynamically and are not likely to return the same models. That is why we want to display all opinions from the website.

Was it helpful?

Solution

Please override the file:

Magento/vendor/magento/module-review/Block/Product/View.php

Find:

public function getReviewsCollection()
{
    if (null === $this->_reviewsCollection) {
        $this->_reviewsCollection = $this->_reviewsColFactory->create()->addStoreFilter(
            $this->_storeManager->getStore()->getId()
        )->addStatusFilter(
            \Magento\Review\Model\Review::STATUS_APPROVED
        )->addEntityFilter(
            'product',
            $this->getProduct()->getId()
        )->setDateOrder();
    }
    return $this->_reviewsCollection;
}

and replace it with:

public function getReviewsCollection()
{
    if (null === $this->_reviewsCollection) {
        $this->_reviewsCollection = $this->_reviewsColFactory->create()->addStoreFilter(
            $this->_storeManager->getStore()->getId()
        )->addStatusFilter(
            \Magento\Review\Model\Review::STATUS_APPROVED
        )->setDateOrder();
    }
    return $this->_reviewsCollection;
}

you can see that I removed addEntityFilter for productId which is use for the validation.

Let me know if you need any further help

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top