Fix review snippet: emit review author as a schema.org/Person object#41009
Open
TuVanDev wants to merge 2 commits into
Open
Fix review snippet: emit review author as a schema.org/Person object#41009TuVanDev wants to merge 2 commits into
TuVanDev wants to merge 2 commits into
Conversation
|
Hi @TuVanDev. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aschema.org/Reviewitem:<strong class="review-details-value" itemprop="author"> <?= $escaper->escapeHtml($_review->getNickname()) ?> </strong>Per schema.org and Google's Review structured-data documentation, a
Review'sauthormust be aPersonorOrganizationobject — 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: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
authorunder Required properties asPersonorOrganization, and its recommended Microdata/RDFa example nests the name inside the author object:This PR wraps the nickname as a
schema.org/Personwith a nesteditemprop="name", soauthoris a valid object type:The
http://schema.org/Personscheme matches theitemtypescheme already used by the surroundingReviewandRatingitems in the same template (Google accepts bothhttpandhttps). The nickname continues to flow through$escaper->escapeHtml(...); the only added markup is a static<span>. The nesteditemprop="name"binds to thePersonscope, distinct from theReview's own titleitemprop="name"a few lines above, which stays in theReviewscope.This is the only frontend template in
Magento_Reviewthat emitsitemprop="author";view.phtml,customer/recent.phtml,customer/list.phtml, andproduct/view/other.phtmldo 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 (*)
catalog/review/active = 1), open a product that has at least one approved review.authoris 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 aPerson.authoris aPersonobject —<strong itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Jane</span></strong>. The validator recognizesauthor→Person→name, and the "Invalid object type for field author" issue is resolved.itemprop="name"on.review-title), rating,datePublished, anddescriptionmicrodata 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.phtmltemplates 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 (httpvshttps) to match maintainer preference.Contribution checklist (*)
.phtmlchange; no automated test surface for template microdata (verified via Rich Results Test / Schema Markup Validator)