Magento – Rewrite Single Method Using Local Class

classextendoverrides

I need to override Varien class because I need to change one method.

app/code/core/Varien/Data/Collection/Db.php

From what I know, the only way is to put it inside local folder.

app/code/local/Varien/Data/Collection/Db.php

But in this way I override entire class. Is there any way to override just single method?

Best Answer

Method getSelectCountSql() is overwritten in a lot of collections like Mage_Sales_Model_Resource_Order_Collection for example.

So if you need to change the behavior of getSelectCountSql() for some collection, you can easily do that in your collection class.

But do not do that in Varien_Data_Collection_Db because it will change the behavior of this method for all collections.

Related Topic