2

How to override private function in model. If anyone knows please explain me

7
  • you can override model file using preference and update your function. 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 M
    Nov 9, 2017 at 5:20
  • plz show your code for which file u want to override 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 M
    Nov 9, 2017 at 5:57
  • plz share it in your original post Nov 9, 2017 at 6:01

1 Answer 1

2

Private functions cannot be overridden in a child class. You can easily override public functions.

Not the answer you're looking for? Browse other questions tagged or ask your own question.