How to Add ProductOntology.org Markup to Magento Product Pages

I’ve been thinking of doing a Schema.org for Magento tutorial for some time now, but two things in particular has been stopping me.

For one, there’s little I can do to add to the wonderful job GotGroove.com did on their Evolving Ecommerce blog. They cover it all, from adding the Product Schema, the name, SKU, image, description, and all of the Offer data for every item in Magento.

Magento Tricks by Traffic Motion

Second, Robert Kent, in his book Magento Search Engine Optimization, does just as great of a job — although slightly differently — in implementing Schema.org structured data for Magento stores. He also covers all of the basics to get an ecommerce website using valid markup.

With that in mind, I won’t reinvent the wheel. There’s no point. Just go check out GrooveCommerce and buy Kent’s book from Amazon and do the basic implementation yourself.

What Is Product Types Ontology?

But what I can offer is one further integration for Magento stores. That is, the Product Types Ontology from ProductOntology.org. Product Types Ontology, according to the website, “provides ca. 300,000 precise definitions for types of product or services that extend the schema.org and GoodRelations standards for e-commerce markup.”

What’s the benefit of doing this? To be honest, I’m not quite sure. Google and Bing aren’t using ProductOntology.org class identifiers in their search results pages. However, Google and Bing, by implementing the “additionalType” property on Schema.org, obviously have services of this type in mind.

What ProductOntology.org markup helps us do is add an external link reference to each of our product pages, telling search engine robots, browsers, and other applications more about our products, without including a lot of extraneous, redundant information on the product page itself. Let the product page do what it does best — briefly and accurately describe the item and provide users the opportunity to purchase it. To do this, we’ll be utilizing Schema.org’s “additionalType” property, with a link reference to a class identifier on the ProductOntology.org website.

Implementation Guide for Magento

While I’m sure there would be a more elegant way to do this, for many small and medium sized stores, this should be more than sufficient, and is easy to do without spending precious resources on Magento development. In the future, this type of markup may be worth doing through a custom module or extension, but this guide will at least get us to be able to use ProductOntology.org markup on product pages in any Magento store.

Let’s start with the end. This is what we want the code to look like for each product page:

<link itemprop="additionalType" href="http://www.productontology.org/id/Product_Type">

With “Product_Type” being replace with the actual product type. And where do we get this product type? The Product_Type comes from Wikipedia. Using the Magento demo store’s Canon PowerShot A630 8MP Digital Camera with 4x Optical Zoom as an example, we would search for the most relevant page on en.wikipedia.org, in this case http://en.wikipedia.org/wiki/Point-and-shoot_camera and use the part after “wiki/” as the ID for the ProductOntology.

Creating the Product Ontology Attribute

The first step in Magento is creating a Custom Attribute. In the admin section of your store, navigate to Catalog > Attributes > Manage Attributes > Add New Attribute. We’ll use product_ontology as the Attribute Code, set the scope to Global, set it to a Text Field, and leave everything else as the default values. Use “Product Ontology” as the admin label.

Now, we have to associate the new attribute with a set. Navigate to Catalog > Attributes > Manage Attribute Sets, and click on Cameras. On the right side of the screen, drag product_ontology over to the General section under Groups.

While we’re in the admin area, let’s give a product an ontology! Search for the Canon PowerShot A630 item under Catalog > Manage Products, and navigate to the General tab on the left of the product edit screen. Under Product Ontology, put “Point-and-shoot_camera” in the text field and save the product.

Editing the Product View Template File

Great, so it’s there and associated with a product. But it’s not displaying anywhere on the frontend since we set it not to display on the frontend. We don’t want it in the specifications table since it doesn’t really belong there.

In your Magento installation folder, navigate to magentoroot/app/design/frontend/base/default/template/catalog/product/ and open the view.phtml file.

If you followed the GrooveCommerce Schema.org implementation guide, you should have the Product itemtype already in this file (or the corresponding view.phtml file in your theme). If not, go use their guide now to get up to speed.

Under the <h1> tag for the product name (on or around line 51 of the default store), we’re going to add this single snippet of code to make this whole thing work:

<?php if ($_product->getProductOntology()): ?>
<link itemprop="additionalType" href="http://www.productontology.org/id/<?php echo $_product->getProductOntology() ?>">
<?php endif; ?>

That’s it! We’re done. Check on the frontend that it’s displaying on your site for the Canon A630. The code should look exactly like this:

<div class="product-name">
	<h1 itemprop="name">Canon PowerShot A630 8MP Digital Camera with 4x Optical Zoom</h1>
	<link itemprop="additionalType" href="http://www.productontology.org/id/Point-and-shoot_camera">
</div>

Now, whatever type of product you have, you can go to Wikipedia, find the most specific Wiki, grab the last part of the URI, and paste it into the Product Ontology field for any product you offer.

We also used a php if statement that will only display the ProductOntology link reference if the attribute is populated for the product. That way, you won’t have empty href attributes if you add a product and fail to add the Wikipedia class right away.

Updating Product Ontology Data in Bulk

Whether you have a handful or thousands of products, you can easily update the Product Ontology data by doing an export of your product info from Magento, then simply uploading the updates back into Magento. All you need to do is match up the SKU field with the Product Ontology ID that you’ve chosen for each product.

Wrapping Up ProductOntology.org Markup

This solution is quick, clean, and easy enough for even Magento novices to use. It’s also a no-risk way to add more structured data to your website and give search engines and browsers more information about your products.

While this solution works for all products, it could probably be done in a more elegant manner if someone wants to take this idea and run with it and develop a full extension for Magento. If you add new products to your site on a daily basis, filling in the Product Ontology field may become quite a hassle, and leaving the field empty is fairly useless.

However, for smaller ecommerce sites that just want more structured data, and who don’t update their products daily or hourly, this is a great way to add the ProductOntology class identifiers to your site.

Again, is there any tangible benefit to it? I don’t know. That’s why I haven’t dug deeper into this. Unless I see Google rewarding this type of structured data, I can’t recommend going beyond this very simple implementation guide and spending a lot of resources having expensive Magento developers create a custom module for it.

1 thought on “How to Add ProductOntology.org Markup to Magento Product Pages”

Leave a Reply

Your email address will not be published. Required fields are marked *