Harini
Harini

Reputation: 25

Magento - Set Category meta title, keywords and description

I have a category for shoes on my website. The meta title,description and keywords that I give under Catalog/Category for that category are not reflected. This is not specific to a category , I'm just quoting shoes as an example.

I dont want to use settitle,setkeyword,setdescription on layout files to set the above. Why is the default magento functionality not working.

It'd be great help if you could point out the area where the default values are applied.

Upvotes: 1

Views: 9696

Answers (1)

Malachy
Malachy

Reputation: 1590

For category layouts in the default magento theme, the area where the meta tags are set is :

//file: app/code/core/Mage/Catalog/Block/Category/view.php
//class: Mage_Catalog_Block_Category_View
//function: protected function _prepareLayout()
    //...
            $category = $this->getCurrentCategory();
            if ($title = $category->getMetaTitle()) {
                $headBlock->setTitle($title);
            }
            if ($description = $category->getMetaDescription()) {
                $headBlock->setDescription($description);
            }
            if ($keywords = $category->getMetaKeywords()) {
                $headBlock->setKeywords($keywords);
            }
    //...

So I think the questions to ask yourself are why is $category->getMetaTitle() falsey or what, later on in the layout, is overwriting $category->getMetaTitle() or does my theme rewrite the function Mage_Catalog_Block_Category_View::_prepareLayout().

You may want to search all your .xml files for code like this:

    <reference name="head">
        <action method="setTitle" translate="title" module="catalog"><title>Site Map</title></action>
    </reference>

Because any module can change the meta tags using XML.

Upvotes: 1

Related Questions