Fixing Magento 2 Product Schema Markup | Missing “image” field FIX
ecommerce Magento Technical

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 

Note: These issues persist in the default Magento setups till version 2.4.7, so if you are using any 3rd party theme or SEO extension, or any newer version in future, then this solution might not work for you. If you are facing any troubles following the guide or fixing the schema, feel free to reach out to us.

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:

Click here to view and edit & add your code between the textarea tags

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.

Click here to view and edit & add your code between the textarea tags

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.

Click here to view and edit & add your code between the textarea tags

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.

Click here to view and edit & add your code between the textarea tags

default.phtml

Click here to view and edit & add your code between the textarea tags

Final Step: Deploy and Test Your Changes

After implementing the custom module, deploy the changes to your Magento store by running the following commands:

Click here to view and edit & add your code between the textarea tags

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.

need assisting with Magento 2 customization?