Copied to clipboard

Flag this post as spam?

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


  • Gavin Semple 21 posts 93 karma points
    Jun 20, 2016 @ 04:25
    Gavin Semple
    0

    Error upon Customer Registration using FastTrack

    Getting the following error straight after registering a new customer:

    Unable to cast object of type 'Merchello.Core.Models.AnonymousCustomer' to type 'Merchello.Core.Models.ICustomer'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.InvalidCastException: Unable to cast object of type 'Merchello.Core.Models.AnonymousCustomer' to type 'Merchello.Core.Models.ICustomer'.
    
    Source Error:
    
    
    Line 7:     Layout = "Master.cshtml";
    Line 8:  
    Line 9:      var customer = (ICustomer)CurrentCustomer;
    Line 10: }
    Line 11: 
    
    
    Source File: ---\Views\Account.cshtml    Line: 9
    

    I can see in the Backoffice Members section that the Customer is getting created and assigned to the Customers group successfully. It appears as though the new customer is not identified as belonging to the Customers group when they're first created and redirected to the Account page.

    Anyone else getting this error? (Using V2.1.0 and FastTrack).

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jun 20, 2016 @ 12:31
    Rusty Swayne
    0

    Hey Gavin,

    Are you using a MemberType MerchelloCustomer (aliased "merchelloCustomer") and the Member Group ("Customer")

    The Account page by default should also be role based and require the Customer group.

  • Gavin Semple 21 posts 93 karma points
    Jun 21, 2016 @ 04:34
    Gavin Semple
    0

    Hi Rusty,

    I am using the default FastTrack configuration. It has one minor difference to what you've mentioned above, which is the Member Group name is "Customers" as opposed to "Customer".

  • Trevor Loader 199 posts 256 karma points
    Aug 03, 2016 @ 21:37
    Trevor Loader
    0

    Hey Gavin, Did you ever figure this out? I'm getting the same issue with Fast Track out of the box.

  • Gavin Semple 21 posts 93 karma points
    Aug 04, 2016 @ 02:48
    Gavin Semple
    0

    I didn't unfortunately. That was just 1 of several hurdles I encountered when evaluating Merchello. In the end I decided that trying to get Merchello to do everything I wanted was going to be too steep a learning curve for me at present, so went back to using nopCommerce for the time being.

    Sorry I couldn't be of more help.

  • Lee 1130 posts 3088 karma points
    Aug 04, 2016 @ 05:53
    Lee
    0

    If you are using a custom MemberType then you need to update the Merchello.Config to know about it.

    <customer memberTypes="customer,Customer,merchelloCustomer,MerchelloCustomer" /> 
    
  • Trevor Loader 199 posts 256 karma points
    Aug 05, 2016 @ 01:58
    Trevor Loader
    1

    Hey Lee,

    It's now working fine.

    It wasn't the MemberType or a config issue...it seemed to be corrupt Merchello customer data.

    I deleted the member record and delete the corresponding customer records from the database and re-registered via Fast Track and it'll all sprung into life again.

    Thanks, T

  • xrisdoc 54 posts 102 karma points
    Jan 16, 2017 @ 17:22
    xrisdoc
    0

    Hello,

    I too have been experiencing this issue. This seems to happen when I am redirected to the Account page on a successful login.

    It seems to be occurring within the following file:

    Merchello.Web.Store\Controllers\CustomerMembershipController.cs Line: 31
    
    var customer = (ICustomer)CurrentCustomer;
    

    Specifically, It seems to be when CurrentCustomer is being cast to ICustomer.

    Also, this only seems to occur when the "merchello" cookie is not present.

    When I login and the "merchello" cookie is present, I do not encounter this error.

    But, if I logout and delete the "merchello" cookie, and then attempt to login again, this is when I encounter the error.

    My site is completely locked down and the first page users will see is the login screen as no other part of the site should be accessible unless the user is logged in. So, when users first come to the site, there will be no "merchello" cookie present, or at least this isn't currently being created at this point.

    Is there any reason why the "merchello" cookie is not being created, when one doesn't currently exists? And is there a way that I can ensure that the "merchello" cookie has been created containing the relevant value?

    I am using the FastTrack starter kit, pretty much untouched in terms of the membership stuff (i.e. login form and account page).

    Thanks,

    Chris

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 16, 2017 @ 17:38
    Rusty Swayne
    0

    Hi Chris,

    The CustomerContext needs to be instantiated at least to add the customer cookie. You can change your initial view you inherit from

       Merchello.Web.Mvc.MerchelloViewPage<[YOUR_MODEL]>
    

    This will instantiate the CustomerContext for you.

  • xrisdoc 54 posts 102 karma points
    Jan 17, 2017 @ 10:11
    xrisdoc
    1

    Hi Rusty,

    Thanks for that, thats seems to have pointed me in the correct direction I think.

    I was using Umbraco.Web.Mvc.UmbracoTemplatePage on my Layout view, being used by my Login page, instead of Merchello.Web.Mvc.MerchelloTemplatePage, but that in itself didn't fix the issue.

    It wasn't until I had called CurrentCustomer.Basket() within the view that it then created the "merchello" cookie.

    So, it seems to be all sorted now by calling that.

    Thanks again for your help.

    Chris

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jan 17, 2017 @ 18:07
    Rusty Swayne
    0

    Ah right - that makes sense as there it populates the private _currentCustomer when it is first required and it's that class that manages the cookie.

  • Stuart 11 posts 34 karma points
    Jun 21, 2018 @ 13:38
    Stuart
    0

    Make sure in Umbraco Members these exist

    Member Group = Customers Member Type = Merchello Customer

    see here https://skrift.io/articles/archive/how-to-quickly-add-ecommerce-to-your-existing-website/

    Once these are in place, use Umbraco Role Based on Account page, for customers. Should redirect automatically to login page then. (don't forget to set login page on role based selection).

Please Sign in or register to post replies

Write your reply to:

Draft