Table of Contents

Class DataMappingFeedProvider

Namespace
Dynamicweb.Ecommerce.Feeds
Assembly
Dynamicweb.Ecommerce.dll

Base class for feed providers whose output is a flat, column-based structure (e.g. CSV, Excel), where each selected field maps to a single output column with a configurable header.

public abstract class DataMappingFeedProvider : FeedProvider, IParameterOptions
Inheritance
DataMappingFeedProvider
Implements
Inherited Members

Properties

IncludeHeaderRow

Gets or sets a value indicating whether the output includes a header row with the column names. When disabled, the headers set on the Mapping tab are not written, but the column order still applies.

[AddInParameter("IncludeHeaderRow")]
[AddInLabel("Include header row")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "reloadOnChange=true")]
public bool IncludeHeaderRow { get; set; }

Property Value

bool

MappingParameterNames

Gets the names of the add-in parameters whose selection becomes the output columns, i.e. the parameters that change what the Mapping tab lists.

public static IReadOnlyList<string> MappingParameterNames { get; }

Property Value

IReadOnlyList<string>

Methods

DecodeHtmlEntities(string?)

Resolves HTML character references in a text value so the same character always reaches the output in the same shape, whichever provider writes it.

protected static string? DecodeHtmlEntities(string? value)

Parameters

value string

Returns

string

Remarks

A quote typed into an "EditorText" (rich text) field is stored as the HTML that editor produced, i.e. &quot;, while the same quote typed into a "Text"/"LargeText" field - or into the same field through the product grid, search-and-replace or an import - is stored verbatim as ". Field values are stored per language, so one language of a product can hold the encoded spelling and another the raw one. A flat file or a spreadsheet carries no markup, so entities are resolved before the value is written. Element markup is intentionally left untouched: dropping tags would silently discard content.

GetAvailableMappingColumns()

Gets every column this provider can output, i.e. the namespaced options of all selectors (see GetMappingColumns()), whether they are selected or not, plus the columns GetMappingColumns() returns. Use it to check a column name that comes from a selection that has not been saved yet.

public virtual IReadOnlySet<string> GetAvailableMappingColumns()

Returns

IReadOnlySet<string>

GetColumns(Feed)

Gets the resolved (system name, header) pairs for the columns currently selected on this provider, applying the headers saved on the Mapping tab (see GetSavedColumnHeaders(Feed)): a column falls back to its raw system name when no label has been saved for it yet, and columns with a saved order come first, sorted by that order, with the rest appended afterwards in GetMappingColumns() (selector-declaration) order.

public IReadOnlyList<(string SystemName, string Header)> GetColumns(Feed feed)

Parameters

feed Feed

Returns

IReadOnlyList<(string SystemName, string Header)>

GetCultureInfo(FeedContextConfiguration)

Resolves the CultureInfo to use for locale-aware formatting (dates, numbers), based on the feed context's LanguageId. Falls back to CurrentCulture if no language is resolvable or its culture tag is invalid.

protected static CultureInfo GetCultureInfo(FeedContextConfiguration feedContextConfiguration)

Parameters

feedContextConfiguration FeedContextConfiguration

Returns

CultureInfo

GetMappingColumns()

Gets the distinct set of output column names, derived from the fields currently selected in the Feed Provider tab (Product, ProductFields, ProductCategoryFields, Price, Assets, AssetCategories, VariantInfo, StockUnits). "Product" columns keep their raw property name; every other selector's columns are namespaced as "{Selector}.{Name}" (e.g. "Assets.Name") so identically-named properties on different view models (see GetValue(ProductViewModel, string, CultureInfo)) never collide into a single output column. Every selector is a strict include-list: a selector with nothing selected contributes no columns, so a feed with no selected fields has no columns and outputs only the data the user chose.

public virtual IReadOnlyList<string> GetMappingColumns()

Returns

IReadOnlyList<string>

GetRowValues(ProductViewModel, IEnumerable<string>, CultureInfo)

Flattens a single product's selected columns into (system name, value) pairs. Each name is resolved via GetValue(ProductViewModel, string, CultureInfo), which routes on the "{Selector}." prefix produced by GetMappingColumns() (an unprefixed name resolves against the "Product" selector).

protected static IEnumerable<(string SystemName, object? Value)> GetRowValues(ProductViewModel product, IEnumerable<string> systemNames, CultureInfo culture)

Parameters

product ProductViewModel
systemNames IEnumerable<string>
culture CultureInfo

Returns

IEnumerable<(string SystemName, object Value)>

Remarks

Scalar columns are returned as their raw CLR value so the caller can write a typed cell; only the collection selectors ("Assets.", "AssetCategories.", "StockUnits.") are flattened to text here, and their separator characters end up literally in the output. Those are rendered with culture - pass the feed language's culture, so the output does not silently depend on CurrentCulture, which is the culture of the server running the feed and has nothing to do with the language selected on it.

One scalar column does not come back as the view model's own value: a field with a value conversion is returned as a ConvertedFieldValue rather than as the display text the view model holds, because that text has already been rendered in the server's culture. Format it for the feed with ToString(string?, IFormatProvider?), passing culture; treating it as a plain object still yields readable text, but invariant.

GetSavedColumnHeaders(Feed)

Resolves the column headers saved on the feed's Mapping tab (its ColumnHeadersPreset) - the label and the output position stored for each mapping column. The base implementation returns none, so every column falls back to its raw system name and keeps GetMappingColumns()' selector-declaration order, because Dynamicweb.Ecommerce cannot reference Dynamicweb.CoreUI (layering), where the preset is stored. Leaf provider projects that DO reference Dynamicweb.CoreUI (e.g. the CSV/Excel feed providers) override this using ColumnHeadersPresetService; an override only has to read the preset, since both the label fallback and the ordering are applied by GetColumns(Feed).

protected virtual IReadOnlyList<FeedColumnHeader> GetSavedColumnHeaders(Feed feed)

Parameters

feed Feed

Returns

IReadOnlyList<FeedColumnHeader>
To top