cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix error in Magento: Either "offers", "review", or "aggregateRating" should be specified

How to fix error in Magento: Either "offers", "review", or "aggregateRating" should be specified

1 REPLY 1

Re: How to fix error in Magento: Either "offers", "review", or "aggregateRa

Hello @juanforce4ef18 

 

The error means that your product structured data markup is missing the offers, review, or aggregateRating properties, which are recommended by Google for better search result presentation.

 

Review Your Theme's Templates:

Magento themes typically include structured data in the product templates. You need to ensure that the structured data markup includes the necessary properties.

 

Locate the product template file: catalog_product_view.xml, and check for the inclusion of structured data. This file is usually found in app/design/frontend/[Vendor]/[Theme]/Magento_Catalog/templates/product/view.phtml.

 

Edit Structured Data in view.phtml:

Open the view.phtml file and check for the JSON-LD structured data script. If it's missing, you need to add it. Here's an example of how to include the offers, review, and aggregateRating properties:

<script type="application/ld+json">

{

  "@context": "http://schema.org",

  "@type": "Product",

  "name": "<?php echo $block->escapeHtml($block->getProduct()->getName()); ?>",

  "image": "<?php echo $block->escapeUrl($block->getProduct()->getImageUrl()); ?>",

  "description": "<?php echo $block->escapeHtml($block->getProduct()->getDescription()); ?>",

  "sku": "<?php echo $block->escapeHtml($block->getProduct()->getSku()); ?>",

  "offers": {

    "@type": "Offer",

    "priceCurrency": "<?php echo $block->escapeHtml($block->getCurrentCurrencyCode()); ?>",

    "price": "<?php echo $block->escapeHtml($block->getProduct()->getFinalPrice()); ?>",

    "itemCondition": "http://schema.org/NewCondition",

    "availability": "http://schema.org/<?php echo $block->escapeHtml($block->getProduct()->isAvailable() ? 'InStock' : 'OutOfStock'); ?>",

    "seller": {

      "@type": "Organization",

      "name": "Your Store Name"

    }

  },

  "aggregateRating": {

    "@type": "AggregateRating",

    "ratingValue": "<?php echo $block->escapeHtml($block->getProduct()->getRatingSummary()->getRatingSummary() / 20); ?>",

    "reviewCount": "<?php echo $block->escapeHtml($block->getProduct()->getRatingSummary()->getReviewsCount()); ?>"

  },

  "review": [

    <?php foreach ($block->getProduct()->getReviewsCollection() as $review): ?>

    {

      "@type": "Review",

      "author": "<?php echo $block->escapeHtml($review->getNickname()); ?>",

      "datePublished": "<?php echo $block->escapeHtml($review->getCreatedAt()); ?>",

      "description": "<?php echo $block->escapeHtml($review->getDetail()); ?>",

      "name": "<?php echo $block->escapeHtml($review->getTitle()); ?>",

      "reviewRating": {

        "@type": "Rating",

        "ratingValue": "<?php echo $block->escapeHtml($review->getRatingValue()); ?>"

      }

    }

    <?php endforeach; ?>

  ]

}

</script>

 

Add Missing Data:

Ensure your products have prices, reviews, and ratings available. The script above will generate the necessary structured data if the product information is available.

 

Test Structured Data:

Use Google’s Rich Results Test tool to test your product pages and ensure that the structured data is correctly implemented.

 

Deploy and Verify:

bin/magento setup:static-content:deploy

bin/magento cache:clean

 

Hope it helps !

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9