Magento – Overwrite Abstract class

magento2overrides

I am not able to overwrite the reorder.php file which is an abstract class. Anyone can help whether I have use di.xml or any other method.

Best Answer

As per The architecture followed by Magento, We can not rewrite any Abstract class. Rewriting a class means, instantiate the new class instead of old class. Since an abstract class is never instantiated, it can never be rewritten.

To solve this issue, you can check for the actual class that is extending the abstract class. Rewrite the child class and override any property in your newly created class.

For example, suppose a class named A extends an abstract class B and defined any function/property here in A. you can rewrite the class A with C and override function/property in your class C.

This is how you can achieve your goal.

Related Topic