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.
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(), 0, 255)); } 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']); } }
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?