How to Override/Overwrite Core Class In Magento ?


There are many reasons and it’s a bad habit and bad programming if core files are modified and it’s not recommended at all. Therefore Magento brought in an excellent way how to override/overwrite those files.In  this post we learn how to override product Model class.This module we will change   first character of product name in uppercase.

 Override/Overwrite Magento Model Class.

1. Create activation/deactivation file.

<?xml version="1.0"?>


 true
 local



2. Create Configuration file.

<?xml version="1.0"?>


       
           1.0.0
       





Smartwin_Coverite_Model_Product





3. Create Modelfile.
<?php
/* app/code/local/Smartwin/Coverite/Model/Product.php  */
class Smartwin_Coverite_Model_Product extends Mage_Catalog_Model_Product
{
 public function getName()
    {
  /*  Customize Code here  */
       $name = parent::getName();
    return ucwords($name);
    }
}
?>
Now Go to Font-end refresh page You will see the effect.

No comments:

Post a Comment