0

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.

1
  • You mean every product's review will display in that tab? Commented Mar 17, 2020 at 9:32

1 Answer 1

1

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

3
  • Thank you. Work perfect. I accept your answear. Last case. Is any solution how to get product name assigned to a given review? prnt.sc/rhodfq because each review relates to different products and I would like to display the product name with a link to product redirection like here: prnt.sc/rhoeu0
    – Sylvester
    Commented Mar 17, 2020 at 10:03
  • @Sylvester ask a new question for it, so anyone can help Commented Mar 17, 2020 at 10:04
  • magento.stackexchange.com/questions/307261/…
    – Sylvester
    Commented Mar 17, 2020 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.