Change Product Meta Title, Keywords and Description in magento

Trying to boost SEO and came across an article that suggests tweaking the Meta Title, Keywords and Description for all products and categories.
The amount of products I have would just be impossible to do this.

File path
app\code\core\Mage\Catalog\Block\Product\View.php

protected function _prepareLayout()
{
    $this->getLayout()->createBlock('catalog/breadcrumbs');
    $headBlock = $this->getLayout()->getBlock('head');
    if ($headBlock) {
        $product = $this->getProduct();
        $productTitle = $product->getName();
        $title = $product->getMetaTitle();
        if($title)
        { 
            $headBlock->setTitle($title);
        }
        else
        {   
            $title = "Buy ".$productTitle. " Online @ Best Price - Sowing Happiness";
            $headBlock->setTitle($title);
        }
        $keyword = $product->getMetaKeyword();
        $currentCategory = Mage::registry('current_category');
        if($keyword) 
        {
            $headBlock->setKeywords($keyword);
        } 
        elseif($currentCategory) 
        {
            //$headBlock->setKeywords($product->getName());
            
            $keyword = $productTitle.", Buy ".$productTitle.", Buy ".$productTitle." Online, ".$productTitle." Online";
            $headBlock->setKeywords($keyword);
        }
        $description = $product->getMetaDescription();
        if($description) 
        {
            $headBlock->setDescription( ($description) );
        } 
        else
        {
            $description = "Buy ".$productTitle." online in Delhi andNCR fromSowing Happiness at the best pricesand free shipping for products costing above Rs. 499.";
            $headBlock->setDescription( ($description) );
            //$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
        }
        if ($this->helper('catalog/product')->canUseCanonicalTag()) {
            $params = array('_ignore_category' => true);
            $headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
        }
    }

    return parent::_prepareLayout();
}

Leave a Reply