Magento1.8 SEO – Get Meta Description in Schema Product Description

magento-1.8PHPseo

In the header I have the following code for meta description.

<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />

I am trying to get this description as my schema product description as follows in the view.pthml file

<meta itemprop="description" name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" /> 

However "Description" it shows up as a blank on the google rich snippets tool.

When I enclose

<meta itemprop="description" name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />

with a <span itemscope itemtype="Http://Schema.Org/Product" > it shows up, but of course breaks the other product itemtype thats on the page.

So how do I get the description in the header to show as my schema product description?

Note: the default meta description is not used (blank) a extension called creare SEO creates the meta description based on attributes.

Best Answer

if(Mage::registry('current_product')){
Mage::registry('current_product')->getDescription();
}

instead of $this->getDescription() ;

Hi,In product page $this->getDescription() function logic depend on below logic

$description = $product->getMetaDescription();
            if ($description) {
                $headBlock->setDescription( ($description) );
            } else {
                $headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
            }

this Code is exiting on fileapp/code/Mage/Catalog/Block/Product/View.php .If you have any issue change logic here.it maay you data issue

Just put code in view.phtml

<?php 
 $description='';
 $description = $_product->getMetaDescription();
            if ($_product->getMetaDescription()) {
               $description=$_product->getMetaDescription();
            } else {
                $description=Mage::helper('core/string')->substr($_product->getDescription(), 0, 255);
            }
?>
<meta itemprop="description" name="description" content="<?php echo htmlspecialchars($description) ?>" />

after

  <?php $_product = $this->getProduct(); ?>

Last resolution:

<?php $headBlock = $this->getLayout()->getBlock('head'); echo $description=$headBlock->getDescription(); ?>" />