PHP Magento Tips

Change Product Page Title Programmatically With Event Observer in Magento

Rate this posting:
{[['']]}

In Magento it is very easy to Change Product Page Titles:

Step 1:

in app/etc/modules/Foo_Bar.xml add below code:

<?xml version="1.0" encoding="UTF-8"?>
<!-- app/etc/modules/Foo_Bar.xml -->
<config>
  <modules>
    <Foo_Bar>
      <active>true</active>
      <codePool>local</codePool>
    </Foo_Bar>
  </modules>
</config> 

Step 2:

in app/code/local/Foo/Bar/etc/config.xml add below code:

<?xml version="1.0" encoding="UTF-8"?>
<!-- app/code/local/Foo/Bar/etc/config.xml -->
<config>
    <global>
        <models>
            <foo_bar>
                <class>Foo_Bar_Model</class>
                </foo_bar>
        </models>
    </global>
    <frontend>
        <events>
            <catalog_product_load_after><!-- event -->  
                <observers>
                    <foo_bar><!-- unique for event -->
                    <type>model</type>
                    <!-- | singlton | disabled -->
                    <class>foo_bar/Observer</class>
                    <method>catalogProductLoadAfter</method>
                    </foo_bar>
                </observers>
            </catalog_product_load_after>
        </events>
      </frontend>
</config>


Step 3:

in app/code/local/Foo/Bar/Model/Observer.php add below code:

<?php
// app/code/local/Foo/Bar/Model/Observer.php
class Foo_Bar_Model_Observer {
    
    public function catalogProductLoadAfter(varien_Event_Observer $observer) {
        
        $product = $observer->getProduct();
        $product->setName($product->getName().' is cool!!');
        
    }
}


Tag : Magento
1 Comments On "Change Product Page Title Programmatically With Event Observer in Magento"

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Typo3, kindly contact us http://www.maxmunus.com/contact
MaxMunus Offer World Class Virtual Instructor led training on Typo3. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email : arun@maxmunus.com
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –http://www.maxmunus.com


Back To Top