skyler.severns wrote:Hi ,
Is it possible to call manufacture model within product model, I want to show manufacture image for each product , thats why i was thinking to include manufacture model within product model so that i can use intellisense for manufacture properties in the productbox.cshtml,
Is there any other way of achieving it or any ideas
Hi creative3k,
It is possible to add a property for manufacturer model on the product model. If you have the source code then you will need to do the following.
1. Add a new property for manufacture(s)
2. Inside of the controller you will need to map the manufacturer domain object to the manufacturer model.
3. Update the ProductBox view to display according to your design.
I'm not at my normal computer so I do not have source code and I cannot provide code samples, but this should help get the ball rolling.
Well I created a separate partial view named manufactureFields.cshtml
@model Nop.Web.Models.Catalog.ProductModel.ProductMiscModel
<text>Manufacture Name:</text> @Model.manufactureName
And did some modification in productmodel.cs:
public class ProductModel : BaseNopEntityModel
{
public ProductModel()
{
ProductMisc = new ProductMiscModel();
}
public ProductMiscModel ProductMisc { get; set; }
public class ProductMiscModel : BaseNopModel
{
public string manufactureName { get; set; }
}
And in catalogController:
private ProductModel.ProductMiscModel PrepareProductMiscModel(Product product)
{
var manufacturer = _manufacturerService.GetProductManufacturersByProductId(product.Id, true);
var manufactureid=0;
foreach (var manid in manufacturer)
{
manufactureid = manid.ManufacturerId;
}
var getmanufacture = _manufacturerService.GetManufacturerById(manufactureid);
var manufacturePicture = getmanufacture.PictureId;
if (getmanufacture.Name == "")
{
model.manufactureName = "No Manufacture Provided";
}
else
{
model.manufactureName = getmanufacture.Name;
}
but this gives an error :System.NullReferenceException: Object reference not set to an instance of an object.