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

Change Product Page Title
 
ferarrieta
Jr. Member
 
Total Posts:  2
Joined:  2011-12-26
 

Hi, I need help, please!

I want to change the page title on products page,

for example (in http://quierojuegos.es/index.php/call-of-duty-black-ops-ii-ps3.html), page title is:

Juegos de PS3, Juegos de Xbox - Tienda de VideoJuegos Call of Duty: Black Ops II PS3 - Comprar Call Of Duty: Black Ops II de PS3

I want the title on product pages like this:

Call of Duty: Black Ops II PS3 - Comprar Call Of Duty: Black Ops II de PS3

What can I do?

Thank you!
Fernando

 
Magento Community Magento Community
Magento Community
Magento Community
 
VnEcoms
Sr. Member
 
Avatar
Total Posts:  121
Joined:  2012-09-13
Vietnam
 

From backend Edit that product.
Click to Meta Information tab. Edit the Meta Title

 
Magento Community Magento Community
Magento Community
Magento Community
 
ferarrieta
Jr. Member
 
Total Posts:  2
Joined:  2011-12-26
 

Meta Information it’s ok. What I want to do its remove prefix title in my product pages.
I want to see only the product information in the title. Let me know if you understand me, please.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Hello.
First of all here is how it works.
When viewing a product page this block is rendered Mage_Catalog_Block_Product_View.
This block has a method called _prepareLayout() that is called before rendering anything.
Inside this method there is this piece of code.

$headBlock $this->getLayout()->getBlock('head');
        if (
$headBlock{
            $product 
$this->getProduct();
            
$title $product->getMetaTitle();
            if (
$title{
                $headBlock
->setTitle($title);
            
}
         
...
        
}
This sets the meta title for the product page.
Now let’s take a look at the setTitle method.
Mage_Page_Block_Html_Head::setTitle() looks like this:
public function setTitle($title)
    
{
        $this
->_data['title'Mage::getStoreConfig('design/head/title_prefix') . ' ' $title
            
' ' Mage::getStoreConfig('design/head/title_suffix');
        return 
$this;
    
}
This means that the prefix and suffix are added to the meta title.

Now here is my idea. (if you have a better one feel free to use it)
I would override the Mage_Page_Block_Html_Head class to add a new method. Let’s call it setExactTitle() that looks like this

public function setExactTitle($title)
    
{
        $this
->_data['title'$title;
        return 
$this;
    
}
After this override the Mage_Catalog_Block_Product_View::_prepareLayout() method to look like this:
protected function _prepareLayout()
    
{
        $this
->getLayout()->createBlock('catalog/breadcrumbs');
        
$headBlock $this->getLayout()->getBlock('head');
        if (
$headBlock{
            $product 
$this->getProduct();
            
$title $product->getMetaTitle();
            if (
$title{
                $headBlock
->setExactTitle($title);//changed setTitle to setExactTitle
            
}
            $keyword 
$product->getMetaKeyword();
            
$currentCategory Mage::registry('current_category');
            if (
$keyword{
                $headBlock
->setKeywords($keyword);
            
elseif($currentCategory{
                $headBlock
->setKeywords($product->getName());
            
}
            $description 
$product->getMetaDescription();
            if (
$description{
                $headBlock
->setDescription( ($description) );
            
else {
                $headBlock
->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0255));
            
}
            
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
                $params 
= array('_ignore_category'=>true);
                
$headBlock->addLinkRel('canonical'$product->getUrlModel()->getUrl($product$params));
            
}
        }
        
//removed parent::_prepareLayout and replaced with lower section
        
$block $this->getLayout()->getBlock('catalog_product_price_template');
        if (
$block{
            
foreach ($block->getPriceBlockTypes() as $type => $priceBlock{
                $this
->addPriceBlockType($type$priceBlock['block']$priceBlock['template']);
            
}
        }

        
return $this;
    
}

Now here is small tutorial on how to properly override blocks in Magento:
http://magedev.com/2009/06/03/magento-overriding-model-block-or-helper/

Use that to override the blocks I suggested.
Cheers,
Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
enass
Jr. Member
 
Total Posts:  5
Joined:  2012-07-16
 

please help me in my issue, i need assistance (i have many of products with themes and this themes will show in specific category and when click into any themes will show many of products including this theme no show product information with add to cart ...etc)
how i will do it?

B. regards

Enass

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