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
fileNamestringThe 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
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
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
LanguageId
Gets or sets the language ID used when generating feed-based exports.
public string LanguageId { get; set; }
Property Value
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
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
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
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
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
modelProductListViewModelThe product list whose products are exported. Does nothing when null or when
Productsis null.imageExportSettingsImageExportSettingsControls 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
modelProductViewModelThe product to export.
imageExportSettingsImageExportSettingsControls image format and size during export.
imagesIEnumerable<string>Relative paths of image files to include in the ZIP.
documentsIEnumerable<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
recipientEmailsIEnumerable<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
recipientEmailsIEnumerable<string>The recipient email addresses. Invalid addresses are silently skipped.
exExceptionThe exception that caused the export failure.