I wan to use the properties of both entities (Product and category) in one of my view for that i need to inegrate both the models in a single model , can any one assist me with it. thanks
Create your own ViewModel class with the properties you need. Fill in the properties either in the controller or preferably in the service, and use it in your view.
For example:
//you didn't specify ifthisis a modification or sepparate plugin development, hence no namespace :)
You don't need Products because the CategoryModel class already includes its child products. In fact, this is quite similar to what the Sitemap does, so I encourage you to have a look at Controllers\CommonController.cs, Sitemap() action, around line 370. There you can see how to fetch the categories and convert them into CategoryViewModels, just to fill the SitemapModel.
Well the issue is , I can show the products by using category model , but i cant show it using subcategory model , i tried adding product model to the subcategory model which is in the category model.
public class SubCategoryModel : BaseNopEntityModel { public SubCategoryModel() { PictureModel = new PictureModel();
}
public string Name { get; set; }
public string SeName { get; set; }
public PictureModel PictureModel { get; set; }
public IList<ProductModel> Products1 { get; set; } }
but i cant get intellisense when trying to edit subcategories in the CategoryTemplateGridorLines.cshtml:
@*subcategories*@ @if (Model.SubCategories.Count > 0) { <div class="sub-category-grid"> @(Html.DataList<CategoryModel.SubCategoryModel>(Model.SubCategories, 3, @<div class="item-box"> <div class="sub-category-item"> <h2 class="category-title"> <a href="@Url.RouteUrl("Category", new { categoryId = item.Id, SeName = item.SeName })" title="@item.PictureModel.Title"> @item.Name</a> </h2> <div class="products-subcategories"> @item.Products //cant get intellisense of the product which should be name , description etc </div> </div> ))
And when i run this and click on the category it comes up with the error : Compiler Error Message: CS1061: 'System.Collections.Generic.IList<Nop.Web.Models.Catalog.ProductModel>' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'System.Collections.Generic.IList<Nop.Web.Models.Catalog.ProductModel>' could be found (are you missing a using directive or an assembly reference?)
I want to merge productmodel and categorynavigationmodel to display left navigation in individual product page. Integrated both but, gives the error "The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Nop.Web.Models.Catalog.ProductModel, but this dictionary requires a model item of type 'Nop.Web.Models.Catalog.customModel".
Or any other idea to display left navigation in product page?
Please help me to solve this.
Thanks in advance.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.