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


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


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


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.

| improve this answer | |
  • You are right, I extended Mage_Customer_Model_Resource_Customer_Collection class and it works. tnx! – JohnyFree Feb 19 '14 at 8:07
  • 1
    If my answer helped you please mark it as accepted. – oleksii.svarychevskyi Feb 19 '14 at 9:07

The original definition for this class lives in the ./lib/Varien/ folder.

If you must override any autoloaded classes from the ./lib folder, you can only do this via inclusion in total in one of the codepools (local, core, community in order of precedence).

There is no way to overwrite only one method.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.