0

if i change template text from admin panel and use that email template in custom email then email is sending but it shows old data only not showing my text even after it is saved in database.

    $alltemplele = $this->_objectManager->get('\Magento\Email\Model\Template')->load(7);
$emailTemplate = $alltemplele->getData('orig_template_code');

$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
$transport = $this->_transportBuilder
// ->setTemplateIdentifier('send_email_email_template') // this code we have mentioned in the email_templates.xml
  ->setTemplateIdentifier($emailTemplate)
  ->setTemplateOptions(
[
'area' => \Magento\Framework\App\Area::AREA_FRONTEND, // this is using frontend area to get the template file
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
]
  )
  ->setTemplateVars(['data' => $postObject])
  ->setFrom($sender)
  ->addTo('[email protected]','paras')
  ->getTransport();
  $transport->sendMessage();

Can anyone help me how can I get latest text or changes in email template?

Any help would be appreciated.

Thanks In advance..!

this is my admin template content : {{template config_path="design/email/header_template"}}

{{trans "Custom Email for subcription"}}

{{template config_path="design/email/footer_template"}}

5
  • may I know what is the email template you are editing.
    – Venkatesh
    Commented Nov 22, 2019 at 9:22
  • i am adding new email template for subscription sucess but it is showing old string i.e. "You have been successfully subscribed to our newsletter". and i have updated like "Custom string" in database. Commented Nov 22, 2019 at 9:54
  • add code for $postObject where this variable come from Commented Nov 22, 2019 at 10:02
  • my problem is ,the string is not changing its showing old string in email i.e. "You have been successfully subscribed to our newsletter". but i want it should be "Custom string" it is saved in database but still getting old msg Commented Nov 22, 2019 at 10:12
  • {{template config_path="design/email/header_template"}} {{trans "Custom Email for subcription"}} {{template config_path="design/email/footer_template"}} this is my template content from admin->marketing->templates. but i should get the message what i have provided i.e. "Custom Email for subcription" but iam getting "You have been successfully subscribed to our newsletter." from where iam getting this message. plz help Commented Nov 22, 2019 at 12:47

1 Answer 1

0

Suggestions for you:

  • Check if the cache is making you a problem.
  • Make sure that the correct email template is selected.
  • Add some changes to the email templates from the Magento_Sales module and see if there is a change in the email. (This is just for debugging.)
5
  • i am adding new email template for subscription sucess but it is showing old string i.e. "You have been successfully subscribed to our newsletter". and i have updated like "Custom string" in database. Commented Nov 22, 2019 at 9:56
  • i tried all these thinks but not works Commented Nov 22, 2019 at 9:57
  • Do you have multiple stores? If yes, maybe you should set template for a correct store.
    – brnnzol
    Commented Nov 22, 2019 at 10:22
  • no i am using default store only Commented Nov 22, 2019 at 12:28
  • {{template config_path="design/email/header_template"}} {{trans "Custom Email for subcription"}} {{template config_path="design/email/footer_template"}} this is my template content from admin->marketing->templates. but i should get the message what i have provided i.e. "Custom Email for subcription" but iam getting "You have been successfully subscribed to our newsletter." from where iam getting this message. plz help Commented Nov 22, 2019 at 12:51

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.