Unable to override account creation email template












1














I need to modify the welcome email sent to user upon new account creation. I need to do this in my custom module. I tried to override the function sendNewAccountEmail in MagentoCustomerModelCustomer using preference method and also using plugin method. Both were not working.



For preference method I added the following



In Vendor/Module/etc/di.xml




Added Customer.php file in the location VendorModuleModelCustomer and added the following code



public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
echo "It's Working";exit;
$types = $this->getTemplateTypes();

if (!isset($types[$type])) {
throw new MagentoFrameworkExceptionLocalizedException(
__('Please correct the transactional account email type.')
);
}

if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}

$this->_sendEmailTemplate(
$types[$type],
'customname/email/account_email_template',
['customer' => $this, 'back_url' => $backUrl, 'store' => $this->getStore()],
$storeId
);

return $this;
}


Still it's not taking the Customer.php file in the module.




echo "It's Working"; is not displaying.




Please advise the correct method to follow. I tried the plugin method also. It's also not working.










share|improve this question






















  • You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
    – Pritam Info 24
    yesterday










  • @Pritam I need to override email template in my custom module not in admin area..
    – DEEPESH KUMAR R
    yesterday










  • Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
    – Pritam Info 24
    yesterday












  • @PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
    – DEEPESH KUMAR R
    yesterday
















1














I need to modify the welcome email sent to user upon new account creation. I need to do this in my custom module. I tried to override the function sendNewAccountEmail in MagentoCustomerModelCustomer using preference method and also using plugin method. Both were not working.



For preference method I added the following



In Vendor/Module/etc/di.xml




Added Customer.php file in the location VendorModuleModelCustomer and added the following code



public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
echo "It's Working";exit;
$types = $this->getTemplateTypes();

if (!isset($types[$type])) {
throw new MagentoFrameworkExceptionLocalizedException(
__('Please correct the transactional account email type.')
);
}

if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}

$this->_sendEmailTemplate(
$types[$type],
'customname/email/account_email_template',
['customer' => $this, 'back_url' => $backUrl, 'store' => $this->getStore()],
$storeId
);

return $this;
}


Still it's not taking the Customer.php file in the module.




echo "It's Working"; is not displaying.




Please advise the correct method to follow. I tried the plugin method also. It's also not working.










share|improve this question






















  • You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
    – Pritam Info 24
    yesterday










  • @Pritam I need to override email template in my custom module not in admin area..
    – DEEPESH KUMAR R
    yesterday










  • Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
    – Pritam Info 24
    yesterday












  • @PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
    – DEEPESH KUMAR R
    yesterday














1












1








1


1





I need to modify the welcome email sent to user upon new account creation. I need to do this in my custom module. I tried to override the function sendNewAccountEmail in MagentoCustomerModelCustomer using preference method and also using plugin method. Both were not working.



For preference method I added the following



In Vendor/Module/etc/di.xml




Added Customer.php file in the location VendorModuleModelCustomer and added the following code



public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
echo "It's Working";exit;
$types = $this->getTemplateTypes();

if (!isset($types[$type])) {
throw new MagentoFrameworkExceptionLocalizedException(
__('Please correct the transactional account email type.')
);
}

if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}

$this->_sendEmailTemplate(
$types[$type],
'customname/email/account_email_template',
['customer' => $this, 'back_url' => $backUrl, 'store' => $this->getStore()],
$storeId
);

return $this;
}


Still it's not taking the Customer.php file in the module.




echo "It's Working"; is not displaying.




Please advise the correct method to follow. I tried the plugin method also. It's also not working.










share|improve this question













I need to modify the welcome email sent to user upon new account creation. I need to do this in my custom module. I tried to override the function sendNewAccountEmail in MagentoCustomerModelCustomer using preference method and also using plugin method. Both were not working.



For preference method I added the following



In Vendor/Module/etc/di.xml




Added Customer.php file in the location VendorModuleModelCustomer and added the following code



public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
echo "It's Working";exit;
$types = $this->getTemplateTypes();

if (!isset($types[$type])) {
throw new MagentoFrameworkExceptionLocalizedException(
__('Please correct the transactional account email type.')
);
}

if (!$storeId) {
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}

$this->_sendEmailTemplate(
$types[$type],
'customname/email/account_email_template',
['customer' => $this, 'back_url' => $backUrl, 'store' => $this->getStore()],
$storeId
);

return $this;
}


Still it's not taking the Customer.php file in the module.




echo "It's Working"; is not displaying.




Please advise the correct method to follow. I tried the plugin method also. It's also not working.







magento2 magento-2.1 overrides






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









DEEPESH KUMAR R

579




579












  • You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
    – Pritam Info 24
    yesterday










  • @Pritam I need to override email template in my custom module not in admin area..
    – DEEPESH KUMAR R
    yesterday










  • Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
    – Pritam Info 24
    yesterday












  • @PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
    – DEEPESH KUMAR R
    yesterday


















  • You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
    – Pritam Info 24
    yesterday










  • @Pritam I need to override email template in my custom module not in admin area..
    – DEEPESH KUMAR R
    yesterday










  • Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
    – Pritam Info 24
    yesterday












  • @PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
    – DEEPESH KUMAR R
    yesterday
















You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
– Pritam Info 24
yesterday




You can try Admin Panel Email template setting from Marketing ->Email Template -> Add New Template
– Pritam Info 24
yesterday












@Pritam I need to override email template in my custom module not in admin area..
– DEEPESH KUMAR R
yesterday




@Pritam I need to override email template in my custom module not in admin area..
– DEEPESH KUMAR R
yesterday












Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
– Pritam Info 24
yesterday






Can you use your custom (assume you using a custom theme ) them instead of any custom module for this customization task?
– Pritam Info 24
yesterday














@PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
– DEEPESH KUMAR R
yesterday




@PritamInfo24 Actually this is custom module, sorry its not possible to use custom theme..
– DEEPESH KUMAR R
yesterday










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256748%2funable-to-override-account-creation-email-template%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f256748%2funable-to-override-account-creation-email-template%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

An IMO inspired problem

Management

Has there ever been an instance of an active nuclear power plant within or near a war zone?