Copied to clipboard

Flag this post as spam?

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


  • William Zhang 39 posts 243 karma points
    Feb 21, 2016 @ 10:54
    William Zhang
    0

    Product listing can't load after adding product content type

    Hi,

    I'm having some trouble with the product content type feature. I've created a new Product Content Type based on a document type with no template, and once I associate it with a product, the entire product listing (All Products) crashes when fetching products from /umbraco/backoffice/Merchello/ProductApi/SearchProducts. I get the following exception:

    {
        "exceptionMessage": "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.",
        "exceptionType": "System.InvalidOperationException",
        "innerException": {
            "exceptionMessage": "Object reference not set to an instance of an object.",
            "exceptionType": "System.NullReferenceException",
            "message": "An error has occurred.",
            "stackTrace": "
                at Merchello.Web.Models.ContentEditing.ExamineDisplayExtensions.GetProductVariantDetachedContentDisplayCollection(SearchResult result, String alias)\r\n
                at Merchello.Web.Models.ContentEditing.ExamineDisplayExtensions.ToProductVariantDisplay(SearchResult result)\r\n
                at Merchello.Web.Search.CachedProductQuery.PerformMapSearchResultToDisplayObject(SearchResult result)\r\n
                at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n
                at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)\r\n
                at Merchello.Web.Search.CachedProductQuery.GetDisplayObject(Guid key)\r\n
                at Merchello.Web.Search.QueryResultFactory`1.<BuildQueryResult>b__2(Guid x)\r\n
                at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n
                at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
                at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
                at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n
                at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n
                at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
                at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
                at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n
                --- End of stack trace from previous location where exception was thrown ---\r\n
                at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
                at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
                at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()"
        },
        "message": "An error has occurred.",
        "stackTrace": null
    }
    

    However, everything starts working again if I remove the product content type. Does anyone have a clue of what could be causing this? I'm running Umbraco 7.3.5 and Merchello 1.14.1.

  • William Zhang 39 posts 243 karma points
    Feb 21, 2016 @ 12:55
    William Zhang
    100

    Just realized this was my fault - I had defined a camel case contract resolver globally in my Global.asax.cs file. This also caused all the product content type JSON to be camel cased, which in turn caused the GetProductVariantDetachedContentDisplayCollection() to not be able to correctly deserialize the detached properties data.

  • Lee 1130 posts 3088 karma points
    Feb 22, 2016 @ 10:33
    Lee
    1

    Great. Could you mark your answer as resolved please.

Please Sign in or register to post replies

Write your reply to:

Draft