I would like to extend core product class and add some functionality.
I made file app\code\local\ast\Catalog\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<ast_Catalog>
<version>0.0.1</version>
</ast_Catalog>
</modules>
<global>
<models>
<catalog>
<rewrite>
<product>ast_Catalog_Model_Product</product>
</rewrite>
</catalog>
</models>
</global>
</config>
second file app\etc\modules\ast_Catalog.xml
<?xml version="1.0"?>
<config>
<modules>
<ast_Catalog>
<active>true</active>
<codePool>local</codePool>
</ast_Catalog>
</modules>
</config>
and file Product.php in app\code\local\ast\Catalog\Model\
class ast_Catalog_Model_Product extends Mage_Catalog_Model_Product
{
public function makeBlue()
{
echo 'makeBlue';
}
}
Now when I try to use my function makeBlue() in app\design\frontend\ast\default\template\catalog\product\view.phtml file
<div class="product-shop">
<?php
....
echo 'hello';
echo $this->makeBlue();
....
?>
I have got error below:
Invalid method Mage_Catalog_Block_Product_View::makeBlue(Array
(
)
)
#0 I:\WWW\Sklep_www4\app\design\frontend\ast\default\template\catalog\product\view.phtml(45): Varien_Object->__call('makeBlue', Array)
.......
What is wrong ?
The problem was I extend class ast_Catalog_Model_Product not Mage_Catalog_Block_Product_View. After change extend class to Mage_Catalog_Block_Product_View everything works fine.