Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
Magento 2 is one of the most flexible and customizable eCommerce platforms out there, which is one of the reasons we love working with it. It comes packed with tons of features, but like any platform, it has its issues. One of the more frustrating ones is the default schema markup for products.
As of the latest version, Magento 2.4.7, the default product schema implementation is out right bad. It doesn’t pass all the required details to be eligible for rich widgets on the Google search results, such as the Merchant Listing or Product Card. Additionally, the schema is still in microdata format, whereas the modern JSON-LD format is preferred.
Key Issues with Magento's Default Product Schema:
- Missing Image Data: Magento’s default schema doesn’t include the product image, which makes your product listings ineligible for merchant listing or simpler terms organic product cards result on Google will not show your site.
- Missing Description: The product description is a recommended property that’s missing from the default schema.
- Stock Status: Information about whether a product is in stock or not is also missing, affecting eligibility for rich search results.
Proper schema implementation is essential for improved organic search performance. While schema markup itself doesn’t directly boost SEO rankings, the additional context it provides enhances how your product is displayed in search results. This extra visibility increases your click-through rates (CTRs), which indirectly improves page authority and SEO rankings.
In this post, we’ll walk through how to fix these schema issues in Magento by creating a custom module, we will not change the entire schema, but only override the
Step 1: Custom Module Structure
To make the required changes without them being overwritten by future updates, we’ll create a custom module. Here’s the basic structure:
Step 2: Layout Configuration
Default.xml
This layout file is used to override the default template that renders product information. We will use it to override the schema to add the missing information.
This block points Magento to our custom product view template (`form.phtml`), where we’ll handle the schema markup for the product information.
Step 3: Schema Markup Implementation
In the form.phtml template, we override the structured data to include missing product elements like the image and description. This step resolves the critical schema issues, making your products eligible for merchant listings and organic product cards on Google.
Adding Availability (optional)
While this isn’t essential part, we will basically we’ll override the price rendering to include the offer and stock availability details.
Catalog_product_prices.xml
Creating the default layout file to override the default pricing. This code customizes the price rendering, ensuring that Magento correctly uses our custom template for price amounts (`default.phtml`) to display the price information and include it in the schema.
default.phtml
Final Step: Deploy and Test Your Changes
After implementing the custom module, deploy the changes to your Magento store by running the following commands:
Once the deployment is complete, test your product schema markup using Google’s Rich Results Testing Tool. Enter the URL of a product page, test a simple and config product, and ensure everything is correctly recognized.
Would you like to share this article?
need assisting with Magento 2 customization?
All Categories
Latest Post
- Magento 2 Rich Text Schema Setup in JSON-LD: Step-by-Step Guide
- Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
- How to Dispatch Custom Events in Magento 2
- Adding Filters in Magento Admin Grid | Column and Non-Column Component
- How to add custom styles (Colors and Fonts) to Magento Admin Grid