It's fairly easy actually
This is my case with v3.0.6, should be ok for v3.x.x and also should be ok for v2.x.x with maybe minor changes regarding the template file and what variables are used for pulled data, depending on your cart version.
This MOD includes one additional function.
1. Open /addons/discussions/controllers/customer/init.post.php
Add this function at the end of the file:
function fn_get_review_count($object_id,$object_type) { global $db_tables; $discussion = fn_get_discussion($object_id, $object_type); if (empty($discussion)) { return false; } return db_get_field("SELECT COUNT(b.post_id) as val FROM ?:discussion_rating as a LEFT JOIN ?:discussion_posts as b ON a.post_id = b.post_id WHERE a.thread_id = ?i and b.status = 'A'", $discussion['thread_id']); }
2. Open up your product template .tpl file i.e:
/skins/YOUR_SKIN/customer/blocks/product_templates/default_template.tpl (may be different in your case)
Add this code right at the end of the file:
{assign var="product_amountN" value=$product.inventory_amount|default:$product.amount} {assign var="url" value="`$config.current_location`/`$config.current_url`"|fn_url} {assign var="average_rating" value=$product.product_id|fn_get_average_rating:"P"} {assign var="rev_count" value=$product.product_id|fn_get_review_count:"P"} <div style="display: none;" itemscope itemtype="http://schema.org/Product"> <span itemprop="name">{$product.product|unescape}</span> <span itemprop="image">{$config.current_location}{$product.main_pair.detailed.image_path}</span> <img itemprop="image" src="{$config.current_location}{$product.main_pair.detailed.http_image_path}"/> <span itemprop="description"> {$product.full_description}</span> <span itemprop="url">{$url}</span> <span itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <span itemprop="price">{$product.price|format_price:$currencies.$primary_currency:''}</span> <meta itemprop="priceCurrency" content="YOUR_CURRENCY_CODE" /> {if $product_amountN > 0} <link itemprop="availability" href="http://schema.org/InStock"> {else} <link itemprop="availability" href="http://schema.org/OutOfStock"> {/if} </span> <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> <span itemprop="ratingValue">{$average_rating}</span> <span itemprop="bestRating">5</span> <span itemprop="reviewCount">{$rev_count}</span> </div> </div>
That's it!
Don't forget to change "YOUR_CURRENCY_CODE" (without the quotes) to your currency (EUR, USD etc)
You can check if it works for you from the google test page at: http://www.google.co...ls/richsnippets
Enjoy...
Edited by preudomme, 21 March 2013 - 09:02 PM.