Skip to content

Fix review snippet: emit review author as a schema.org/Person object#41009

Open
TuVanDev wants to merge 2 commits into
magento:2.4-developfrom
TuVanDev:fix-review-snippet-author-schema-person
Open

Fix review snippet: emit review author as a schema.org/Person object#41009
TuVanDev wants to merge 2 commits into
magento:2.4-developfrom
TuVanDev:fix-review-snippet-author-schema-person

Conversation

@TuVanDev

Copy link
Copy Markdown
Member

Description (*)

On the product page, the customer reviews list renders each review's author as itemprop="author" placed directly on an element whose content is a plain text string (the reviewer nickname), inside a schema.org/Review item:

<strong class="review-details-value" itemprop="author">
    <?= $escaper->escapeHtml($_review->getNickname()) ?>
</strong>

Per schema.org and Google's Review structured-data documentation, a Review's author must be a Person or Organization object — not a bare string. Because the markup provides text where an object type is expected, Google Search Console reports the non-critical Review snippets issue:

Invalid object type for field "author"

Items with this issue remain valid but are not eligible for an author-based review snippet, and Google notes such issues "could be reclassified as critical in the future."

Google's own Review snippet documentation lists author under Required properties as Person or Organization, and its recommended Microdata/RDFa example nests the name inside the author object:

<span property="author" typeof="Person">
    <span property="name">Bob Smith</span>
</span>

This PR wraps the nickname as a schema.org/Person with a nested itemprop="name", so author is a valid object type:

<strong class="review-details-value" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name"><?= $escaper->escapeHtml($_review->getNickname()) ?></span>
</strong>

The http://schema.org/Person scheme matches the itemtype scheme already used by the surrounding Review and Rating items in the same template (Google accepts both http and https). The nickname continues to flow through $escaper->escapeHtml(...); the only added markup is a static <span>. The nested itemprop="name" binds to the Person scope, distinct from the Review's own title itemprop="name" a few lines above, which stays in the Review scope.

This is the only frontend template in Magento_Review that emits itemprop="author"; view.phtml, customer/recent.phtml, customer/list.phtml, and product/view/other.phtml do not, so no other template is affected.

Related Pull Requests

None.

Fixed Issues (if relevant)

N/A — reproducible on 2.4-develop (see manual testing below).

Manual testing scenarios (*)

  1. On a store with reviews enabled (catalog/review/active = 1), open a product that has at least one approved review.
  2. Inspect the rendered review in the customer reviews list, or run the page through the Rich Results Test / Schema Markup Validator.
    • Before: the review's author is plain text — <strong itemprop="author">Jane</strong>. Google Search Console reports "Invalid object type for field author" for the Review snippet, and the author is not recognized as a Person.
    • After: the review's author is a Person object — <strong itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Jane</span></strong>. The validator recognizes authorPersonname, and the "Invalid object type for field author" issue is resolved.
  3. Regression — the review title (itemprop="name" on .review-title), rating, datePublished, and description microdata are unchanged; the reviewer name still renders identically on screen (same <strong class="review-details-value"> element and text).

Questions or comments

This is a template markup fix (.phtml) only; there is no behavioral/PHP change, so no unit or integration test is added — core .phtml templates are not covered by the automated test harness for microdata output, and the change is verifiable via Google's Rich Results Test / Schema Markup Validator (see manual testing). Happy to adjust the wrapping element or scheme (http vs https) to match maintainer preference.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests — N/A: markup-only .phtml change; no automated test surface for template microdata (verified via Rich Results Test / Schema Markup Validator)
  • All automated tests passed successfully (no code paths changed)

@m2-assistant

m2-assistant Bot commented Jul 19, 2026

Copy link
Copy Markdown

Hi @TuVanDev. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

The opening <strong> tag with schema.org/Person attributes exceeded 120
characters (Magento coding standard limit). Split attributes across
multiple lines to comply with line length requirements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant