Ciao
grazie per l'aiuto
Forse perchè sono all'inizio e non capisco molto, ma sto impazzendo per fare una cosa semplicissima: voglio visualizzare le categorie a cui appartiene il prodotto.
Controller
Model
namespace Nop.Web.Models.Catalog
{
public partial class ProductOverviewModel : BaseNopEntityModel
{
public ProductOverviewModel()
{
ProductPrice = new ProductPriceModel();
DefaultPictureModel = new PictureModel();
SpecificationAttributeModels = new List<ProductSpecificationModel>();
ReviewOverviewModel = new ProductReviewOverviewModel();
Categories = new List<ProductCategory>();
}
public string Name { get; set; }
public string ShortDescription { get; set; }
public string FullDescription { get; set; }
public string SeName { get; set; }
//price
public ProductPriceModel ProductPrice { get; set; }
//picture
public PictureModel DefaultPictureModel { get; set; }
//specification attributes
public IList<ProductSpecificationModel> SpecificationAttributeModels { get; set; }
//price
public ProductReviewOverviewModel ReviewOverviewModel { get; set; }
//categorie QUESTO E' QUELLO CHE VOGLIO AGGIUNGERE IO
public IList<ProductCategory> Categories { get; set; }
#region Nested Classes
public partial class ProductPriceModel : BaseNopModel
{
public string OldPrice { get; set; }
public string Price {get;set;}
public bool DisableBuyButton { get; set; }
public bool DisableWishlistButton { get; set; }
public bool AvailableForPreOrder { get; set; }
public DateTime? PreOrderAvailabilityStartDateTimeUtc { get; set; }
public bool ForceRedirectionAfterAddingToCart { get; set; }
/// <summary>
/// A value indicating whether we should display tax/shipping info (used in Germany)
/// </summary>
public bool DisplayTaxShippingInfo { get; set; }
}
#endregion
}
}
Lettura dei dati
/// <summary>
/// Gets all products displayed on the home page
/// </summary>
/// <returns>Product collection</returns>
public virtual IList<Product> GetAllProductsDisplayedOnHomePage()
{
var query = from p in _productRepository.Table
orderby p.DisplayOrder, p.Name
where p.Published &&
!p.Deleted &&
p.ShowOnHomePage
select p;
var products = query.ToList();
return products;
}
Classe Product
Classe Category
Non riesco a capire come assegnare i valori alla List Category che ho aggiunto io. Non mi è propro chiara la logica di come vengano assegnati i valori.
Grazie mille