Copied to clipboard

Flag this post as spam?

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


  • MB 273 posts 936 karma points
    Nov 22, 2021 @ 10:55
    MB
    0

    Variants not available

    Hi all,

    I'm adding multiple variants to my products and encountering an issue I can't seem to find a solution for (hence I'm here)....

    So, when I go to a product it will by default show "Variant not available". I can choose any variant in any combination I'd like.

    The console error I get is:

    Server Error 500
    XHRPOSThttps://localhost:44381/umbraco/api/productapi/getproductvariant
    

    I have setup my Multiple Variant Page just like the Vendr Demo page.

    Any idéa why the product variants can be shown but it shows the "Variant not available" message and it allows for any combination to be added?

    Thanks!

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Nov 22, 2021 @ 11:19
    Matt Brailsford
    1

    Hi MB,

    Could you check your Umbraco instances trace log to see what the 500 error is? Or, look in your browsers dev tools to see if it has more info.

    It looks like your GetProductVariant API controller isn't working. It's not clear which version of Umbraco / Vendr / Vendr Demo Store you are using so I can't point you to the right bit of code to check, but make sure you have the ProductApiController copied over and tested from the demo store.

    Hope that helps

    Matt

  • MB 273 posts 936 karma points
    Nov 22, 2021 @ 11:43
    MB
    0

    Hi Matt!

    I'm using:

    • Umbraco 8.15.0
    • Vendr 1.8.6

    My logs don't report anything related to the ProductVariant API. I checked out the Demo Store and copied the ProductVariantAPI from Web/Controllers/ProductApiController and build my project.

    The response error on the frontpage tells me:

        XHRPOSThttps://localhost:44381/umbraco/api/productapi/getproductvariant
    [HTTP/2 500 Internal Server Error 3ms]
    
    
    Message "An error has occurred."
    ExceptionMessage    "Value cannot be null.\r\nParameter name: mediaItem"
    ExceptionType   "System.ArgumentNullException"
    StackTrace  " at Umbraco.Web.ImageCropperTemplateCoreExtensions.GetCropUrl(IPublishedContent mediaItem, IImageUrlGenerator imageUrlGenerator, ImageCropperValue localCrops, Boolean localCropsOnly, Nullable`1 width, Nullable`1 height, String propertyAlias, String cropAlias, Nullable`1 quality, Nullable`1 imageCropMode, Nullable`1 imageCropAnchor, Boolean preferFocalPoint, Boolean useCropDimensions, Boolean cacheBuster, String furtherOptions, Nullable`1 ratioMode, Boolean upScale) in D:\\a\\1\\s\\src\\Umbraco.Web\\Image…ccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\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.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
    

    And the request data:

        XHRPOSThttps://localhost:44381/umbraco/api/productapi/getproductvariant
    [HTTP/2 500 Internal Server Error 3ms]
    
    
        productNodeId   "1552"
        attributes[0][key]  "bikesize"
        attributes[0][value]    "bikexxsmall"
        attributes[1][key]  "color"
        attributes[1][value]    "red"
    

    I hope this helps. I've done what I can to follow the demo page.

  • Matt Brailsford 4123 posts 22194 karma points MVP 9x c-trib
    Nov 22, 2021 @ 11:47
    Matt Brailsford
    100

    Ok, so the error is really telling you what the issue is.

    Looks like the ProductApiController here https://github.com/vendrhub/vendr-demo-store/blob/v1/main/src/Vendr.DemoStore/Web/Controllers/ProductApiController.cs#L49-L50 assumes that an image must always be defined. My guess is one or more of your variants don't have an image defined on them.

    You'll either need to make sure your variants have images defined, or change the code on those two lines to check to see if an image is defined before calling GetCropUrl on them.

    Hope this helps

    Matt

  • MB 273 posts 936 karma points
    Nov 22, 2021 @ 11:54
    MB
    0

    Matt... Thank you! That was exactly the problem. I learn more and more everytime I reach out to you so thank you!

    It is rather time consuming to upload the same image to multiple variants but it'll work :)

    The shop is getting somewhere. Looking forward to purchasing a license when it's done.

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft