Timeline for How to override private function in Model (Magento-2)
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 9, 2017 at 13:11 | comment | added | Mahi M | One more doubt,admin panel->allcustomer->edit->address....throw error last name is required field | |
Nov 9, 2017 at 9:58 | comment | added | MeenakshiSundaram R | Let us continue this discussion in chat. | |
Nov 9, 2017 at 9:57 | comment | added | Mahi M | $this->customValidate($addressModel);this func in save method.it does not call private function customValidate(CustomerAddressModel $customerAddressModel) | |
Nov 9, 2017 at 9:45 | comment | added | MeenakshiSundaram R |
remove the _validate() function from your class. Create a new function(customValidate ) and copy _validate function code into customValidate function and change the logic. After that inside save function call customValidate function.
|
|
Nov 9, 2017 at 9:42 | comment | added | Mahi M | it's throw ......Fatal error: Uncaught Error: Call to private method Magento\Customer\Model\ResourceModel\AddressRepository::_validate() | |
Nov 9, 2017 at 9:27 | comment | added | MeenakshiSundaram R | try my updated answer | |
Nov 9, 2017 at 9:26 | history | edited | MeenakshiSundaram R | CC BY-SA 3.0 |
added 480 characters in body
|
Nov 9, 2017 at 9:08 | comment | added | Mahi M | namespace Maha\CreateLastname\Plugin\Customer\Model\ResourceModel; class AddressRepository { public function save(\Magento\Customer\Api\Data\AddressInterface $address) { $this->_validate($addressModel); echo "save form";exit; } private function _validateCustom(CustomerAddressModel $customerAddressModel) { echo "Model"; } }..............But it's does not working | |
Nov 9, 2017 at 8:54 | comment | added | MeenakshiSundaram R | Don't use validate function create a new function(validateCustom) and call that( validateCustom) function inside save function | |
Nov 9, 2017 at 8:49 | comment | added | Mahi M | if anything changes in my code .I want the execution is go to validate function. | |
Nov 9, 2017 at 8:43 | comment | added | MeenakshiSundaram R |
is the execution is going into save function??
|
|
Nov 9, 2017 at 8:26 | comment | added | Mahi M | <?php namespace Maha\CreateLastname\Plugin\Customer\Model\ResourceModel; class AddressRepository { public function save() { echo "save form"; } private function _validate(CustomerAddressModel $customerAddressModel) { echo "hi";exit; } } ?> | |
Nov 9, 2017 at 7:48 | comment | added | MeenakshiSundaram R | Can you update the question with the latest code which you tried | |
Nov 9, 2017 at 7:39 | comment | added | Mahi M | but it's not working.please explain code briefly | |
Nov 9, 2017 at 7:14 | history | answered | MeenakshiSundaram R | CC BY-SA 3.0 |