2
$我能夠在管理部分創建菜單項 插件 - >導入產品 但是,當我點擊它時,它給我 錯誤資源找不到。請幫助這個 的事情。我在下面附加了模型,視圖,控制器和其他相關代碼。nopCommerce:無法找到資源。
*************Model*************
namespace Nop.Plugin.Import.Product.Models
{
public class ImportProductModel
{
public string Button1 { get; set; }
}
}
**********Controller*************
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Nop.Admin.Models.Catalog;
using Nop.Core.Domain.Catalog;
using Nop.Core.Infrastructure;
using Nop.Plugin.Import.Product.Models;
using Nop.Services.Catalog;
using ns_5OClock;
namespace Nop.Plugin.Import.Product.Controllers
{
class ImportProductController : Controller
{
//
// GET: /DisplayTime/
public ActionResult Index(ImportProductModel model)
{
if (!String.IsNullOrEmpty(model.Button1))
{
CreateProduct();
}
return View();
}
//
}
}
*************View (ImportProduct.cshtml) **********
@{
Layout = "";
}
@model Nop.Plugin.Import.Product.Models.ImportProductModel
<table>
<tr>
<td>
<button title="Click to Create Products"
style="width:300px;height:60px" name="Button1"></button>
</td>
</tr>
</table>
***************Plugin (ImportProduct) **********************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Core.Plugins;
using Nop.Web.Framework.Web;
namespace Nop.Plugin.Import.Product
{
public class ImportProduct : BasePlugin, IAdminMenuPlugin
{
public void BuildMenuItem(Telerik.Web.Mvc.UI.MenuItemBuilder menuItemBuilder)
{
menuItemBuilder.Text("Import Product");
//menuItemBuilder.Url("/Plugins/ProductImport/Index");
menuItemBuilder.Route("Plugin.Import.Product.ImportProduct");
}
}
}
**************Route Provider ****************
using System.Web.Mvc;
using System.Web.Routing;
using Nop.Web.Framework.Mvc.Routes;
namespace Nop.Plugin.Import.Product
{
public partial class RouteProvider : IRouteProvider
{
public void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("Plugin.Import.Product.ImportProduct",
"Plugins/Import/ImportProduct",
new { controller = "Import", action = "ImportProduct" },
new[] { "Nop.Plugin.Import.Product.Controllers" }
);
}
public int Priority
{
get
{
return 0;
}
}
}
}
? :) – wooncherk 2013-04-05 14:43:04