I am using Umbraco 7.5.11 and Merchello 2.5.0 with FastTrack.
I am experiencing significant slow loading (timed it to 23 sec load) on a page that uses mHelper.Query.Product.GetByKey(Model.Key); compared to mHelper.TypedProductContent(Model.Key); which is pretty much instant. The only reason I am using Query.Product is because it gives me access to product.DetachedContents that I need for accessing a product variant detached content for displaying specific product variant description. All my variants has their own unique description.
Is there any other way I can access DetachedContents ? Or any other way to display product variant specific description?
This is my code in Views/_ProductBox.cshtml
@inherits UmbracoViewPage<Merchello.Web.Models.VirtualContent.IProductContent>
@using Merchello.Core
@using Merchello.Web.Store.Controllers
@using Merchello.FastTrack.Ui
@using Merchello.Web
@{
var mHelper = new MerchelloHelper();
//var product = mHelper.TypedProductContent(Model.Key);
var product = mHelper.Query.Product.GetByKey(Model.Key);
var hasVariants = product.ProductVariants.Any();
var doesHaveDetachedContents = false;
var lastVariantID = "";
}
<div id="@Model.Key" class="product-box">
<div class="imageWrap">
@if (Model.HasValue("image"))
{
var mediaId = Model.GetPropertyValue<string>("image");
var image = Umbraco.TypedMedia(mediaId);
<img style="width:100%;" class="img-responsive" src="@image.GetCropUrl(400, 400)" alt="@Model.Name">
}
</div>
<div class="product-info">
<h3>@Model.Name</h3>
@if(hasVariants)
{
doesHaveDetachedContents = false;
foreach (var productVars in product.ProductVariants)
{
var getProductVariant = mHelper.Query.Product.GetProductVariantByKey(productVars.Key);
if (getProductVariant.DetachedContents.Any())
{
foreach (var item in getProductVariant.DetachedContents)
{
foreach (var dataValues in item.DetachedDataValues)
{
if (dataValues.Key == "brief")
{
if(!String.IsNullOrEmpty(dataValues.Value) || dataValues.Value != null)
{
if (lastVariantID.ToLower() != getProductVariant.Key.ToString().ToLower())
{
var productVarBrief = dataValues.Value.Trim().Replace("\"", "");
<div style="display:none;" class="productBriefDescription" id="@getProductVariant.Key">@Html.Raw(productVarBrief)</div>
doesHaveDetachedContents = true;
lastVariantID = getProductVariant.Key.ToString().ToLower();
}
}
}
}
}
}
}
if (!doesHaveDetachedContents)
{
@Model.GetPropertyValue("brief")
}
}
else
{
@Model.GetPropertyValue("brief")
}
@Html.Action("AddProductToBasketForm", "StoreBasket", new { area = "Merchello", model = Model })
</div>
</div>
I republished cache on all my nodes in Umbraco backoffice. What do you mean with build my models in the back office?
I get this error now:
Server Error in '/' Application.
Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model type Umbraco.Web.PublishedContentModels.FtStore.
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: Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model type Umbraco.Web.PublishedContentModels.FtStore.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model type Umbraco.Web.PublishedContentModels.FtStore.]
Umbraco.Web.Mvc.RenderModelBinder.ThrowModelBindingException(Boolean sourceContent, Boolean modelContent, Type sourceType, Type modelType) +639
Umbraco.Web.Mvc.RenderModelBinder.BindModel(Object source, Type modelType, CultureInfo culture) +248
Umbraco.Web.Mvc.UmbracoViewPage`1.SetViewData(ViewDataDictionary viewData) +180
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +99
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) +113
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +290
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +38
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +28
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9986301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2103.2
If you login to the back office and go to the developer tab you should be able to see models builder within the right hand frame. CLick on this and then click the red button titled Generate models.
MerchelloHelper Query.Product slow performance ( Product variant specific description )
Hello,
I am using Umbraco 7.5.11 and Merchello 2.5.0 with FastTrack.
I am experiencing significant slow loading (timed it to 23 sec load) on a page that uses mHelper.Query.Product.GetByKey(Model.Key); compared to mHelper.TypedProductContent(Model.Key); which is pretty much instant. The only reason I am using Query.Product is because it gives me access to product.DetachedContents that I need for accessing a product variant detached content for displaying specific product variant description. All my variants has their own unique description.
Is there any other way I can access DetachedContents ? Or any other way to display product variant specific description?
This is my code in Views/_ProductBox.cshtml
Best regards, Christian
Probably not the cause of it but worth checking, are you familiar with the models builder?
what have you got this set to in umbraco web.config?
Cheers
Hi David,
Thanks for snappy response!
I am not familiar with the models builder, but it is currently set to:
I would rule this out as a possible performance killer, has killed some of my sites in the past.
It something you should read up about if using Umbraco.
Try setting it to the following:
be sure to build your models in the back office once you have made the change.
Cheers
David
I republished cache on all my nodes in Umbraco backoffice. What do you mean with build my models in the back office?
I get this error now:
If you login to the back office and go to the developer tab you should be able to see models builder within the right hand frame. CLick on this and then click the red button titled Generate models.
Ah right - I did it and now no errors, but sadly no change in regards to loading time on that specific page with all my products on.
Have you tried commenting out the individual if statements and for loops to find the offending line of code?
I have found using the detachedContent a little problematic, I'm not happy with my solution but plan to rewrite it when I have more time.
I am using the following at the moment:
This is product options you are accessing and not detached content which is what I need that contains a product variants description :)
Yes I have found the offending line of code as stated in the subject line, but maybe I should of written that in the post.
This line alone without anything else causes severe loading times: var product = mHelper.Query.Product.GetByKey(Model.Key);
It does loop through alot of product variants though, but still should not be this slow
Bump... :(
is working on a reply...