1

I tried to override addAddressByType() function in Magento\Framework\Mail\Template\TransportBuilder but I can't override this function only as it is a private function.

Then I tried to override whole class but getting the below error.

1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Customer\Model\Customer\Interceptor

Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Customer\Model\Customer\Interceptor
<pre>#1 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#2 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#3 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#4 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Customer...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#5 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:150]
#6 Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/Factory/Compiled.php:79]
#7 Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Weee\Mod...') called at [vendor/magento/framework/ObjectManager/ObjectManager.php:70]
#8 Magento\Framework\ObjectManager\ObjectManager->get('Magento\Weee\Mod...') called at [vendor/magento/framework/Interception/PluginList/PluginList.php:250]
#9 Magento\Framework\Interception\PluginList\PluginList->getPlugin('Ranosys\Subscrib...', 'weee-app-action-...') called at [vendor/magento/framework/Interception/Interceptor.php:119]

Please help to share your suggestions if there is any other better approach.

1

Copy your vendor file from this location

vendor/magento/framework/Mail/Template/TransportBuilder.php

and then paste that here

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

and change whatever function in this file.

Hope this will work for you!

9
  • Got this error PHP Fatal error: Cannot declare class Vendor\Module\Mail\Template\TransportBuilder, because the name is already in use in /opt/lampp/htdocs/magento-project/app/code/Vendor/Module/Model/Mail/Template/TransportBuilder.php on line 431 Nov 22 '19 at 11:31
  • I've updated my answer please review Nov 22 '19 at 12:08
  • Let me know if it will work for you then. Nov 22 '19 at 12:37
  • Thanks @Kishan, it worked ! could you help to elaborate it ? Nov 22 '19 at 12:38
  • Yes, Let me know. Approve my answer as well. Thanks.:) Nov 22 '19 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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