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.
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()"
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.
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:
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!
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
Hi Matt!
I'm using:
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:
And the request data:
I hope this helps. I've done what I can to follow the demo page.
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
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!
is working on a reply...