Add price to homepage products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi. Im completely new to nopcommerce and im trying to configure and customize it. Right now im trying to display the product price for each featured product in the homepage.

What i did is put @Model.ProductPrice.Price on _ProductSmallBox.cshtml, but nothing is displayed. If i put @Model.ProductPrice only it displays the object type and if i try @Model.ProductVariantModels[0].ProductVariantPrice.Price it throws an out of bounds exception.

Whats the correct way to do this?

Thank you very much.
12 years ago
laborin wrote:
Hi. Im completely new to nopcommerce and im trying to configure and customize it. Right now im trying to display the product price for each featured product in the homepage.

What i did is put @Model.ProductPrice.Price on _ProductSmallBox.cshtml, but nothing is displayed. If i put @Model.ProductPrice only it displays the object type and if i try @Model.ProductVariantModels[0].ProductVariantPrice.Price it throws an out of bounds exception.

Whats the correct way to do this?

Thank you very much.

This is configurable in v. 2.2. In admin>configuration>settings>all settings (advanced) set  'catalogsettings.usesmallproductboxonhomepage' to true.
12 years ago
eadameg wrote:
Hi. Im completely new to nopcommerce and im trying to configure and customize it. Right now im trying to display the product price for each featured product in the homepage.

What i did is put @Model.ProductPrice.Price on _ProductSmallBox.cshtml, but nothing is displayed. If i put @Model.ProductPrice only it displays the object type and if i try @Model.ProductVariantModels[0].ProductVariantPrice.Price it throws an out of bounds exception.

Whats the correct way to do this?

Thank you very much.
This is configurable in v. 2.2. In admin>configuration>settings>all settings (advanced) set  'catalogsettings.usesmallproductboxonhomepage' to true.


Yes, but if i set "usesmallproductboxonhomepage" to true, it shows the products in a little area with only the title and the picture. If i set it to false, it shows a more detailed box with a "add to cart" button and stuff. I Want to use the smallbox BUT showing the product price. Thats why im trying to edit the "_ProductSmallBox.cshtml" partial view, but unsuccessful yet.
12 years ago
Done!

I had to edit the HomepageProducts() action in the Catalog controller. Just set to true the second parameter for PrepareProductOverviewModel, so it always constructs the products model with the price model included even if i want to use the smallproductbox:


        [ChildActionOnly]
        public ActionResult HomepageProducts()
        {
            var model = new HomePageProductsModel()
            {
                UseSmallProductBox = _catalogSettings.UseSmallProductBoxOnHomePage
            };
            model.Products = _productService.GetAllProductsDisplayedOnHomePage()
                .Select(x => PrepareProductOverviewModel(x, true, true))
                .ToList();

            return PartialView(model);
        }
12 years ago
This was really helpfull thanks so much, also can you tell me, if these changes are made on te source, which dlls i need to copy to my live site?
12 years ago
kakoli wrote:
This was really helpfull thanks so much, also can you tell me, if these changes are made on te source, which dlls i need to copy to my live site?


I don't remember, i'm not doing nopcommerce development anymore, but an easy way to know is to compile it without changes, wait some minutes, make the changes in the code and compile it again. Only the needed output files wil be re-compiled, so you can sort by "modified date" your output directory content and the updated DLLS will be the most recent by some minutes.

Just remember to set the visual studio project in release mode before any compilation.
12 years ago
Thanks once agian, actully i already did that, and its working. Have a great day.
12 years ago
laborin wrote:
Done!

I had to edit the HomepageProducts() action in the Catalog controller. Just set to true the second parameter for PrepareProductOverviewModel, so it always constructs the products model with the price model included even if i want to use the smallproductbox:


        [ChildActionOnly]
        public ActionResult HomepageProducts()
        {
            var model = new HomePageProductsModel()
            {
                UseSmallProductBox = _catalogSettings.UseSmallProductBoxOnHomePage
            };
            model.Products = _productService.GetAllProductsDisplayedOnHomePage()
                .Select(x => PrepareProductOverviewModel(x, true, true))
                .ToList();

            return PartialView(model);
        }


I was able to do this in 2.2, after i migrated to 2.4, i am not able find this on source, please help..
11 years ago
I have done following change in the catlog controller for nop 2.5, just wanted to know if this would effect something else,??

I commented
.Select(x => PrepareProductOverviewModel(x, !_catalogSettings.UseSmallProductBoxOnHomePage, true, productThumbPictureSize))

Added this
                .Select(x => PrepareProductOverviewModel(x, true, true))
11 years ago
Hi,
I have done for 2.4 version code as fallows

web-->views-->catalog-->_productsmallbox.cshtml

at the end add fallowing code

    <div class="prices">
        @Html.Partial("_ProductPrice", Model.ProductPrice)
    </div>






Thanks & Regards
Kumar
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.