_ProductBox.cshtml
@model Nop.Web.Models.Catalog.ProductModel
<div class="product-item">
<h2 class="product-title">
@Model.Name
</h2>
<div class="description">
@Html.Partial("_ProductMisc", Model.ProductMisc)<br />
<text><b>Description :</b></text>@Html.Raw(Model.FullDescription)
<div><text><b>Size :</b></text>@Html.Raw(Model.Size)</div>
</div>
<div class="add-info">
<div class="prices">
@Html.Partial("_ProductPrice", Model.ProductPrice)
</div>
<div class="buttons">
@if (!Model.ProductPrice.DisableBuyButton)
{
<input type="button" value="@T("ShoppingCart.AddToCart")" class="productlistaddtocartbutton" onclick="setLocation('@(@Url.RouteUrl("AddProductToCart", new { productId = Model.Id }))')" />
}
</div>
</div>
</div>
_ProductMisc.cshtml
@model Nop.Web.Models.Catalog.ProductModel.ProductMiscModel
<text><b>Code :</b></text>@Model.Sku
<div style="float:right"> @foreach (var Manufacture in Model.manufactureName)
{
<img style="border-width: 0px;" alt="@Manufacture.PictureModel.AlternateText" src="@Manufacture.PictureModel.ImageUrl" title="@Manufacture.PictureModel.Title" />
// @test.PictureModel.ImageUrl}
}
</div>
OutPut on the test website:
Code: Code of Product
Product Manufacture Image
Size: Product Size
Description: Product Description
Price: Product Price
What I want is to show the product attributes in the _ProductBox.cshtml, I want to call @Html.Partial("_ProductAttributes") for each product in _ProductBox.cshtml , but I cant find a way of calling it by passing it the variant id of the product , I tried calling : @{
var defaultProductVariant = Model.ProductVariantModels.Count > 0 ? Model.ProductVariantModels[0] : null;}
@{
var dataDictAttributes = new ViewDataDictionary();
dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", defaultProductVariant.Id);
@Html.Partial("_ProductAttributes", defaultProductVariant.ProductVariantAttributes, dataDictAttributes)
}
which comes up with the object reference not set to instance of an object.