0

我正在使用 WSI 服务将数据导入 ASPDNSF 我有以下

            sb.AppendLine("<Mappings AutoCleanUp=\"true\">");
        sb.AppendLine("<Entity EntityType=\"Manufacturer\" ID=\"" + ManufacturerID + "\" />");

        if (Category != null)
            sb.AppendLine("<Entity EntityType=\"Category\" ID=\"" + Category.CategoryID + "\" />");
        sb.AppendLine("")
        sb.AppendLine("</Mappings>");

目前所有产品都添加到制造商,但在产品/类别下没有显示我希望有人能够指出我认为我需要使用的正确方向

<Mappings AutoCleanup="boolean">

<Entity EntityType="Manufacturer|Distributor|Category|Section|Genre|Vector" Name="string" XPath="string" ID="integer" GUID="uniqueidentifier" DisplayOrder="integer"/>

这是xml格式

这是完整的字符串生成器

public string ToXML()
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine("<AspDotNetStorefrontImport SetImportFlag=\"true\" Verbose=\"true\" AutoLazyAdd=\"true\">");
        sb.AppendLine("<Product Action=\"" + Action.ToString() + "\" EnsureDefaultVariant=\"true\" SKU=\"" + SKU + "\"" + (GUID != null ? " GUID=\"" + GUID + "\"" : "") + " Name=\"" + System.Web.HttpUtility.HtmlEncode(Name) + "\">");
        sb.AppendLine("<Name>" + System.Web.HttpUtility.HtmlEncode(Name) + "</Name>");
        sb.AppendLine("<Summary>" + System.Web.HttpUtility.HtmlEncode(Name) + "</Summary>");
        sb.AppendLine("<SeAltText>" + System.Web.HttpUtility.HtmlEncode(Name) + "</SeAltText>");
        sb.AppendLine("<ProductType ID=\"" + ProductTypeID + "\" />");
        sb.AppendLine("<Price>" + Price + "</Price>");
        sb.AppendLine("<Display>");
        sb.AppendLine("<XmlPackage>" + ConfigurationManager.AppSettings["XMLPackage"] + "</XmlPackage>");
        sb.AppendLine("</Display>");
        sb.AppendLine("<SKU>" + SKU + "</SKU>");
        sb.AppendLine("<Description>" + System.Web.HttpUtility.HtmlEncode(Description) + "</Description>");
        sb.AppendLine("<Published>" + InStock.ToString() + "</Published>");
        sb.AppendLine("<Images>");
        sb.AppendLine("<ImageFilenameOverride>" + ImageName + "</ImageFilenameOverride>");
        sb.AppendLine("</Images>");

        sb.AppendLine("<Mappings AutoCleanUp=\"true\">");
        sb.AppendLine("<Entity EntityType=\"Manufacturer\" ID=\"" + ManufacturerID + "\" />");

        if (Category != null)
            sb.AppendLine("<Entity EntityType=\"Category\" ID=\"" + Category.CategoryID + "\" />");
        sb.AppendLine("")
        sb.AppendLine("</Mappings>");

        sb.AppendLine("<Variants AutoCleanup=\"true\">");
        sb.AppendLine("<Variant Action=\"Add\" Name=\"" + System.Web.HttpUtility.HtmlEncode(Name) + "\">");
        sb.AppendLine("<IsDefault>true</IsDefault>");
        sb.AppendLine("<Name>" + System.Web.HttpUtility.HtmlEncode(Name) + "</Name>");
        sb.AppendLine("<Description>" + System.Web.HttpUtility.HtmlEncode(Description) + "</Description>");
        sb.AppendLine("<Price>" + Price + "</Price> ");
        sb.AppendLine("<Images>");
        sb.AppendLine("<ImageFilenameOverride>" + ImageName + "</ImageFilenameOverride>");
        sb.AppendLine("</Images>");
        sb.AppendLine("<MSRP>" + (SalesListPrice ?? OrigListPrice) + "</MSRP>");
        sb.AppendLine("<Cost>" + Cost + "</Cost>");

        sb.AppendLine("</Variant>");
        sb.AppendLine("</Variants>");
        sb.AppendLine("</Product>");
        sb.AppendLine("</AspDotNetStorefrontImport>");
        return sb.ToString();
    }
}

}

任何帮助表示赞赏

麦克风

4

1 回答 1

0

麦克风,

您指定的类别是否存在?我没有使用 id 指定映射的经验,但使用 XPath 属性取得了很大成功。

<Entity EntityType="Category" Name="" XPath="/Products/NewCategoryName/" />

你曾经能够解决这个问题吗?

于 2013-12-26T16:50:15.750 回答