0

In magento the html title is standard configured that it shows the name of the product when on a product page. It also shows the product name if you are on the review page of that specific product.

So it shows the image below in the browser tab both on the product page and the product review page.

enter image description here

I want to change the title for the product review page. I want the browser tab to say something like: 'You are reviewing a product'

Is there some way to change this only for the product review page.

0

Try to create Observer on the catalog_controller_product_view

in your app/code/local/Companyname/Modulename/etc/config.xml

...
        <frontend>
            <events>
                <catalog_controller_product_view>
                    <observers>
                        <modulename>
                         <class>Companyname_Modulename_Model_Observer</class>
                            <method>updateTitleBar</method>
                        </modulename>
                    </observers>
                </catalog_controller_product_view>
            </events>
        </frontend>
    ....

and then in create Observer.php, in the folder app/code/local/Companyname/Modulename/Model

then write this code

<?php

class Companyname_Modulename_Model_Observer
{

    public function updateTitleBar(Varien_Event_Observer $observer)
    {
        if ($product = $observer->getEvent()->getProduct()) {
            $title = __('You are reviewing a product '). $product->getData('name');
            $product->setMetaTitle($title);
        }
        return $this;
    }
}
0

Method 1:

Step 1. Override the controller app/code/core/Mage/Review/controllers/ProductController.php in the local or community code pool.

Step 2. Write the following code just before $this->renderLayout();:

$this->getLayout()->getBlock('head')->setTitle($this->__('You are reviewing %s', $product->getName()));

Step 3. Refresh cache for your Magento system and check the frontend.

Update:

Method 2:

Step 1: Add this code in your module's app/code/[codePool]/[NameSpace]/[Module]/etc/config.xml:

<frontend>
        <events>
            <controller_action_layout_render_before_review_product_list>
                <observers>
                    <modulename>
                        <class>[NameSpace]_[Module]_Model_Observer</class>
                        <method>updateTitleBar</method>
                    </modulename>
                </observers>
            </controller_action_layout_render_before_review_product_list>
        </events>
    </frontend>

Step 2: Create an observer file (app/code/[codePool]/[NameSpace]/[Module]/Model/Observer.php) and the following code:

load(Mage::app()->getRequest()->getParam('id'))) { $title = __('You are reviewing a product '). $product->getName(); $head = Mage::app()->getLayout()->getBlock('head'); if($head) { $head->setData('title', 'You are reviewing '.$product->getName()); } } return $this; } }

  • I don't think this works, I tried to add it on my local environment to the core and it did not change anything, so I did not try to override the controller. i Added your code to above rule 252 and 279 in app/code/core/Mage/Review/controllers/ProductController.php – Jasper1187 Sep 21 '18 at 11:40
  • I have tried both methods in my localhost and found working. Have you flushed cache? Also, try my second solution. – Mohit Kumar Arora Sep 21 '18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.