How to override a model in Magento?

guys.

I need to override 2 functions in different classes (CatalogSearch / Layer.php and CatalogSearch / Mysql4 / Fulltext / Collection.php). So, I have a configuration file:

<config> <modules> <my_modulename> <version>0.1</version> </my_modulename> </modules> <global> <models> <catalogsearch> <rewrite> <layer>My_Modulename_Model_CatalogSearch_Layer</layer> <mysql4_fulltext_collection>My_Modulename_Model_CatalogSearch_Mysql4_Fulltext_Collection </mysql4_fulltext_collection> </rewrite> </catalogsearch> </models> </global> </config> 

Therefore, Layer.php was correctly overridden, but Collection.php did not have it - '/local/My/Modulename/Model/CatalogSearch/Mysql4/Fulltext/Collection.php' was not even included. What for?

Thanks for any help.

+4
source share
1 answer

Resource models are probably handled separately, try the following:

 <global> <models> <catalogsearch> <rewrite> <layer>My_Modulename_Model_CatalogSearch_Layer</layer> </rewrite> </catalogsearch> <catalogsearch_mysql4> <rewrite> <fulltext_collection>My_Modulename_Model_CatalogSearch_Mysql4_Fulltext_Collection</fulltext_collection> </rewrite> </catalogsearch_mysql4> </models> </global> 
+8
source

All Articles