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"?>2. Create Configuration file.true local
<?xml version="1.0"?>3. Create Modelfile.1.0.0 Smartwin_Coverite_Model_Product
<?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