Passing a Partial View as a new Product Display .

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

I need some help as I am humbly stuck - again!!

I want to pass a partial view for a product display using a popup instead of product display page. Here is the Outlining steps I have undertaken. To produce this action / view but as I mentioned I am stuck and I would appreciate all help!! As when I try to pass the view - as you will see in the code below nothing happens.

1. Nop.Web.Controllers.Catalog.cs

Using the orignal source code provided by Nop Commerce and partially my own I have updated and created a new public action.

        
public ActionResult _Productpopup(int productId)
        {
            var product = _productService.GetProductById(productId);
            if (product == null || product.Deleted || !product.Published)
                return RedirectToAction("Index", "Home");

            //prepare the model
            var model = PrepareProductDetailsPageModel(product);

            //CCCStockCode
            model.CCCStockCode = product.CCCStockCode;

            ////CCCPack
            model.CCCPack = product.CCCPack;

            ////CCCLane
            model.CCCLane = product.CCCLane;

            ////CCCRRP
            model.CCCWholesalePrice = product.CCCWholesalePrice;

            ////CCCRetailPrice
            model.CCCRetailPrice = product.CCCRetailPrice;

            ////CCCMRP
            model.CCCMRP = product.CCCMRP;

            ////CCCQTYINSTOCK
            model.CCCQTYINSTOCK = product.CCCQTYINSTOCK;

            ////CCCBay
            model.CCCBay = product.CCCBay;

            ////CCCSourceBarcode
            model.CCCSourceBarcode = product.CCCSourceBarcode;

            ////CCCRetailBarcode
            model.CCCRetailBarcode = product.CCCRetailBarcode;

            ////CCCWeight
            model.CCCWeight = product.CCCWeight;

            ////CCCQTYPacksPerLayer
            model.CCCQTYPacksPerLayer = product.CCCQTYPacksPerLayer;

            ////CCCQTYLayersPerPallet
            model.CCCQTYLayersPerPallet = product.CCCQTYLayersPerPallet;

            //CCCQTYLayersPerPallet
            model.CCCQTYTotalPerPallet = product.CCCQTYTotalPerPallet;

            return PartialView();
        }


Nop.Web.Views.Catalog. _Productpopup.cshtl

As you can see I have used the _RootPopup shared view after digging through the orignal source code provided and I'm using Nop.Model.Product.cs

@model Nop.Web.Models.Catalog.ProductModel
@{
    Layout = "~/Views/Shared/_RootPopup.cshtml";      
}

      <div class="product-popup">
            <div class="product-details-infopopup">
                <!--product pictures-->
                   <div class="popup-picture">
                     @Html.Partial("_ProductDetailsPictures", Model)
                   </div>
                <div class="overview">
                    <div class="productname">
                     @Model.Name
                    <div class="shortdescription">
                     @Html.Raw(Model.ShortDescription)
                    </div>
                    
                    <div class="stockcode">
                     @Model.CCCStockCode
                    </div>
                    
                    <div class="wholesaleprice">
                    @Model.CCCWholesalePrice
                    </div>

                    <div class="pack">
                    @Model.CCCPack
                    </div>

                    <div class="weight">
                    @Model.CCCWeight
                    </div>

                    <div class="retailprice">
                    @Model.CCCRetailPrice
                    </div>

                    <div class="retailbarcode">
                    @Model.CCCRetailBarcode
                    </div>

                    <div class="sourcebarcode">
                    @Model.CCCSourceBarcode
                    </div>

                    <div class="packsperlayer">
                    @Model.CCCQTYPacksPerLayer
                    </div>

                    <div class="layersperpallet">
                    @Model.CCCQTYLayersPerPallet
                    </div>

                    <div class="totalperpallet">
                    @Model.CCCQTYTotalPerPallet
                    </div>
                    
                    </div>
                    
                    <div class="product-close-button">
                    <input type="button" value="Close" onclick='close()' />
                    </div>
                    
                  </div>
                
                </div>
            
             </div>


Nop.Web.Views._Productbox.cshtml

From the image provided in the view Instead of returning the product display page I would like a pop up to display the product information/data -with no Jquery just a javascript:window.open popup.

<div class="picture">
       <a href="javascript:window.open(@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName })"
       title="@Model.DefaultPictureModel.Title"> <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title"class="product-popup" />
        </a>
    </div>


When I click on the image nothing happen's.

Hopefully someone can advise me on what I am missing.

All help highly regarded

Thank you

Richard
11 years ago
Done.
11 years ago
can u share what was wrong ?
11 years ago
Yes and No - I did a fix instead due to deadlines. I think it was due to routes. I will need to reviste when I have time but

Basically In ProductTemplate.SingleVariant.cshtml

I used rootpop up in the shared view instead of shared columns and called my partial view into that view.

In the _productbox I used this Javascript that I found online

<a href="@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName })" 
         onclick="javascript:void window.open('@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName })','1328267806899','width=600,height=600,toolbar=0, menubar=0,location=0,status=0,scrollbars=0,resizable=0,left=200,top=60,center=1');return false;
          "class="product-details-info"</a><img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl"title="@Model.DefaultPictureModel.Title" />
       </div>


It works.  Which is cool.
11 years ago
thank for the info :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.