2

Short background: We're using a third party extension so send mail with Mandrill. This extension accomplishes this by overriding the method core/email_template::send(). I have to implement an e-mail filter to stop all e-mails to be sent to certain fake e-mail addresses, which I would do by also overriding core/email_template::send(). Simple enough, I would just make sure my module depends on the third party extension using <depend> in my module configuration.

The problem: If we decide to to inactivate or remove the third party Mandrill extension, my e-mail filter module would stop working since it depends om the third party extension. What I would like is for it to continue working without having to do any modification to it.

Possible solution: Remove the <depend> and the order of magentos module loading resolv it.

As far as I understand magento, modules are loaded in the order core, community and last local, and then alphabetically within these pools? Since the third party extension is placed in the community pool and my module resides in the local pool, my module will always override and things will work as expected. However, I don't feel this is a very solid solution. If modules gets moved to other pools or get renamed, things could stop working correctly without anyone noticing.

2
  • I think the only real answer is to leave the depend in place, if you remove the Mandril extension you will therefore get the error and can fix it. You can do conditional class declarations with different extends, but in my opinion, this is far more 'voodoo' and an error would be my expected behaviour. Commented Mar 30, 2015 at 15:19
  • Thank you. I agree. If there's no good way to solve this it's better to leave the dependence in place. Commented Mar 31, 2015 at 12:18

1 Answer 1

1

As Cags said you can do different extends for instance you can put this at the top of your overwrite file and the extend your overwrite from Custom_Modulename_Model_Email_Template_Base

if (
    Mage::helper('core')->isModuleEnabled('module_name') &&
    Mage::getStoreConfig('modulename/general/enabled') 
) {
    class Custom_Modulename_Model_Email_Template_Base
        extends 3rdParty_Modulename_Email_Template
    {
    } 
} else {
    class Custom_Modulename_Model_Email_Template_Base
        extends Mage_Core_Model_Email_Template
    {
    } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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