Reputation: 2752
I'm using noncommerce V2.6. So I try to add new product in admin panel. I enter all the data and then click Save button or save and continue edit button.
The I have a error like this.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 546: //default product variant
Line 547: var variant = model.FirstProductVariantModel.ToEntity();
Line 548: variant.ProductId = product.Id;
Line 549: variant.Published = true;
Line 550: variant.DisplayOrder = 1;
My code is below which has error..
var variant = model.FirstProductVariantModel.ToEntity();
variant.ProductId = product.Id;
variant.Published = true;
variant.DisplayOrder = 1;
variant.CreatedOnUtc = DateTime.UtcNow;
variant.UpdatedOnUtc = DateTime.UtcNow;
_productService.InsertProductVariant(variant);
FirstVariant_UpdateLocales(variant, model.FirstProductVariantModel);
How can I slove it..
Plz help... Thankx
Upvotes: 0
Views: 769
Reputation: 1903
For that product you must add one product variant under Default product variant info tab
Upvotes: 1