0

I'm using Magento 1.9.x EE.

I'm looking to overwrite the Mage_Core_Model_Email_Template::send function.

I could overwrite the core class, but then my changes would be dependent on code that resides outside of the new custom module for my feature and IMO this is bad practice.

I understand Magento 1.x is outdated at this point and doesn't have all the features of Magento 2 but I would like to know if this is possible.

In Magento 2 I could do something like this:

<!--  File: app/etc/di.xml -->
<config>
    <preference for="Magento\Core\Model\UrlInterface" type="Magento\Core\Model\Url" />
</config>

Is this feature possibly to duplicate at all in Magento 1.9.x?

0

The short answer is no.

If you are overriding core functionality in m1 and want to add code that is dependent on another extension safely the only thing I can suggest is wrapping code in if blocks

if(Mage::helper('core')->isModuleEnabled('MyCompany_MyModule')) {

  • I ended up following this link and it worked great. – domdambrogia Jun 5 '19 at 0:14
  • 1
    I misunderstood what you meant. Yes overriding is possible in m1. You can either do it as part of an extension or a local override. You can overide all public methods without too much trouble. Private methods involve more planning. Same as M2. I thought you wanted a preference mechansim which wasn't interrupted if another hard dependant extension was disabled. – Dominic Xigen Jun 5 '19 at 1:12
  • The <rewrite> tag was exactly what I was after. Thanks for your insight though, it's always appreciated. – domdambrogia Jun 5 '19 at 1:14
  • Actually I can add something useful to this. Try overriding the same class but different methods in two different extensions. You will get a conflict and only one is used. Its useful to know how to resolve conflicts marketplace.magento.com/alekseon-modules-conflict-detector.html – Dominic Xigen Jun 5 '19 at 1:21

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.