nopCommerce 2.40管理产品编辑添加 [英] nopCommerce 2.40 Admin Product Edit Addition

查看:140
本文介绍了nopCommerce 2.40管理产品编辑添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望我能在这里取得一些进展,因为nopCommerce论坛对我的帖子一直保持沉默。我目前的情况是,对于商店中拥有的每种产品,我们(管理员)需要上载特定文档,并在最终用户浏览产品详细信息部分时通过链接和下载的方式将该文档显示给最终用户。

Hopefully I can get some headway here as nopCommerce forums has been silent to my post. My current situation is that for each product we have in our store, we(admins) need to upload a specific document and have that document show to the end user when they are browsing the product detail section, through means of a link and download.

所以我想我会把这个项目切碎,然后首先尝试从管理区域开发上载功能。

So I figured I would chop this project up and first attempt to develop the upload function from the admin area.

如果其他人可以提供帮助但不知道nopCommerce,则它是一个ASP.NET MVC 3项目。对于已经拥有nopCommerce的用户,请在下面查看如何导航并将我的代码添加到特定文件。

In case anyone else can help but doesn't know nopCommerce, it is an ASP.NET MVC 3 project. For those who have nopCommerce already, please look below on how to navigate and add my code to the specific files.

1。如何在产品编辑中添加标签:

1.How to add a tab to Product

a。内部Nop.Admin

a.Inside Nop.Admin

i。导航至视图-> _CreateOrUpdate.cshtml

i.Navigate to Views -> _CreateOrUpdate.cshtml

b。在第24行之后添加TabPanel

b.Add TabPanel after line 24

x.Add().Text(T("Admin.Catalog.Products.ProductDocuments").Text).Content(TabProductDocuments().ToHtmlString());

c。在772行创建'TabProductDocuments'帮助方法

c.Create ‘TabProductDocuments’ help method on line 772

@helper TabProductDocuments()
{
if (Model.Id > 0)
{
<h2>Product Documents</h2>
<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="submit" />
</form>
}
else
{
@T("Admin.Catalog.Products.ProductDocuments.SaveBeforeEdit")
}
}

d。将ProductDocumentsController.cs更改为更简单的代码:

d.Change ProductDocumentsController.cs to more simple code:

public class ProductDocumentsController : BaseNopController
{
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(HttpContext.Server.MapPath("../Content/files/uploads"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}

现在,我遇到的问题是:我现在可以在其中看到选项卡产品编辑,但无法上传文件。它提交查询,但只是刷新页面并返回到产品列表。没有文件上传。如果可以,请协助我尝试将文件正确上传到我指定的路径。再次感谢您的协助。

Now, the issue I am experiencing is: I can see the tab now in Product Edit, but I cannot upload the file. It submits the query but just refreshes the page and leads back to Product List. No file is uploaded. If you can, please assist me with trying to upload the file properly to the path I have designated. Thank you again for your assistance.

我已经从头开始尝试了一个上传项目,它确实可以正常工作,但是由于某种原因,在这里它无法正常工作。

I've already tried from scratch an upload project and it does work properly, but for some reason, here, it just isn't working.

推荐答案

可能有点晚了,但是我为此做了一个插件。可以在github上找到

Probably a bit late but I did a plugin for this. Can be found on github

https ://github.com/johanlasses/nopcommerce-product-files-plugin

这篇关于nopCommerce 2.40管理产品编辑添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆