Table of Contents

Class ProductViewModelsExporter

Namespace
Dynamicweb.Ecommerce.ProductCatalog
Assembly
Dynamicweb.Ecommerce.dll

Exports a ProductListViewModel or a single ProductViewModel to a ZIP archive containing the product data file (JSON, XML, or CSV) and any associated media assets.

public sealed class ProductViewModelsExporter
Inheritance
ProductViewModelsExporter
Inherited Members

Remarks

Typical usage:

var exporter = new ProductViewModelsExporter("my-export")
{
    ExportFormat = ExportFormat.CSV,
    HostUrl = "https://example.com"
};
exporter.Export(productListModel, imageSettings);
exporter.SendEmail(new[] { "buyer@example.com" });

The resulting ZIP is written to /Files/Exports/{FileName}.zip.

Constructors

ProductViewModelsExporter(string)

Initializes a new exporter with the given base filename.

public ProductViewModelsExporter(string fileName)

Parameters

fileName string

The base filename (without extension) for the ZIP and data file. Invalid characters are stripped automatically; falls back to a timestamp-based name when null or empty.

Properties

ExportFormat

Gets or sets the output format for the product data file. Defaults to None which skips data-file generation.

public ExportFormat ExportFormat { get; set; }

Property Value

ExportFormat

FeedId

Gets or sets an optional feed ID. When set, the export data file is generated using the configured feed provider rather than the built-in JSON/XML/CSV converters.

public int? FeedId { get; set; }

Property Value

int?

FileName

Gets the sanitised base filename (without extension) used for the export ZIP and data file. Set via the constructor.

public string FileName { get; }

Property Value

string

HostUrl

Gets or sets the host URL prepended to the download link in notification emails (e.g. "https://example.com").

public string HostUrl { get; set; }

Property Value

string

LanguageId

Gets or sets the language ID used when generating feed-based exports.

public string LanguageId { get; set; }

Property Value

string

SenderEmail

Gets or sets the email address used as the sender in notification emails. Falls back to the system mail-from address when null or invalid.

public string SenderEmail { get; set; }

Property Value

string

SenderName

Gets or sets the display name of the email sender. Falls back to SenderEmail when null or empty.

public string SenderName { get; set; }

Property Value

string

Subject

Gets or sets the subject line of notification emails. Defaults to "Export products" (success) or "Export products failed" (error).

public string Subject { get; set; }

Property Value

string

TemplatePath

Gets or sets the path to the Razor email template used to render the notification message. Defaults to eCom/ProductCatalog/ExportProductsMail.cshtml.

public string TemplatePath { get; set; }

Property Value

string

Methods

Export(ProductListViewModel, ImageExportSettings)

Exports all products in the list to a ZIP archive, including the data file and any requested images.

public void Export(ProductListViewModel model, ImageExportSettings imageExportSettings)

Parameters

model ProductListViewModel

The product list whose products are exported. Does nothing when null or when Products is null.

imageExportSettings ImageExportSettings

Controls which images are included and their format/size. Pass null to skip image export.

Export(ProductViewModel, ImageExportSettings, IEnumerable<string>, IEnumerable<string>)

Exports a single product to a ZIP archive using the explicitly supplied image and document paths.

public void Export(ProductViewModel model, ImageExportSettings imageExportSettings, IEnumerable<string> images, IEnumerable<string> documents)

Parameters

model ProductViewModel

The product to export.

imageExportSettings ImageExportSettings

Controls image format and size during export.

images IEnumerable<string>

Relative paths of image files to include in the ZIP.

documents IEnumerable<string>

Relative paths of document files to include in the ZIP.

SendEmail(IEnumerable<string>)

Sends a success notification email with a download link to the generated ZIP file.

public void SendEmail(IEnumerable<string> recipientEmails)

Parameters

recipientEmails IEnumerable<string>

The recipient email addresses. Invalid addresses are silently skipped.

SendEmail(IEnumerable<string>, Exception)

Sends an error notification email with exception details to the given recipients.

public void SendEmail(IEnumerable<string> recipientEmails, Exception ex)

Parameters

recipientEmails IEnumerable<string>

The recipient email addresses. Invalid addresses are silently skipped.

ex Exception

The exception that caused the export failure.

See Also

To top