Jan 14, 2014

How to override magento model.

Overriding magento model is some tricky base, that's why I want to share how this models Override.


First Mage_Reports_Model_Event_Observer
<models>
    <reports>
        <rewrite>
            <event_observer>Globe_Reports_Model_Event_Observer</event_observer>
        </rewrite>
    </reports>
</models>



Second Mage_Reports_Model_Mysql4_Product_Index_Viewed_Collection
<!-- You configs -->
<models>
    <reports_mysql4>
        <rewrite>
            <product_index_viewed_collection>Globe_Reports_Model_Mysql4_Product_Index_Viewed_Collection</product_index_viewed_collection>
        </rewrite>
    </reports_mysql4>
</models>

// Your PHP class
class Globe_Reports_Model_Mysql4_Product_Index_Viewed_Collection extends Mage_Reports_Model_Mysql4_Product_Index_Viewed_Collection{

// Put possible override methods or 
//  addition methods you want here
}

No comments: