I'm trying to override a model class Customer.php, maybe I've configure it wrongly, this error occurs:
a:4:{i:0;s:316:"Recoverable Error: Argument 21 passed to Magento\Customer\Model\AccountManagement::__construct() must be an instance of Magento\Customer\Model\Customer, instance of Vendor\ModuleName\Model\Customer given in C:\xampp2\htdocs\magento2ce\vendor\magento\module-customer\Model\AccountManagement.php on line 263";i:1;s:9721:"#0 C:\xampp2\htdocs\magento2ce\vendor\magento\module-customer\Model\AccountManagement.php(263): Magento\Framework\App\ErrorHandler->handler(4096, 'Argument 21 pas...', 'C:\\xampp2\\htdoc...', 263, Array)
Here is my di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Customer\Model\Customer" type="Vendor\ModuleName\Model\Customer" />
</config>
I also tried using plugin, but failed too. when I use plugin, this error occurs:
Fatal error: Call to undefined method Magento\Customer\Model\ResourceModel\Customer::afterLoad() in C:\xampp2\htdocs\magento2ce\vendor\magento\framework\Model\AbstractModel.php on line 572
And my custom model class extended:
class Customer extends \Magento\Framework\Model\AbstractModel
Anyone can give me some ideas how to deal with it? Thanks