Class ImportBase
Base class for different types of asset import implementations.
Inherited Members
Namespace: Mediachase.Commerce.Assets.Import
Assembly: Mediachase.Commerce.dll
Version: 10.8.0Syntax
public abstract class ImportBase
Constructors
ImportBase(String, String)
Initializes a new instance of the ImportBase class.
Declaration
public ImportBase(string assetPath, string assetFolderName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | assetPath | The local file path where the files to import are present. |
| System.String | assetFolderName | Name of the asset folder that will be used/created in ECF. |
Properties
AssetFolder
Gets the ECF asset folder where to store imported assets.
Declaration
public FolderEntity AssetFolder { get; }
Property Value
| Type | Description |
|---|---|
| FolderEntity |
AssetGroups
Gets all available asset groups.
Declaration
public string[] AssetGroups { get; }
Property Value
| Type | Description |
|---|---|
| System.String[] |
Remarks
The asset groups are determined by subfolders on the first level below the AssetPath. I e if you have the AssetPath set as "C:\Images" and below the folder you have "Small", "Medum", and "Large" then your asset groups will be "Small", "Medium" and "Large".
AssetPath
Gets the local file path where assets to import are stored.
Declaration
public string AssetPath { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
AssociateAssetsWithProduct(IEnumerable<AssetWrapper>, CatalogEntryDto)
Associates the assets with aproduct.
Declaration
public void AssociateAssetsWithProduct(IEnumerable<AssetWrapper> assets, CatalogEntryDto productDto)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<AssetWrapper> | assets | The imported assets to associate with product. |
| CatalogEntryDto | productDto | The product that should receive the assets. |
DoImport(IEnumerable<AssetMapping>)
Does the import.
Declaration
public abstract void DoImport(IEnumerable<AssetMapping> entries)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<AssetMapping> | entries | The entries to import. |
FullAssetPath(String[])
Gets the full path to an asset file.
Declaration
public string FullAssetPath(params string[] segments)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String[] | segments | The segments for the asset file. |
Returns
| Type | Description |
|---|---|
| System.String | A correctly joined file path pointing to the asset file. |
GetOrCreateElementEntity(FolderEntity, String, String)
Gets the asset or creates it if it does not exist.
Declaration
public FolderElementEntity GetOrCreateElementEntity(FolderEntity parentFolderEntity, string assetName, string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| FolderEntity | parentFolderEntity | The parent folder entity. |
| System.String | assetName | Name of the asset. |
| System.String | filePath | The file path where the asset to import is located. |
Returns
| Type | Description |
|---|---|
| FolderElementEntity | A FolderElementEntity to associate with products/variations. |
Remarks
This method will use an existing asset in ECF with the same name if it is found. However there is no check that this existing asset contains the same data as the asset we're trying to import. If you need to re-import assets with the same name, but new content you need to clear out the asset folder first.
GetOrCreateFolderEntity(FolderEntity, String)
Declaration
public FolderEntity GetOrCreateFolderEntity(FolderEntity parentEntity, string folderName)
Parameters
| Type | Name | Description |
|---|---|---|
| FolderEntity | parentEntity | |
| System.String | folderName |
Returns
| Type | Description |
|---|---|
| FolderEntity |
GetProductDto(String)
Gets the DTO object for a product/variation from ECF.
Declaration
public CatalogEntryDto GetProductDto(string productCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | productCode | The product code. |
Returns
| Type | Description |
|---|---|
| CatalogEntryDto | A catalogEntryDto or null if not found. |
ValidAssetGroups(String)
Gets all valid asset groups for the asset.
Declaration
public IEnumerable<string> ValidAssetGroups(string assetName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | assetName | Name of the asset. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<System.String> | The valid asset groups. |
Remarks
This handles the case when the mapping file (csv file) contains an entry that maps an asset to a product, but the asset file does not exist in all the different asset group folders. In that case we will only import the asset that actually exists.