Nikhil_K_R
Nikhil_K_R

Reputation: 2373

Integration of facebook like button in magento (programmatically)

I want to add Facebook like button in category-product-view.
I added the following part in head.phtml :

<?php
$product = Mage::registry('current_product');
if($product)
{
?>
<meta property="og:title" content="<?php echo trim($product->getName()); ?>"/>
<meta property="og:url" content="<?php echo $this->helper('core/url')->getCurrentUrl();?>"/>
<meta property="og:type" content="product"/>
<meta property="og:image" content="<?php echo $this->helper('catalog/image')->init($product, 'image') ;?>"/>
<?php
}
?>

And added the following code in addto.phtml (template/catalog/product/view/addto.phtml)(line:31):

<ul class="add-to-links">
<li>
<div class="fb-like" data-href="<?php echo $this->helper('core/url')->getCurrentUrl();?>" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true">
</div>
</li>

I get like button,but onclicking it shows question mark in image part and like part has no effect (i.e like is not done).
It asks confirm again and again.
Adding there is no update for the same page in my fb profile.
I want image ,title, description on-clicking like button and reflect the same in fb profile page.
Thanks in advance.

Upvotes: 0

Views: 2454

Answers (2)

Nikhil_K_R
Nikhil_K_R

Reputation: 2373

The problem was with working in local.
When it is live it retrieves proper image,description .
Thanks for your support.

Upvotes: 0

rixit
rixit

Reputation: 46

Use This, It's work for me in magento 1.7

<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="<?php echo $this->getSkinUrl()."images/icon-f.png" ?>" alt="Share on Facebook"> <a>

Upvotes: 3

Related Questions