Try our conversational search powered by Generative AI!

Wishlist for AD Users

Vote:
 

Hi, 

Looking for a quick suggestion and confirmation.

We are doing an MVP site for a client base on http://commerce75.demo.episerver.com/ version 7.5.394.2.

Where Client is looking for their AD Users to use the Wishlist functionality. That didn't work, It is working fine for SQL Users. I investigated further and found CartHelper class is taking Contact From OrderContext Classes and for AD Users every time we are getting a new Contact ID for AD Users (AD Users doesnot have a Contact created).

We need to find some best solution for AD users.

My first option will be to create a contact object for a AD Users whenever it gets login.
OR write CustomCartHelper class to meet with custom requirement in any case I will require to creae a contact object for AD Users.

Regards

Khurram

#141970
Nov 25, 2015 11:21
Vote:
 

Hi,

Apologize for answering my own question. None of provider do this for us, we have to add this at time of registration or on login.

public void SetCustomerContact(string userName)
        {
            var currentUser = this.userProfileRepository.GetUserProfile(snUser);
            
            var user = System.Web.Security.Membership.GetUser(userName);
            if (currentUser != null && user != null)
            {
                var customerContact = CustomerContext.Current.GetContactForUser(user);
                if (customerContact == null || customerContact.PrimaryKeyId == Guid.Empty)
                {
                    // Now create an account in the ECF 
                    customerContact = CustomerContact.CreateInstance(user);
                }

                if (customerContact == null)
                {
                    return;
                }

                    customerContact.FirstName = currentUser.FirstName;
                    customerContact.LastName = currentUser.LastName;
                customerContact.RegistrationSource = String.Format("{0}", SiteContext.Current);                    customerContact["Email"] = user.Email;
                
                customerContact.SaveChanges();
            }
#142225
Dec 04, 2015 18:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.