_ProductBox override

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 лет назад
If I copy _ProductBox.cshtml to my plugin to override it, I get the following error at line 52:


    Line 52:             @Html.Widget("productbox_addinfo_before", Model.Id)

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Nop.Web.Models.Catalog.ProductOverviewModel>' does not contain a definition for 'Widget' and no extension method 'Widget' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Nop.Web.Models.Catalog.ProductOverviewModel>' could be found (are you missing a using directive or an assembly reference?)


If I try to copy some other cshtml into my plugin it works. What should I change?
8 лет назад
Hi,

I presume you forget to add "using Nop.Web.Framework" directive to your custom cshtml file
8 лет назад
a.m. how do you know that?

I have just copy original _ProductBox.cshtml to my plugin to override it. The original one has this directives:

@model ProductOverviewModel
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Web.Models.Catalog;


Why I have to add another one(Nop.Web.Framework), I don't understand. All other code is original, just this cshtml is from mine plugin but is currently the same as original one - so, no modifications. It should work.(well if I add other view, HomepageProducts.cshtm for examples, and it works).

Now I get different error:

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<Nop.Web.Models.Catalog.ProductOverviewModel>' does not contain a definition for 'GetTopicSeName' and no extension method 'GetTopicSeName' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<Nop.Web.Models.Catalog.ProductOverviewModel>' could be found (are you missing a using directive or an assembly reference?)

Line 66:                         @T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))



I guess I have to add another reference?

thanks,
Simon
8 лет назад
as Andrei wrote u r missing directives, these directives are set on the web/views/web.config under namespaces
8 лет назад
I have add another one:@using Nop.Web.Extensions and now it works.

But why some directives are written inside cshtml:

@using Nop.Core
@using Nop.Core.Domain.Orders


and some in config file. I don't understand.

Otherwise you helped me a lot.
I thought to write all custom code inside my plugins but I have found out that this is not possible. If I want to extend some model - for example add custom column to all products, I should change source code:
http://docs.nopcommerce.com/pages/viewpage.action?pageId=1442499

Then why bother with overriding the view inside plugin if I have to change the source code anyway?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.