Add ProductVariant properties Weight, length and height to productview

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hello,

I'm pretty new to NopCommerce so I hope someone can give me some directions. I want to show the productvariant properties Weight, Length and Height to the customer on the productdetail page. I want to show them with my product specification so I did the follow:

Extended the ProductModel.cs with

public class ProductVariantPriceModel : BaseNopModel
            {
                public string OldPrice { get; set; }

                public string Price { get; set; }
                public string PriceWithDiscount { get; set; }

                public decimal PriceValue { get; set; }
                public decimal PriceWithDiscountValue { get; set; }

                public bool CustomerEntersPrice { get; set; }

                public bool CallForPrice { get; set; }

                public int ProductVariantId { get; set; }

                public bool HidePrices { get; set; }

                public bool DynamicPriceUpdate { get; set; }

                //added
                public string YouSave { get; set; }
                public string YouSavePercent { get; set; }
                //@added

                //add pve
                public decimal Weight { get; set; }
                public decimal Length { get; set; }
                public decimal Width { get; set; }
                public decimal Height { get; set; }
                //@//added
            }


Then I create a new partial View _ProductVariantSpecifications.cshtml

@model Nop.Web.Models.Catalog.ProductModel.ProductVariantModel.ProductVariantPriceModel
@using Nop.Web.Models.Catalog;
@using Nop.Core.Domain.Catalog;
@using Nop.Core.Infrastructure;
@using Nop.Core;
@using System.Text;
@using System.Globalization;
@using Nop.Web.Framework;
@using Nop.Services.Customers;
@using System.Text.RegularExpressions;
<div class="customspecifications">
    <div class="productspec-list">
        <div class="customspecifications">
            <table class="grid" style="width: 100%; border: 0px">
                <tr>
                    <td style="width: 30%;">
                        Lengte(cm)
                    </td>
                    <td style="width: 70%;">
                        @*@Model.Length;*@
                    </td>
                </tr>
                <tr>
                    <td style="width: 30%;">
                        Breedte(cm)
                    </td>
                    <td style="width: 70%;">
                       @* @Model.Width;*@
                    </td>
                </tr>
                <tr>
                    <td style="width: 30%;">
                        Hoogte(cm)
                    </td>
                    <td style="width: 70%;">
                        62222
                    </td>
                </tr>
                <tr>
                    <td style="width: 30%;">
                        Gewicht(kg)
                    </td>
                    <td style="width: 70%;">
                        3.2
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>


The problem is that the properties Length, weight etc in the model are empty. Where do I have to load these values in the model


Thanks
12 years ago
You should set these values in the controller action method you're requesting. I presume that you added a new method and a view.
12 years ago
Can you give me a hint? This the part I'm a little lost
12 years ago
patzwork wrote:
Can you give me a hint? This the part I'm a little lost

I think what he's referring to is that you will need to create a controller to set the vaults in your model / view.
12 years ago
Try this in the Catalog Controller...

CatalogController.cs

[NonAction]
        private ProductModel.ProductVariantModel PrepareProductVariantModel(ProductModel.ProductVariantModel model, ProductVariant productVariant)

model.ShowWeight = _catalogSettings.ShowWeight;
            model.Weight = productVariant.Weight.ToString();
            model.ShowLength = _catalogSettings.ShowLength;
            model.Length = productVariant.Length.ToString();
            model.ShowWidth = _catalogSettings.ShowWidth;
            model.Width = productVariant.Width.ToString();
            model.ShowHeight = _catalogSettings.ShowHeight;
            model.Height = productVariant.Height.ToString();

Try this may work mind you I added it to a different area of the model but I'm having issues with the display but that is due to changes I am currently undertaken.
12 years ago
Hi Patz,

Were you able to succesfully do this. If you could can you please share me the files you modified as I am also about to do the same.

Thanks,
Praneeth
11 years ago
Thanks you for All.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.