cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get customer data from email URL hit by customer

Former Member
0 Likes
746

Hi experts,

I am sending registration successful email. There I have to implement newsletter unsubscribe functionality just by clicking one URL from mail. So when the customer clicks on the unsubscribe hyperlink/URL in the email, then I need to get the customer data or customer email in hybris back-end so that I can check its availability in hybris DB an remove it from newsletter table. Can you please guide me how to get the customer data from emails URL hits?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi Abhinandan

I think a better way is to generate a uuid using UUID class in java.util package. Save the UUID in your DB and send an email to customer with an unsubscribe link as
www.xyz.com/email/unsubscribe/<your unique UUID>

then create a controller class with

 @Controller
 @RequestMapping("/email/unsubscribe") 
 public class EmailUnsubscribeController
 {
   @RequestMapping("/{uuid}")
   public void unsubscribe(@PathVariable String uuid) 
   { 
      CustomerModel customer = (CustomerModel)userService.getUserForUUID(uuid);
       customer.setSubscription(false);
       modelService.save(customer);
   }
 }

It is not a good idea to access service layer in controller, so use the facade-service pattern that hybris uses out of the box. This code snippet was just for the illustration purposes.

the idea is to use a random UUID in emails for these kind of task me know how you go.

Former Member
0 Likes

Thanks a lot for your reply. That's a good approach. I will pass the UUID of the customer from email context in the email. Then I will follow your steps. Thanks a lot.

Answers (0)