This is my plugin:

namespace Vendor\Module\Plugin;

use Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate;

class MyPlugin
    public function afterExecute(DefaultTemplate $template, $result)
        $text = $template->getData('template_text');
        $text .= '<p>Custom Text</p>';
        $template->setData('template_text', $text);

Var dump works. Plugin executes, but I can't get why getData method is not found. Any suggestions?

  • You can use get_class_methods to check available methods for your $template object. Apr 2, 2019 at 8:23

1 Answer 1


You have done wrong.The original function execute() does have return @return **void** .So, for you $result is void type variable and also how you can $template variable as your return does not give any parameters like that?. and $template give Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate class object.

If you want $template variable data then you have to use

$template = $template->getRequest()->getParam('code');

Actually, You have to explain what you to achieve?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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