In Magento 1 I could copy abstract class to local or community directory and Magento used it, when autoload load this class.
Is there some solution to make to Magento loads my class instead vendor/magento/framework/Model/AbstractModel.php
?
Preferences in di.xml
for abstract classes does not work. Plugins only?
Best Answer
Yes. You can write plugins for abstract classes and plugins should always be preferred over preferences if possible.
Preferences are useful if you want to replace an implementation. I can't think of a use case to replace the implementation for all models that extend
AbstractModel
, if that's even logically possible. So what you probably want is to add or change functionality and this is what plugins are for.