Class SchemaOrgRelationMappingService
- Namespace
- Dynamicweb.Ecommerce.ProductCatalog.SchemaOrg
- Assembly
- Dynamicweb.Ecommerce.dll
Manages the configured mappings of Dynamicweb product relation groups to Schema.org Product relation properties.
public abstract class SchemaOrgRelationMappingService
- Inheritance
-
SchemaOrgRelationMappingService
- Inherited Members
Remarks
A mapped relation group contributes its related products to the configured property when the Schema.org Product model is generated. A relation property without a mapping is not written at all.
Several groups can be mapped to the same property, in which case their related products are written to the same array in mapping sort order.
Register an implementation of this type to keep the configuration somewhere other than the EcomSchemaOrgMapping table; SchemaOrgProductFactory reads the mappings through this type.
Methods
DeleteByIds(IEnumerable<int>)
Deletes the mappings that match the given IDs.
public abstract void DeleteByIds(IEnumerable<int> mappingIds)
Parameters
mappingIdsIEnumerable<int>The IDs of the mappings to delete.
Exceptions
- ArgumentNullException
Thrown when
mappingIdsisnull.
GetAll()
Gets all configured mappings, ordered by property and sort order.
public abstract IEnumerable<SchemaOrgRelationMapping> GetAll()
Returns
- IEnumerable<SchemaOrgRelationMapping>
The configured mappings.
GetById(int)
Gets the mapping with the given ID.
public abstract SchemaOrgRelationMapping? GetById(int id)
Parameters
idintThe mapping ID.
Returns
- SchemaOrgRelationMapping
The mapping, or
nullwhen no mapping has the given ID.
GetByProperty(SchemaOrgProductProperty)
Gets all mappings configured for the given Schema.org Product relation property, across all languages.
public abstract IEnumerable<SchemaOrgRelationMapping> GetByProperty(SchemaOrgProductProperty productProperty)
Parameters
productPropertySchemaOrgProductPropertyThe property to get the mappings for.
Returns
- IEnumerable<SchemaOrgRelationMapping>
The mappings configured for the property.
GetMappingsByProperty(string?)
Gets the mappings that apply in the given language, grouped by property and ordered by sort order. A mapping for the specific language takes precedence over a mapping that applies to all languages.
public abstract IReadOnlyDictionary<SchemaOrgProductProperty, IReadOnlyList<SchemaOrgRelationMapping>> GetMappingsByProperty(string? languageId)
Parameters
languageIdstringThe language the mappings are resolved for.
Returns
- IReadOnlyDictionary<SchemaOrgProductProperty, IReadOnlyList<SchemaOrgRelationMapping>>
The mappings that apply, grouped by property.
Remarks
This is read once per product while the JSON-LD is generated, so the mappings are not copied: treat them as read-only, and use GetById(int) to get a mapping to change.
Save(SchemaOrgRelationMapping)
Saves the mapping. A mapping without an ID is created, an existing mapping is updated.
public abstract void Save(SchemaOrgRelationMapping mapping)
Parameters
mappingSchemaOrgRelationMappingThe mapping to save.
Exceptions
- ArgumentNullException
Thrown when
mappingisnull.