NopCommerce 3.7:有没有办法让SubCategory产品出现在父类别页面上但是按子类别分组?

时间:2016-07-19 20:01:45

标签: asp.net-mvc nopcommerce

Nop 3.7

有没有办法让SubCategory产品显示在父类别页面上但是按子类别分组?

当前代码无效:

ProductModel.cs(在Nop.Web项目中)

 public partial class SubCategoryModel : BaseNopEntityModel
    {
        public SubCategoryModel()
        {
            PictureModel = new PictureModel();
            //Custom ADDED PRODUCT LIST TO LIST OUT SUB CATERGORY PRODUCTS CORRECTLY
            Products = new List<ProductOverviewModel>();
        }

        public string Name { get; set; }

        public string SeName { get; set; }

        public string Description { get; set; }

        public PictureModel PictureModel { get; set; }
        //Custom ADDED PRODUCT LIST TO LIST OUT SUB CATERGORY PRODUCTS CORRECTLY
        public IList<ProductOverviewModel> Products { get; set; }
    }

CSHTML(在Nop.Web项目中查看)

    @*--Custom GET SUBCATEGORIES AND SHOW THEIR PRODUCTS UNDER EACH SUB CATEGORY--*@
        @if (Model.SubCategories.Count > 0)
        {
           <div id="customSubCategoriesWithProducts">
               <p>Custom stuff below:</p>
                @foreach (var item in Model.SubCategories)
                { 
                    <div class="customSubCategorieSection">
                        <h2 class="title">
                                @item.Name

                        </h2>
                            @foreach (var product in item.Products)
                            { 
                               @product.Name  
  //No output when trying to get the products.  Is there a way to do this?
                            }

                    </div>
                }
           </div>

        }

期望的影响:

父类别页面

  • SubCategory1

    [产品1],[产品2],[产品3]

  • SubCategory2

    [产品4],[产品5],[产品6] ...

预期结果的图像: enter image description here

0 个答案:

没有答案