I want to override an core model class, but I cannot find the correct way to do it.
I have googled a lot, but some of the examples are shown how to override a model which are not located at app/code/core/Mage/Core/Model
folder and some of the examples are shown how to override a model which in the sub-dir of Core
dir, like app/code/core/Mage/Core/Model/Resources/Eav/Mysql4/
.
I have read the examples, but I still cannot find a way to override it. For example, I want to override app/code/core/Mage/Core/Model/Store.php
And here is the xml I use, but it is not working. Please help me to find out which part is wrong. Thanks in advance!
app/etc/models/My_Core
<config>
<modules>
<My_Core>
<active>true</active>
<codePool>local</codePool>
</My_Core>
</modules>
</config>
app/code/local/My/Core/etc/config.xml
<config>
<modules>
<My_Core>
<version>0.1.0</version>
</My_Core>
</modules>
<global>
<models>
<my_core_store>
<rewrite>
<class>My_Core_Model_Store</class>
</rewrite>
</my_core_store>
</models>
</global>
</config>
The new Store.php file is at app/code/local/My/Core/Model/Store.php
. And the magento version is 1.8.1.0
Your config.xml has some mistakes. Follow in this way..
< ?xml version="1.0"?>
<config>
<modules>
<my_core>
<version>0.1.0</version>
</my_core>
</modules>
<global>
<models>
<core>
<rewrite>
<store>My_Core_Model_Store</Store>
</rewrite>
</core>
</models>
</global>
</config>
and also in the model class, You need to extend the Parent Class Name. For Ex: My_Core_Model_Filename extends Mage_Core_Model_Store