How to override private function in model. If anyone knows please explain me
-
you can override model file using preference and update your function.– Rakesh JesadiyaCommented Nov 9, 2017 at 5:18
-
yes.i follow your instruction .But it only override public function in that class.I want to override private function.wt can i do– Mahi MCommented Nov 9, 2017 at 5:20
-
plz show your code for which file u want to override– Rakesh JesadiyaCommented Nov 9, 2017 at 5:55
-
<?php namespace Maha\CreateLastname\Model\ResourceModel; //use Magento\Customer\Model\Address as CustomerAddressModel; class AddressRepository extends \Magento\Customer\Model\ResourceModel\AddressRepository { protected function _validate(CustomerAddressModel $customerAddressModel) { echo "Model Rewrite Working"; die(); } } i can't override private fun in above code in my module– Mahi MCommented Nov 9, 2017 at 5:57
-
plz share it in your original post– Rakesh JesadiyaCommented Nov 9, 2017 at 6:01
|
Show 2 more comments
1 Answer
Private functions cannot be overridden in a child class. You can easily override public functions.