1

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)

  • It would work natively, so I suspect you have a module modifying it. Have a dig through the code, something must be overriding it (search for "setMetaDescription") – Mayers Nov 2 '15 at 11:30
  • In which file would you have a look about that? As in the Mage_Catalog_Block_Product_View.php and the other files in Mage_Catalog_Block_Product there is no such function declared – Tarrn Nov 2 '15 at 11:41
  • Do a grep in your root folder and search for "setMetaDescription", it will give you more information. If you're using a custom module, it's hard for me to tell you where and which. – Mayers Nov 2 '15 at 11:42
  • Neither do i sadly, as this isn't my website and neither have i installed the custom modules, but i will try to download the website later to do a grep. Thank you for your kind help so far. – Tarrn Nov 2 '15 at 11:56
  • have you need to change product meta description to description right? – Abdul Nov 2 '15 at 12:34
1

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.

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.