Magento add price and color in meta description

I would like to add product price in meta description of products. I don't write meta desc in product options, magento gets it from product desc. (it's ok to me)

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

How to make Meta desc looks like that= ProductDesc Color only FinalPrice

?

Answers


Pleas copyfile view.php app\code\core\Mage\Catalog\Block\Product to app\code\local\Mage\Catalog\Block\Product here find protected function _prepareLayout() find code and comment this

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


And try below       


$Color=$product->getAttributeText('color');
            $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
            $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
            $currencySymbol = Mage::app()->getLocale()->currency($currentCurrencyCode)->getSymbol();
            $price=$currentCurrencyCode .' '.Mage::helper('core')->currency($product->getFinalPrice(),false,true); 
            $metaTmp1=$Color.' only '. $price;
            $strlen=strlen($metaTmp);
            $metaTmp2==Mage::helper('core/stri;ng')->substr($product->getDescription(), 0, (255-$strlen-5));
            $meta= $metaTmp2.''.$metaTmp1;
            $headBlock->setDescription( $meta) ;

So I did:

//$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255)); $Color=$product->getAttributeText('color'); $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode(); $currencySymbol = Mage::app()->getLocale()->currency($currentCurrencyCode)->getSymbol(); $price=$currentCurrencyCode .' '.Mage::helper('core')->currency($product->getFinalPrice(),false,true);

        $metaTmp1=$Color.' only '. $price;
        $strlen=strlen($metaTmp);
        $metaTmp2==Mage::helper('core/string')->substr($product->getDescription(),
        0, (255-$strlen-5));
        $meta= $metaTmp2.''.$metaTmp1;
        $headBlock->setDescription( $meta) ;                   }

And in HTML code, in Meta desc I see only f ex " only 123" - so the price only.

No I don't need to manage it from admin.


Need Your Help

Convert table into matrix by column names

r statistics

I have data frame that looks like the following

Xcode plugin for improving code completion

ios objective-c xcode

Recently I've done a small service (available in Github) to return a switch case structure from a given enum.