Posted on 10/12/2021 08:55:13
Hi Morten,
I found out it might have to do with our custom implementation of the product list.
Perhaps yu have a tip for me what to do.
I put a breakpoint in the FindPrice method again and found out that when I log in and get the user assortment (custom) I break having the user set in the price context correctly.
Then when I navigate to the product list page I break having the user to be NULL in the price context.
I pasted the stack from that moment below.
When I navigate to a product detail page I break having the user set in the price context correctly.
When I add to cart and go to the cart I break having the user set in the price context correctly.
When I went to a product list again I break having the user to be NULL again in the price context.
The product list page has a paragraph with a Product Catalog for ViewModel APP placed on it, all properties set to "Include all" for the moment.
But in the list view template we do some magic.
We pass the model to a method which returns a custom extended model, but it doesn't hit the FindPrice there!
When the template uses the extended model values to show the products and wants to show a price I break having the user to be NULL in the price context.
The object we iterate through is a List<MasterWithVariantsModel>
MasterWithVariantsModel is some master data, List<Dynamicweb.Ecommerce.Produts.Product> and some other lists
The list of Product is printed in the template along with data from the other lists.
Can you come up with any reason why the user would be NULL?
Stack:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at MyProject.Application.CustomCode.Providers.SapPriceProvider.FindPrice(PriceContext context, PriceProductSelection selection) in C:\Projects_GIT\MyProject\MyProject.Application\CustomCode\Providers\SapPriceProvider.cs:line 40
at Dynamicweb.Ecommerce.Prices.PriceManager.FindPriceInternal(PriceProvider provider, PriceContext context, PriceProductSelection selection, Boolean isInformative)
at Dynamicweb.Ecommerce.Prices.PriceManager.FindPrice(PriceContext context, PriceProductSelection selection, Boolean isInformative)
at Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(PriceContext context, Product product, String unitId, Int64 stockLocationId)
at Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(Product product, String currencyCode, String countryCode, String unitId, Int32 userId, String shopId, StockLocation stockLocation)
at Dynamicweb.Ecommerce.Products.Product.get_Price()
at CompiledRazorTemplates.Dynamic.RazorEngine_4ee06cad6eb44079b90bdfc6279bcc7d.Execute() in C:\Projects_GIT\MyProject\MyProject.Application\Files\Templates\Designs\MyProject\eCom\ProductCatalog\ProductViewListFacets.cshtml:line 218
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
at Dynamicweb.Rendering.Template.Output()
at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.RenderProductList(ProductCatalogSettings settings, String groupId, Boolean feed)
at Dynamicweb.Ecommerce.ProductCatalog.ProductCatalogFrontend.GetContent()
at Dynamicweb.Frontend.Content.GetModuleOutput(Paragraph paragraph, PageView pageview)
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_fdfe45703b2e4dcea800102ea60d653b.Execute() in C:\Projects_GIT\MyProject\MyProject.Application\Files\Templates\Designs\MyProject\Paragraph\ModuleOnly.cshtml:line 2
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
at Dynamicweb.Rendering.Template.Output()
at Dynamicweb.Frontend.Content.RenderParagraph(Paragraph paragraph, ContainerInfo containerInfo, Layout layout, GridColumnViewModel column)
at Dynamicweb.Frontend.Content.CreateContent(IList`1 paragraphs)
at Dynamicweb.Frontend.Content.CreateContent(Int32 contentId)
at Dynamicweb.Frontend.ContentViewModelFactory.CreatePageViewModel(PageView pageView)
at Dynamicweb.Frontend.PageView.SetPageTemplateValues()
at Dynamicweb.Frontend.PageView.Output()
at Dynamicweb.AspNet.DynamicwebHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)