Magento tutorial: how to overload a Varien class?

If you have read my previous post about Magento overloading mechanism, you’ll see that there is two existing mechanisms to overload classes in Magento

But these two mechanisms are only available for classes which are instantiated.

Many of Varien classes are not loaded directly through a new. So how we can overload them?

If class is only used when using extends, we have only one way to overload it’s content: the passive overload

This mechanism is based upon the auto-loading mechanism embedded with Magento

  • Loading first from app/code/local folder
  • Then first look for classes in app/code/community
  • If always not found, look for the app/code/core folder
  • Always not found? look for lib folder

The only way you can use to overload a Varien class is to use this mechanism to provide your own functionalities by copying Varien class in app/code/community or app/code/local folder (we do not touch at the app/code/core)

By using this method, this is your class which will be loaded, instead of Varien one