Magento – Product description is used as meta description

meta-tagsproduct

I tried to update the meta descriptions for my products so that they are different to the normal description. My main problem is, that in the source code the normal description of the products is shown as the meta description and the text entered in the meta description is ignored.

Any tips how to solve this? (this isn't my website, I try to polish it up a bit, which all works fine except this problem)

Best Answer

The Meta Description for each page is loaded in the file

[your magento install dir]/app/design/frontend/YOURPACKAGE/YOURTHEME/template/page/html/head.phtml

If your theme does not have its own head.phtml file then look in the /default/default/ and /base/default/ directories

By default the code which renders the Meta Description looks like this

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

So first check for possible changes in this code.

Now for product pages the getDescription() function call gets its data from

[your magento install dir]/app/code/core/Mage/Catalog/Block/Product/View.php

By default the _prepareLayout() function in this file should contain the following code for retreiving the Meta Description

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

So also check this code for any changes. This code could also be overwritten in

[your magento install dir]/app/code/local/Mage/Catalog/Block/Product/View.php

If you do not find any changes then this may be caused by some extenion. A good way to trouble shoot is to disable all extensions (one by one) and/or change to the base/default theme to see what happens.

Related Topic