jcadima
8/22/2016 - 7:59 PM

Magento get current page title by store id or store code

Magento get current page title by store id or store code

http://stackoverflow.com/questions/31511631/magento-get-current-page-title-by-store-id-or-store-code

Category page

The title is set within the Mage_Catalog_Block_Category_View block
<?php
if ($headBlock = $this->getLayout()->getBlock('head')) {
    $category = $this->getCurrentCategory();
    if ($title = $category->getMetaTitle()) {
        $headBlock->setTitle($title);
    }
    
    

Product page

The title is set within the Mage_Catalog_Block_Product_View block

$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
    $product = $this->getProduct();
    $title = $product->getMetaTitle();
    if ($title) {
        $headBlock->setTitle($title);
}



CMS page

The title is set within the Mage_Cms_Block_Page block

$head = $this->getLayout()->getBlock('head');
if ($head) {
    $head->setTitle($page->getTitle());
}





Cart

The title is set within the Mage_Checkout_CartController (not a block this time!)

$this
    ->loadLayout()
    ->_initLayoutMessages('checkout/session')
    ->_initLayoutMessages('catalog/session')
    ->getLayout()->getBlock('head')->setTitle($this->__('Shopping Cart'));