EasyAbp/EShop

Can't build store product view for new product

Closed this issue · 3 comments

yqszt commented

I try to run EShop sample, and try to create a new product, then i found an error like that:

[17:47:34 ERR] Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.MinBy[TSource,TKey](IEnumerable1 source, Func2 keySelector, IComparer1 comparer) at System.Linq.Enumerable.MinBy[TSource,TKey](IEnumerable1 source, Func2 keySelector) at EasyAbp.EShop.Products.Products.ProductViewAppService.GetCacheDurationOrNullAsync(List1 productViews, DateTime now)
at EasyAbp.EShop.Products.Products.ProductViewAppService.BuildStoreProductViewsAsync(Guid storeId)
at EasyAbp.EShop.Products.Products.ProductViewAppService.GetListAsync(GetProductListInput input)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync()
at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope)
at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed)
at lambda_method4325(Closure, Object)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
[17:47:34 INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
[17:47:34 INF] Executed action EasyAbp.EShop.Products.Products.ProductViewController.GetListAsync (EasyAbp.EShop.Products.HttpApi) in 995.6593ms
[17:47:34 INF] Executed endpoint 'EasyAbp.EShop.Products.Products.ProductViewController.GetListAsync (EasyAbp.EShop.Products.HttpApi)'

The root cause is missing sku for new product when fill price with real price.
I try to fix it with an empty ProductViewDiscountModels, is it a right way?
image

Hi, I guess you are upgrading from the old version EShop.

image

The exception you got may cause by these two columns with null values. Please try to truncate the ProductView table, and the newly generated entities are expected to be [] if the discount info is empty.

yqszt commented

Hi, I guess you are upgrading from the old version EShop.

image

The exception you got may cause by these two columns with null values. Please try to truncate the ProductView table, and the newly generated entities are expected to be [] if the discount info is empty.

Hello, It not this issue, actually i'm using the latest version from dev, i just change database to Mysql, and i checked the logic that how to build the product view, firstly create a product info, and when i first get a list of product, the program would be bulid a product view entity and store cache it through the BuildStoreProductViewsAsync method.
image
This method build product view from product entity not product view entity. so the root cause is here, when product mapping to product view, the ProductDiscounts property should be null.
image
and then, the program to fill the real price to the product view, the real price come from sku info. but the new one does't have any sku info, so there is no any process logic for this view, the ProductDiscounts property still null.
image
finally the null value store to database, and application throw a NullReferenceException.
image

Well, I see now. I will fix this problem. Thank you for reporting this.