magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.51k stars 9.31k forks source link

Review summary block is not rendered in product page or product listing #26613

Closed elmahone closed 6 months ago

elmahone commented 4 years ago

Preconditions (*)

  1. Magento 2.3.3
  2. An environment with multiple MySQL instances (3 in this case)

Steps to reproduce (*)

  1. Create a product that can be seen in a product list
  2. Enable reviews
  3. Add a review to the product

Expected result (*)

  1. Review summary block should display in the product cards and product page with the correct amount of stars

Actual result (*)

  1. Review summary block is not displayed at all

Details

The root of the problem is in the function \Magento\Review\Model\ReviewSummary::appendSummaryDataToObject Where the $entityType is set to 1 by default. In environments with multiple MySQL instances the autoincremental IDs are increased in intervals of 3. So we can't count on the product entity ID being 1, it might be 2 or 3. We fixed this issue by patching function \Magento\Review\Block\Product\ReviewRenderer::getReviewsSummaryHtml to fetch the product entity ID, instead of using the default 1

magento-deployment-service[bot] commented 4 years ago

Thanks for opening this issue!

m2-assistant[bot] commented 4 years ago

Hi @elmahone. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@elmahone do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


GovindaSharma commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

Hi @GovindaSharma. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team commented 4 years ago

Hi @GovindaSharma, here is your Magento instance. Admin access: https://i-26613-2-4-develop.instances.magento-community.engineering/admin_bf44 Login: 151cb6ea Password: 8effc726b013 Instance will be terminated in up to 3 hours.

m2-assistant[bot] commented 4 years ago

Hi @engcom-Echo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Echo Thank you for verifying the issue. Based on the provided information internal tickets MC-31181 were created

Issue Available: @engcom-Echo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

sdzhepa commented 4 years ago

Hello @elmahone @Bartlomiejsz and @engcom-Echo

Could you please provide more details and exact configuration for

An environment with multiple MySQL instances (3 in this case)

With the current description it is not clear is it master/slave or split-db or some other configuration type. Without this information, we are not able to triage and prioritize. accept and test it after.

Thank you in advance!

Bartlomiejsz commented 4 years ago

Hi @sdzhepa, not sure about exact way to simulate approach mentioned in ticket, but you can simulate error itself by manually changing entity_id in review_entity table for product. Error is caused by hardcoded value of identifier - 1 - in code, while it also exists in database table.

agorbulin commented 4 years ago

Reproduced on 2.3.5-p1

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

dverkade commented 3 years ago

Posting a comment. Issues should not be automatically closed.

artttj commented 3 years ago

We faced the same issue in the Magento Cloud production environment.

We have database slave and entity_id's there are different in review_entity table as @elmahone mentioned.

The patch for \Magento\Review\Block\Product\ReviewRenderer::getReviewsSummaryHtml() solves the problem.

Bartlomiejsz commented 3 years ago

@dverkade @artttj actually this issue should already be fixed in mainline. Despite of my PR pretty similar changes were pushed to core in https://github.com/magento/magento2/commit/fb2f1a74ad2a9442c4c6ca39b85b42050a9f387b so this ticket should be closed in my opinion CC @magento-engcom-team

artttj commented 3 years ago

@Bartlomiejsz ,

Thanks for the info.

zenfork commented 3 years ago

Reproduced on Magento 2.4.0 CE (Cloud). Please, consider this query as a hotfix:

SET FOREIGN_KEY_CHECKS = 0;

UPDATE
    review AS R,
    review_entity_summary AS RES,
    review_entity AS RE
SET
    R.entity_id = 1,
    RE.entity_id = 1,
    RES.entity_type = 1
WHERE
    RE.entity_code = 'product' AND (
        R.entity_id = RE.entity_id OR RES.entity_type = RE.entity_id
    );

SET FOREIGN_KEY_CHECKS = 1; 
engcom-Bravo commented 6 months ago

Hi @elmahone,

As per this https://github.com/magento/magento2/issues/26613#issuecomment-828800606 We are closing this issue.since the issue has been fixed.

Thanks.