Adding Social Networking Buttons to Magento
// February 17th, 2010 // 2 Comments » // Magento
I have been building a magento based site over the past few months for a new project I am working on with Ruth. The end product will be an online food store that sell Australian Gourmet Foods.
I spent a while searching around Google trying to figure out how to add social networking buttons into the products page. I basically wanted people to click “Share on Facebook”, “Tweet This” and more recently “Buzz This” and send the product name, the URL and any other text I wanted.
All you really need to know is
- <?php echo $this->htmlEscape($_product->getName()) ?> – Product name
- <?php echo $_product->getProductUrl() ?>- Product URL
I have added the below to the view.phtml page, found in templates/catalog/product.
<a title=”Send this page to Twitter!” href=”http://twitter.com/home?status=Check out the <?php echo $this->htmlEscape($_product->getName()) ?> at <?php echo $_product->getProductUrl() ?> @foodoAU” target=”_blank”><img src=”YOUR BUTTON HERE” alt=”Follow foodoAU on Twitter”/></a>
<a href=”http://www.facebook.com/sharer.php?u=<?php echo $_product->getProductUrl() ?>&t=Check+this+out” target=”_blank” title=”Share on Facebook”><img src=”YOUR BUTTON HERE” alt=”Share on Facebook”></a>
Google Buzz
<a href=”http://www.google.com/reader/link?url=<?php echo $_product->getProductUrl() ?>&title=<?php echo $this->htmlEscape($_product->getName()) ?>&srcURL=YOUR URL&srcTitle=YOUR SITE NAME” target=”_blank” rel=”nofollow external” title=”Google Buzz This”><img src=”YOUR BUTTON” ” alt=”Google Buzz This!” /></a>



