Skip to Content
0
Jun 18, 2019 at 11:01 AM

How to display customer id in email via context to vm file.

335 Views

Hi Concern, I want to display the customer ID in email generated. I had created the ForgottenUsernameEmailContext.java

 public class ForgottenUsernameEmailContext extends CustomerEmailContext
 {
     private CustomerData customerData;
 
     @Override
     public void init(final StoreFrontCustomerProcessModel storeFrontCustomerProcessModel, final EmailPageModel emailPageModel)
     {
         super.init(storeFrontCustomerProcessModel, emailPageModel);
         customerData = getCustomerConverter().convert(getCustomer(storeFrontCustomerProcessModel));
     }
     public CustomerData getCustomerData()
     {
         return customerData;
     }
 
 public void setCustomerData(final CustomerData customerData)
     {
         this.customerData = customerData;
     }}

And email-forgottenUserNameBody.vm file

messageSource=classpath:/bauschcore/messages/email-forgottenUserName_$lang.properties

macro(genHtmlLinkStartTag $url) #end #macro(genHtmlLinkEndTag) #end #macro(genHtmlLink $url $textColor $bodyContent) $bodyContent #end

 <head>
 </head>
 <body bgcolor="#ffffff"
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
     <tr>
         <td> </td>
     </tr>
     <tr>
         <td align="center" valign="top">
             <table width="610" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#fff">
                 <tr>
                     <td align="center" valign="top" bgcolor="#FFFFFF">
                         <table width="570" cellpadding="0" cellspacing="0" border="0" align="center">
                             <tr>
                                 <td valign="middle"> </td>
                             </tr>
                             <tr>
                                 <td valign="middle">
                                     ${ctx.cmsSlotContents.SiteLogo}
                                     <img src="${ctx.themeResourceUrl}/images/header_01.png" alt="" width="229" height="72" border="0" align="right" title="" />
                                 </td>
                             </tr>
                             <tr>
                                 <td height="30" align="right" valign="middle" bgcolor="#000000">
                                     <font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="${ctx.secureBaseUrl}/my-account"><font color="#FFFFFF">${ctx.messages.myAccount}</font></a> | <a href="${ctx.baseUrl}/store-finder"><font color="#FFFFFF">${ctx.messages.storeFinder}</font></a>   </font>
                                 </td>
                             </tr>
                             <tr>
                                 <td align="center" valign="middle"><a href="${ctx.baseUrl}" style="display:block; margin-top:10px;margin-bottom:10px;">${ctx.cmsSlotContents.TopContent}</a></td>
                             </tr>
                             <tr>
                                 <td> </td>
                             </tr>
                         
                             <tr>
                             <td>*******TESTING *************</td>
                             <b> ${ctx.displayName}  </b>
                             <b>Your UserId :  ${ctx.customer.customerId} </b>
                             <b> ${ctx.customerId}</b>                            
                                 
                             </tr>
                             
                             <tr>
                                 <td height="30" align="right" valign="middle" bgcolor="#000000">
                                     <font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="${ctx.baseUrl}"><font color="#FFFFFF">${ctx.messages.help}</font></a> | <a href="${ctx.messages.contactUsPage}"><font color="#FFFFFF">${ctx.messages.contactUs}</font></a> | <a href="${ctx.baseUrl}"><font color="#FFFFFF">${ctx.messages.termsAndCondition}</font></a>   </font>
                                 </td>
                             </tr>
                             <tr>
                                 <td> </td>
                             </tr>
                         </table>
                     </td>
                 </tr>
             </table>
         </td>
     </tr>
     <tr>
         <td> </td>
     </tr>
 </table>


` I am able to trigger the mail but I am unable to get the Customer id ie Email id of customer.

Is anyone help me on the same.