Adding Social Networking Buttons to Magento – Updated

Update: There has been a few updates to the code below, especially the Google Buzz code.

——-

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 the two pieces of code below that will grab the product name and URL you need to insert into the URL of the code you are going to be placing on your page. I have already inserted this code into each URL.

I have added the below to the view.phtml page, found in templates/catalog/product. You’ll need to decide where you want to add it, so it might take a few times to get it right. Just copy the below code, paste it where you want it displayed on your product page and edit the bits in bold to suit your website.

Twitter

<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>

Facebook

<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/buzz/post?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>



Tags : , , , ,

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

31 Comments

Leave Comment