Sukeshini
Sukeshini

Reputation: 1261

How to override classes in lib/Varien directory?

I want to override \lib\Varien\Data\Collection\Db.php. I know how to override this by creating the same file path in local code pool. I want to know is it possible to override this class same way we overriding models, blocks inside our modules? Any help will be appreciated.

Upvotes: 1

Views: 1049

Answers (1)

Jürgen Thelen
Jürgen Thelen

Reputation: 12737

No, you can not rewrite Varien_Data_Collection_Db the dynamic way like you do with models, etc.

The reason is simple: all appropriate Magento models use Varien_Data_Collection_Db as a base class and literally extend it:

abstract class Mage_Core_Model_Resource_Db_Collection_Abstract extends Varien_Data_Collection_Db {}
abstract class Mage_Eav_Model_Entity_Collection_Abstract extends Varien_Data_Collection_Db {}
class Mage_Sales_Model_Resource_Sale_Collection extends Varien_Data_Collection_Db {}

Copying the class to the local or community code pool is the way to go.

Upvotes: 1

Related Questions