Magento 2 preference not working for Magento\Customer\Model\Metadata\Form\File
-
11-05-2021 - |
Question
I want to create preference for this file Magento\Customer\Model\Metadata\Form\File but its not working so please give some solution for this problem how to solve it
di.xml code
Solution
Your code looks correct. And if you instantiate the Magento\Customer\Model\Metadata\Form\File
you should get an instance of your own class.
But maybe it does not work for you because you are not using directly the class Magento\Customer\Model\Metadata\Form\File
.
I see that there is another class Magento\Customer\Model\Metadata\Form\Image
that extends the Magento\Customer\Model\Metadata\Form\File
. Maybe your code uses this Image
class and not the File
class.
If this is the case you need to create a preference for the image class to work because the Image class still extends the original File class and not your new clsss.