Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Add SKU to title [SOLVED]
 
jsch
Jr. Member
 
Total Posts:  25
Joined:  2011-08-28
 

Hi,

How can I add the SKU to the title tag when viewing a product?

My title tag looks like this for a product
Domain - productname - subcategory- subcategory- main category

Would like it to be something like this:
Domain - SKU - productname - subcategory- subcategory- main category

 
Magento Community Magento Community
Magento Community
Magento Community
 
Siggi_Schmitz
Enthusiast
 
Avatar
Total Posts:  811
Joined:  2011-07-03
 

Sure,

File:

app/code/core/Mage/Page/Block/Html/Head.php

Change the function setTitle from this:

public function setTitle($title)
    
{
        $this
->_data['title'Mage::getStoreConfig('design/head/title_prefix') . ' ' $title
            
' ' Mage::getStoreConfig('design/head/title_suffix');
        return 
$this;
    
}

to this:

public function setTitle($title)
    
{
        $sku 
'';
        if (
$product Mage::registry('current_product')) {
            $sku 
$product->getSku() . ' - ';
        
}
        $this
->_data['title'$sku Mage::getStoreConfig('design/head/title_prefix') . ' ' $title
            
' ' Mage::getStoreConfig('design/head/title_suffix');
        return 
$this;
    
}

Of course, it`s better to overwrite this function with an own module instead of hacking the core code!

 
Magento Community Magento Community
Magento Community
Magento Community
 
jsch
Jr. Member
 
Total Posts:  25
Joined:  2011-08-28
 

Thanks alot.

I will see if I can figure out how to do this by creating a module.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top