Google Structured Data – Quick and Easy

I was trying to find a simple, quick and easy way to add Google Structured Data (Rich Snippets) to the product pages without modifying tons of templates etc.

The method below will get you up and running by adding a block of code at the end of one template Рtotal time to make the change and install Рless than 5 minutes!!

First, locate your active product view template –


After the final closing </div>, add the following code :

<?php //Added Div below for Google Rich Snippets / Structured Data ?>
<div itemscope itemtype="">
<meta itemprop="name" content="<?php echo $this->htmlEscape($_product->getName()) ?>" />
<meta itemprop="image" content="<?php echo Mage::helper('catalog/image')->init($_product, 'image') ?>" />
<meta itemprop="description" content="<?php echo $this->htmlEscape($_product->getDescription()) ?>" />
<meta itemprop="sku" content="<?php echo $this->htmlEscape($_product->getSku()) ?>" />
<meta itemprop="mpn" content="<?php echo $this->htmlEscape($_product->getModel()) ?>" />
<meta itemprop="model" content="<?php echo $this->htmlEscape($_product->getModel()) ?>" />
<meta itemprop="brand" content="<?php echo $_product->getAttributeText('manufacturer') ?>" />
<div itemprop="offers" itemscope itemtype="">
<meta itemprop="category" content="<?php echo $this->htmlEscape($_product->getClassification()) ?>" />
<meta itemprop="itemCondition" content="new" />
<meta itemprop="priceCurrency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode() ?>" />
<meta itemprop="price" content="<?php echo round($_product->getFinalPrice(), 2); ?>" />

<?php if($_product->isSaleable() ) { ?>
<link itemprop="availability" href="">
<?php } else { ?>
<link itemprop="availability" href="">
<?php } ?>

Read through all the attributes and modify where necessary (ie delete any not used – classification may not be used by many – check each attribute)

Save the file and upload to your installation.

Go to Google Webmaster Tools and use the structured data testing tool to make sure there are no errors – correct any if found. (The most important elements are brand, name, price, and model – the instock/outofstock would display using the testing tool)

Within the next few days, you’ll notice that Google has started to pick up your structured data / rich snippets on your product pages – you can verify¬†it by clicking on the structure data link under search appearance.

If you change template themes, just remember to add this block to the new theme view.phtml


Leave a Reply