Copied to clipboard

Flag this post as spam?

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


  • ThanhNguyen 1 post 71 karma points
    Apr 02, 2019 @ 15:46
    ThanhNguyen
    0

    Model return value cannot be null in FastTrack

    Hi im a newbie to Umbraco and i have question about adding , replacing ,.. model in Umbraco/ Merchello. My version of Umbraco CMS is 7.14 with Merchello/ FastTrack 2.7. I want to change the front page of the site to show all the products instead of only featured products, so i went to the ftStore in the template and change @Model.FeaturedProducts to @Model.Products but it tell me :"'FtStore' does not contain a definition for 'Products' ". enter image description here So i copy [ImplementPropertyType("products")] from another template (ftCategory) to ftStore in both all.generated.cs and model.generated.cs and run enter image description here

    it show another error : enter image description here

    I really dont know how to fix this, in the ftCategory it had the same model as ftStore but it can call the Model.Products and ftStore cant ( after manually added). Can somebody help me, sorry for my bad english :(

  • Rhys Hamilton 140 posts 942 karma points
    Apr 03, 2019 @ 08:54
    Rhys Hamilton
    0

    First of all, I’d recommend reverting your ftStore model in all.generated.cs and model.generated.cs back to it’s original state – as this might cause some more headaches for you in the long-run.

    To get the products, rather than adding a new property, you should take a look at the Services documentation (particularly the section on ProductService).

    A quick example (which should work) would be something like:

    var productService = MerchelloContext.Current.Services.ProductService;
    var products = productService.GetAll(); 
    
Please Sign in or register to post replies

Write your reply to:

Draft