Partager via


What Are the Export Options?

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

To export a catalog, use one of the ExportXml methods of the CatalogContext object. These methods let you specify whether to export the catalog as an XML file or as a data stream.

Use the CatalogExportOptions parameter to specify the options that control the export operation. The reference topic CatalogExportOptions describes these options and how to use them. This section provides additional information for some of these options.

Properties to Export

The PropertiesToExport property specifies the properties to export. Only the properties specified and the mandatory properties are exported.

Format Type

The FormatType property specifies the format of the exported file. Set this property to CatalogFormatXsd to generate an XSD file. Set this property to CatalogFormatAttributeCentric to generate a file that is attribute-centric.

Export Deleted Items

The catalog system keeps track of products and categories deleted from individual catalogs. Use the ExportDeletedItems property to export these deleted items to your XML file. This option is particularly useful if you want to use import/export for staging data from staging to production servers and to delete catalog items deleted from your staging server on your production server.

Export Modes

The Mode property provides two modes for exporting catalog data. The Full mode exports an entire catalog. You can specify which catalogs to export by using the CatalogsToExport or CatalogSetsToExport property. If these properties are empty, all catalogs in the system are exported.

The ExpressionBased mode lets you export selected items by specifying an SQL-based search expression to select specific data. You specify this expression in the ProductsAndCategoriesClause property. This expression must be applicable to all catalogs that are being exported. If you are exporting multiple catalogs, and if one catalog does not contain the property in the expression, the export fails. For example, if your ProductsAndCategoriesClause is "Description like N'%test%'" and a catalog does not contain the property "Description", the export will fail.

This property provides basic incremental export. Every node of the database is tested against this query. Items that match the query are put in a list to be exported. This list is then expanded according to criteria determined by the value of the Descendants property.

If this value is None, only the items on the list are exported.

If this value is ImmediateChildren, only one level of descendants is included in the list.

If the value is All, all descendants are included in the list.

The descendants in the list, if any, can be filtered further by using the FilterDescendantsClause property. This property is an SQL-based query that you create. The properties specified in this clause must be defined for all catalogs in the system.

For example, if you want to export all items in a category that have a price greater than some amount, you would use code similar to the following:

// Look only at items in 'Category1'.
exportOptions.Mode = ExportMode.ExpressionBased;
exportOptions.ProductsAndCategoriesClause = String.Format("{0}='Category1'", CatalogItemsDataSetSchema.CategoryName);
// Look at all items in this category.
exportOptions.Descendants = Descendants.All;
// Of the items in this category, export those that have a list price greater than $10.00.
exportOptions.FilterDescendantsClause = String.Format("{0} > 10", CatalogItemsDataSetSchema.ListPrice);

Reporting Export Status

If an error occurs during the export operation, the file is deleted and the operation must be restarted. The ExportXml method returns an ExportProgress object that contains information about the status of the export operation. It contains a value of CatalogOperationsStatus that specifies the status of the operation and a CatalogErrorCollection object that contains any errors that have occurred.

Warning

Do not delete catalogs while they are being exported because this could cause a deadlock.

See Also

Other Resources

How to Export a Catalog to an XML File

How to Export Selected Fields of a Catalog

Importing Catalog Data by Using the Catalog API

Developing with the Catalog System