Hi ,
I want to show certain fields from the product variant table, therfore I created a partial view for it but for some reason its not working can anyone assist me with it , below is the code which i added into following class, controller and view:
ProductModel.cs:
public class ProductModel : BaseNopEntityModel
{
public ProductModel()
{
ProductMisc = new ProductMiscModel();
}
public ProductMiscModel ProductMisc { get; set; }
public class ProductMiscModel : BaseNopModel
{
public string Sku { get; set; }
public bool ShowSku { get; set; }
}
}
CatalogController.cs:
[NonAction]
private ProductModel.ProductMiscModel PrepareProductMiscModel(Product product)
{
if (product == null)
throw new ArgumentNullException("product");
var model = new ProductModel.ProductMiscModel();
var productVariants = _productService.GetProductVariantsByProductId(product.Id);
var productVariant = productVariants[0];
model.Sku = productVariant.Sku;
model.ShowSku = true;
return model;}
Created a partial view _ProductMisc.cshtml:
@model Nop.Web.Models.Catalog.ProductModel.ProductMiscModel
@Model.Sku
Finally integrated the partial view in the _ProductBox.cshtml:
<div class="description">
@Html.Partial("_ProductMisc", Model.ProductMisc)
@Html.Raw(Model.FullDescription) <br />
</div>
But sku doesnt not comes up in the view , where am i getting it wrong???