0

I am using Magento 2.1.7 version. The customer is able to write a review from product detail page, and review is approved by admin. But Customer reviews is not showing in product detail page. This block is showing empty <div id="product-review-container" data-role="product-review"></div> and getting this error in console

http://xxx/review/product/listAjax/id/200/ 500 (Internal Server Error)

When I hit this Link in the browser then getting this error - Item (Magento\Review\Model\Review\Interceptor) with the same ID "4" already exists.

1 Answer 1

0

Seems your collection is loading multiple items which has more than 1 row with ID 4.

So use add group by clause to your collection primary key. For eg: $collection->getSelect()->group('main_table.review_id');

So this will skip loading duplicate entries.

Collection may have been loading same entries because of wrong join or joined table may have same column name with same value is being loaded. So please check you query try printing it and execute in phpmyadmin check if same ID exits. And you may need to add group by as well.

4
  • Thanks for your reply.But there is no duplicate entries Aug 21, 2018 at 12:51
  • No no, not duplicate entries. Collection may have been loading same entries because of wrong join or joined table may have same column name with same value is being loaded. So please check you query. And you may need to add group by as well
    – Kumar M
    Aug 21, 2018 at 12:54
  • Actually we are using magento core functionality so why this problem is comming Aug 21, 2018 at 14:10
  • is any one there who face same problem ? Aug 22, 2018 at 15:08

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.