0

As title suggest i want to override Mage_Payment_Model_Method_Abstract class , I know that it is abstract class. and we can easily override abstract class using local directory like app\code\local\Mage\Payment\Model\Method\Abstract.php. But i want to know is there any other option for me ? Because this option is not safe with different magento version.

Any help will be appreciated.

Thank you

1

For abstract classes, there is not other way to rewrite them, other than copying them to the local folder.
The abstract classes are never instantiated and you can rewrite only the classes that get instantiated.

To go a little more technical, you can rewrite only the classes that are instantiated using factory methods like Mage::getModel, Mage::getSingleton, Mage::getResourceModel, Mage::app()->getLayout()->createBlock(), Mage::helper and so on.

The abstract classes are there just as a common ancestor for other classes.
Here is an example.

abstract class A {}
class B extends A{}
class C extends A {}

Even if you rewrite the class A using the standard way of rewriting, classes B and C will still extend the original class A so your rewrite is useless.
The only way you can change class A is to make the autoloader retrieve it from a different location.
That's why you need to move it to the local (or community folder).

you can get more info about this "issue" from here

  • is create any issue if i use this method different version of magento? @Marius – Keyur Shah Jun 6 '14 at 16:50
  • @KeyurShah. Well, there is the chance that on a future upgrade something will fail. But if something goes wrong at least you know where to look. – Marius Jun 6 '14 at 18:56
  • @Marius I am trying to override prepareSave function of Mage_Payment_Model_Method_Cc model but nothing is working for me. I followed magento.stackexchange.com/questions/172334/… this, it is working fine for isAvailable function but not working for prepareSave function. – Pradeep Singh Aug 18 '18 at 9:13

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.