How to include sku and manufacture number and quantity in _ProductBox.cshtml

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 年 前
Hi,

I am using nop 2.2 , trying to edit the productbox view , i need to show sku , manufacture id and quantity box in it , i tried something like this which fails :

<div class="description">
<!--product SKU, manufacturer part number, stock info-->
    @if(Model.ProductVariantModels.Count > 0)
    {@Model.ProductVariantModels.Select(x => x.Sku) }
        @Html.Raw(Model.FullDescription)
        
        
    </div>
    <div class="add-info">
        <div class="prices">
            @Html.Partial("_ProductPrice", Model.ProductPrice)
        </div>
12 年 前
Do you alway have a single variant for a product ?
12 年 前
yeh just one variant for each product
12 年 前
Does anyone had figured out how to acheive this ??
12 年 前
Sorted by creating an extra partial view.
12 年 前
creative3k wrote:
Sorted by creating an extra partial view.


Hi

I need to show the SKU in  ProductTemplate.VariantsInGrid.cs.html

Could you please expand in detail about how you have done it?

Thanks
Diip
12 年 前
dilip03 wrote:
Sorted by creating an extra partial view.

Hi

I need to show the SKU in  ProductTemplate.VariantsInGrid.cs.html

Could you please expand in detail about how you have done it?

Thanks
Diip


Well i created a separate partial view , as i want to call the manufactures , sku and size of the products, created a model which calls all my required fields ,
just added something like

public ProductModel()
        
{
               ProductRequired  = new ProductRequiredModel();// in the Product Model.cs

         }
               public ProductRequiredModel ProductRequired  { get; set; }

         public class ProductRequiredModel: BaseNopModel
        {
            public string Sku { get; set; }

            public bool ShowSku { get; set; }

            public IList<ManufacturerModel> manufactureName { get; set; }

        
        }
//and in Catalog Controller

[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 getManufactureImage = _manufacturerService.GetProductManufacturersByProductId(product.Id)
               .Select(x =>
               {
                   var m = x.Manufacturer.ToModel();

                   m.PictureModel.ImageUrl = _pictureService.GetPictureUrl(x.Manufacturer.PictureId, _mediaSetting.ManufacturerThumbPictureSize, true);
                   m.PictureModel.Title = string.Format(_localizationService.GetResource("Media.Manufacturer.ImageLinkTitleFormat"), m.Name);
                   m.PictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Manufacturer.ImageAlternateTextFormat"), m.Name);
                   return m;
               })
               .ToList();
            model.manufactureName = getManufactureImage;
            switch (productVariants.Count)
            {
                case 0:
                    {
                        var productVariant = productVariants[0];
                      
                        model.Sku = null;
                        model.ShowSku = false;
                       // model.attributeName = 0;
                    } break;
                 }
        
            return model;
        }
//Similarly in the View _ProductBox.cshtml
@model Nop.Web.Models.Catalog.ProductModel
@Html.Partial("_ProductCode", Model.ProductMisc)
@Html.Partial("_ProductManufacture", Model.ProductMisc)

//_ProductManufacture.cshtml
@model Nop.Web.Models.Catalog.ProductModel.ProductMiscModel
@foreach (var Manufacture in Model.manufactureName)
                          {
                                 <img style="border-width: 0px;" alt="@Manufacture.PictureModel.AlternateText" src="@Manufacture.PictureModel.ImageUrl" title="Manufacture" />
                                  
                          }

//_ProductCode.cshtml
@model Nop.Web.Models.Catalog.ProductModel.ProductMiscModel
@Model.Sku
                            
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.