Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jan A 59 posts 264 karma points
    Aug 20, 2018 @ 07:26
    Jan A
    0

    Customer missing for member

    I've taken over an old merchello site (v 1.7 i think). The problem is that the documentation only covers from 1.13.1 on their site and I can't upgrade it at the moment.

    The problem is that when some of the merchello customers was deleted some time ago, the members was not. So now when a member signs in (we are just checking member) and the code tries to get the address for the merchello customer we get an error.

    What I want to do is to do a fix for this, and when the user logs in I check if the merchello customer entity exist and if not, creates one. I'm guessing this is done somewhere but I can't seem to find it.

    When we create a new member we do this

            var user = this.memberService.CreateWithIdentity(email, email, password, MemberTypes.Customer);
    
            this.memberService.SavePassword(user, password);
            var customer = this.merchelloContext.Services.CustomerService.GetByLoginName(email);
            var region = new RegionInfo(this.requestLanguage.Culture.LCID);
            var destination = new Address() {
                Name = email,
                Address1 = string.Empty,
                Address2 = string.Empty,
                Locality = string.Empty,
                Region = string.Empty,
                PostalCode = string.Empty,
                CountryCode = region.Name,
            };
            customer.CreateCustomerAddress(destination, "defaultBilling", AddressType.Billing);
            this.merchelloContext.Services.CustomerService.Save(customer);
    

    And I figure that the merchello customer is created when the member is (?)

    How should I check if the merchello customer exists (best practice) and how do I create it if it's missing?

Please Sign in or register to post replies

Write your reply to:

Draft