Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 07, 2014 @ 16:21
    Dennis Aaen
    0

    Catalog.cshtml throws an error on a category

    Hi

    I am working on my first uCommerce project. When I visit a category the Catalog.cshtml throws an error, the file contains this code, an example of a URL where the Catalog.cshtml fail could be: http://www.domain.com/store/partne/2.3-mw/c-26/c-75/

    @using UCommerce.EntitiesV2
    @using UCommerce.Extensions
    @using UCommerce.Runtime
    @using umbraco.MacroEngines
    @{
        Category category = SiteContext.Current.CatalogContext.CurrentCategory;
    }
    <div class="row-fluid">
        <div class="hero-unit">
            @if (!string.IsNullOrEmpty(category.ImageMediaId))
            {
                dynamic mediaItem = new DynamicMedia(category.ImageMediaId);
                <img src="@mediaItem.umbracoFile" alt="@category.DisplayName()" />
            }
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12 product-list">
            @* View /App_Code/uCommerce/Helpers/Review/Category.cshtml for this helper *@
            @uCommerce.Helpers.Category.DisplayCategoryProducts(category)
        </div>
    </div>
    

    File contains the basic code from the demo store, I have tried looking into the stack trace to see if I could get more information about why it give me and error.

    From the stack trace I get this:

    Error Loading Razor Script (file: Store Catalog) Object reference not set to an instance of an object. at ASP.PagemacroScriptsStoreCatalogcshtml.Execute() in d:\customer\macroScripts\Store\Catalog.cshtml:line 10 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) 0.334953 0.006805 macro Error loading MacroEngine script (file: /Store/Catalog.cshtml, Type: '' Object reference not set to an instance of an object. at ASP.PagemacroScriptsStoreCatalogcshtml.Execute() in d:\customer\macroScripts\Store\Catalog.cshtml:line 10 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage) at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) at umbraco.macro.loadMacroScript(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

    First I thought I got because I don´t have add an image to the category or a product.

    We are running Umbraco 4.11.10 and uCommerce 6.0.3.14141

    Any help will be appreciated.

    /Dennis

  • Martin 181 posts 740 karma points
    Jul 07, 2014 @ 17:54
    Martin
    0

    Hi Dennis,

    My guess would be that this line:

    @if(!string.IsNullOrEmpty(category.ImageMediaId))

    That causes problems. Try do a check for category is null. In case it's null throw an exception with a test message. That way you can easy track if its that line. Otherwise do you use Visual Studio? In that case you can actually debug it fairly easy that way.

    Best regards
    Martin 

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 08, 2014 @ 11:48
    Dennis Aaen
    0

    Hi,

    I found out that, the line that makes problem is this:

    @* View /App_Code/uCommerce/Helpers/Review/Category.cshtml for this helper *@
    @uCommerce.Helpers.Category.DisplayCategoryProducts(category)
    

    If I see in the App_Code folder the files is but have this path:

    /App_Code/uCommerce/Helpers and in the helpers folder I have these files:

    Category.cshtml

    Product.cshtml

    ProductReview.cshtml

    Review.cshtml

    Should the Category.cshtml file be in a folder named Review or what could be the reason why my Catalog.cshtml throws an error.

    Any help will be appreciated.

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 08, 2014 @ 16:40
    Dennis Aaen
    100

    It turns out I got this error because I don´t have any facts.

    But I managed to solve the issue.

    Thanks Martin for taking your time to help me

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft