Error when using partial view :ProductVariant_SKU_Man_Stock

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Spire wrote:

Just try this, i have not tested it , just a guess :

Add this line to PrepareProductOverviewModels [Nope.WebControllers.CatalogController]

var quantity = productVariant.AllowedQuantities;

after this line
var productVariant = _priceCalculationService.GetProductVariantWithMinimalPrice(productVariants, _workContext.CurrentCustomer, true, int.MaxValue, out minimalPrice); //line248

Now add this line in the ProductOverviewModel
public string quantity { get; set; } it should be included in the partial class
public partial class ProductPriceModel : BaseNopModel

Now call quantity in the _ProductBox.cshtml
like:
@Html.Raw(Model.ProductPrice.quantity)

Hi

Well as you posted the above code I had just worked out that I may be able to get to the Stock Qty by using this line in the productVariant.StockQuantity; at the line in the code u suggested.

However I was still trying to work out how how to get that in to the view, so I followed the code u suggested with a couple of minor changes

priceModel.StockQty = productVariant.StockQuantity; instead of
var quantity = productVariant.AllowedQuantities;

public int StockQty { get; set; } instead of public string quantity { get; set; }

and @Model.ProductPrice.StockQty instead of
@Html.Raw(Model.ProductPrice.quantity)

and it worked :) thank you again for your time and patience, I am begining to learn a little C# and MVC. :)

Thanks


Glad to see that it worked out for you , make sure if you have multiple variants for product then you have to use a loop.

Thanks
11 years ago
Hi

I'm using 2.4 currently and I don't have Partial Classes as in 2.6. I can't upgrade currently due to other reasons. But I have updated the Overview Controller as follow's


[NonAction]protected ProductModel PrepareProductOverviewModel(Product product, ProductVariant productVariant, bool preparePriceModel = true, bool preparePictureModel = true, int? productThumbPictureSize = null)
        {
            if (product == null)
                throw new ArgumentNullException("product");

            var model = product.ToModel();
            //ConcordProductBlock
            model.CCCPack = product.CCCPack;
            model.CCCStockCode = product.CCCStockCode;
            model.CCCRetailPrice = product.CCCRetailPrice;
            [code]model.StockAvailablity = productVariant.DisplayStockQuantity;


As you can see I have implemented my own feilds above that call through the view but my issue is Displaying the StockQuantity as I cannot implicity convert Bool to Int and also when I Implement
ProductVariant productVariant
in the values I have multiple error's throughout the catalog Controller that seem to be contain around 1 line but in multiple line's of code for example

model.Add(PrepareProductOverviewModel(product, false, false, productThumbPictureSize));


If you could advise and help will be highly regarded. - I can't upgrade to 2.6 though.

Thank you in advance

Richard.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.