Product and Breadcrumb Rich Snippets in Magento

Rich Snippets were introduced a while ago as a standardised way to describe your website content so that services such as Google Search can understand it. Google uses information from Rich Snippets to display information about your web page in its search results, as seen here:

Rich Snippets Example

The Rich snippets specification is defined at Schema.org

Here’s how to add products and breadcrumb Rich Snippets in Magento.

Breadcrumbs.

Implementing the breadcrumbs rich snippets in Magento is pretty straightforward. Create your own breadcrumbs.phtml file in <module>/app/design/frontend/<package>/<theme>/template/page/html/breadcrumbs.phtml

Edit for your design.

Products

Add markup to your<module>/app/design/frontend/<package>/<theme>/template/catalog/product/view.phtml.

Set the schema scope:

Add the description markup:

Prices

My product detail page contains a block with ‘related products’ displayed. Magento has a single file for displaying the prices (<module>/app/design/frontend/<package>/<theme>/template/catalog/product/price.phtml) so adding any Rich Snippets markup to this file causes it to be added to the product and also to all the related products too, rendering the page invalid when checking with Google’s Rich Snippets testing tool (https://developers.google.com/structured-data/testing-tool/).

The fix for this is to check whether the current iteration of the product in price.phtml is the same as the main price, and then only set the Rich Snippets markup if it is.

So, at the top of price.phtml, after $_product has been declared:

Then use this to decide whether we should show the Rich Snippets Markup:

And thats it. You can test your Rich Snippets markup is valid by using the Google Rich Snippets testing tool.