1

I developed whats-app share extension.
and I want to share image can any one help me how to share product image to whats-app.

<?php

include 'app/Mage.php';
Mage::setIsDeveloperMode(true);

Mage::app(); // Mage_Core_Model_App

Mage::getSingleton('core/session', array('name'=>'frontend'));


$productId = '100';
    $product = Mage::getModel('catalog/product')
        ->load($productId);
?>



 <meta property="og:title" content="<?php echo ($product->getName()); ?>" />
 <meta property="og:type" content="product" />
 <meta property="og:image" content="<?php echo Mage::helper('catalog/image')->init($product, 'small_image')->resize(200,200);?>" />
 <meta property="og:url" content="<?php echo $product->getProductUrl(); ?>" />
 <meta property="og:description" content="<?php echo strip_tags(($product->getShortDescription())); ?>" />
 <meta property="og:site_name" content="<?php echo Mage::app()->getStore()->getName(); ?>" />
 <body>
 <div>

 <a href='<?php echo 'whatsapp://send?text=https://magecomp.com/dev/magento-2-custom-stock-status.html%0A%0A'; ?>' > 
    hello
 </a>

 </div>

    </body>
  • You can use open graph meta tag in your product page – Gopal Patel Mar 27 '17 at 9:33
  • can you give me code – Jigs Parmar Mar 27 '17 at 9:34
1

Use open graph meta tag

Just copy and paste below codes in head.phtml file in our template file.

<?php if(Mage::registry('current_product')): ?>
 <?php $product = Mage::registry('current_product'); ?>
 <meta property="og:title" content="<?php echo ($product->getName()); ?>" />
 <meta property="og:type" content="product" />
 <meta property="og:image" content="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(200,200);?>" />
 <meta property="og:url" content="<?php echo Mage::registry('product')->getProductUrl(); ?>" />
 <meta property="og:description" content="<?php echo strip_tags(($product->getShortDescription())); ?>" />
 <meta property="og:site_name" content="<?php echo Mage::app()->getStore()->getName(); ?>" />
 <?php endif; ?>

More Info

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.