面对 Kentico 10 中 DocumentHelper 方法的问题

Facing an issue with DocumentHelper method in Kentico 10

我正在使用 csv 文件并借助 DocumentHelper 方法将所有产品添加到 kentico 数据库。

以下是我在 Kentico 9.0 中将产品添加到 Kentico 数据库时使用的代码。这工作正常

public void InsertAttachment(string url, SKUTreeNode productDoc)
    {
        string file = DownloadImage(url);

        if (!String.IsNullOrEmpty(file))
        {
            Bitmap bmp = (Bitmap)System.Drawing.Image.FromFile(Server.MapPath(file), true);
            AttachmentInfo attachment = DocumentHelper.AddAttachment(productDoc, "ProductImage", file, tree);
            attachment.AttachmentImageHeight = getRelativeHeight(bmp);
            attachment.AttachmentImageWidth = 300;
            attachment.AttachmentIsUnsorted = true;
            AttachmentInfoProvider.SetAttachmentInfo(attachment);
            productDoc.Update();
        }
    }

我在 Kentico 10 中使用的代码相同,但我在 AddAttachment method.It 中收到一个错误,它不接受 TreeProvider 变量“tree”。 您能否为我提供此解决方案或我可以添加附件的替代方法?

在 v10 中你不需要给方法提供 tree 参数,你可以使用:

attachment = DocumentHelper.AddAttachment(page, "MenuItemTeaserImage", file);
page.Update();

我得到了在 Kentico 10

中对 API 所做的更改

https://devnet.kentico.com/documentation/api-changes/kentico-10/23737