Microdata is essential for any website as it helps search engines to understand the site’s content and display it in a relevant way. For example, you can add specific tags to block that display prices to tell Google bots that this page contains price information. After that, Google will show this information in searches. Today I’ll show you how to add Microdata to Magento product pages.
There are two ways to add microdata to Magento product pages:
- Install and enable a 3rd-party app;
- Add microdata manually if 3rd-party apps don’t provide you with the needed functionality.
Adding Microdata to Magento | Adobe Commerce Product Pages Manually
First of all, you need to wrap up a product in the new tag _ itemscope itemtype=”http://schema.org/Product”_.
Open file [your_theme] /template/catalog/product/view.phtml
Then, specify the name of the product by adding itemprop=”name”
Use the tag itemprop=”description” for the product description.
Open [your_theme] /template/catalog/product/view/media.phtml
and add the tag itemprop=”image” to add image attribute.
Microdata reviews work only if there is at least one review.
The path to the template is [your_theme] /template/review/helper/summary.phtml
The tag is itemprop=”aggregateRating” itemscope itemtype=”http://schema.org/AggregateRating”
If you want to help Googlebots to find the best and the worst ratings, the number of reviews, aggregate rating, add several hidden rows:
<span class=”no-display” itemprop=”reviewCount”>
<span class=”no-display” itemprop=”worstRating”>0</span>
<span class=”no-display” itemprop=”bestRating”>5</span>
<span class=”no-display” itemprop=”ratingValue”>
If you want to add price and availability microdata attributes, you need to insert a specific code into the template [your_theme] /template/catalog/product/view.phtml
The code to insert:
<?php if($_product->isAvailable()): ?>
<div class="no-display" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<span itemprop="price"><?php echo Mage::helper('core')->currency($_product->getFinalPrice()); ?></span>
<link itemprop="availability" href="http://schema.org/InStock" />
</div>
<?php endif; ?>
You need to insert these code lines after:
<div class="product-name">
<h1 itemprop="name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
</div>
See the screenshot:
This code checks the availability of in-stock products. If a product is in stock, the code adds its price and availability to microdata.
When you add microdata, validate it via the Google Structured Data testing tool.
Mobecls team provides basic and advanced SEO audits, SEO and performance optimization services. We are SEO-focused development company that specializes in Magento | Adobe Commerce. It means that we know what and how to fix SEO issues, taking into account your UX, Marketing and Business specifics.
Top Extensions for Adding Microdata to Magento | Adobe Commerce Product Pages
Today you can find numerous extensions for Magento stores that boost SEO, improve usability, and attract more customers by adding Rich Snippets (structured data) for Google Search and social media.
Magento 2 Rich Snippets (Schema.org Structured Data) Extension by WeltPixel
Magento 2 Rich Snippets allows adding microdata not only for Google Search but also for Facebook Open Graph, Twitter Cards, and Pinterest Rich Pins.
Microdata:
- Product Name
- Product Image
- Price
- Availability
- Description (short/long)
- Brand (Country of manufacture, Shipping, etc..)
- SKU
- Reviews (Aggregate Ratings/Aggregate Ratings with Detailed Reviews)
Microdata on Facebook, Twitter, Pinterest:
- Twitter Cards — highlight your products on Twitter using images, videos, short/long descriptions, prices, and drive customers to your online store.
- Facebook Open Graph — showcase your products on Facebook Feed using images, long/short descriptions, prices, and highlight your website or app.
- Pinterest Rich Pins — add rich product information to your products on Pinterest.
Magento 2 SEO Extension by Mageplaza
Magento 2 SEO Extension provides a vast set of features for boosting your SEO without code modifications. Besides adding Microdata, it includes:
- Resolution to duplicate content issue
- Advanced HTML/XML sitemaps
- SEO reports
- Cross-links
- Hreflang tag configuration
- SEO Metadata template rules
- Page analysis
Magento 2 SEO extension automatically adds Rich Snippets (Microdata) to the site’s product pages. It enriches the search results with Rating, Review, Price, and Stock status. This extension will help your online store to climb higher positions on Google.