MAM Hotfolder Linking

Within the BS Skills module, there is an ActiveScript, that allows to automatically link files in a MAM hot folder to products in PIM based on their file names. This allows to

  • mass import files into the MAM
  • find related products based on its file name matching certain product attributes
  • assign the files to these products reference attributes
  • and finally, move the files to a folder hierarchy that matches the product hierarchy

The key concept of matching file names to product is to use two patterns with two regular expressions:

  • the first pattern extracts one or more tokens from the file name
  • the second pattern then is used to search the products using the tokens from the first pattern

Setup

Create a new ActiveScript and select the script plugin called "BS MAM HotFolder Linking":

Configuration

The script can be configured with several parameters. Please note the information hints appearing on mouseover of the question mark icons next to the configuration parameter names:

The following parameters are available:


For language-dependent file reference attributes, you have an additional parameter "Import Language".



ParameterDescription
Hot FolderMAM folder that will be checked for files
Hot File Pattern

Provide here a pattern that a file in the hot folder must match to be processed. If you use a full pattern syntax including surrounding slashes the pattern is used as-is. If you provide a quick syntax without surrounding slashes you can use a dot (.) as a pattern for dot and * as a pattern for all possible file name characters.

SequenceDefines the sequence multiple files are processed, for example by file name or file date
Filename Extraction Pattern

Provide here a regular expression that extracts the part of the file name you want to use for searching. Surround the parts to use with round brackets, otherwise, the complete pattern will be used. Enclosing the search pattern with leading and trailing slash is optional. Search the internet for "Regular Expressions" to learn more about the required pattern format.

Product Search Pattern

Provide here a regular expression that matches the product information you want to find in the Search Attribute. Use the tokens {0}, {1}, {2}, etc. to refer to the file name part extracted in the previous setting. {0} will be replaced by the complete matched string, {1} by the part in the first brackets, etc. Enclosing the search pattern with leading and trailing slash is optional. Search the internet for "Regular Expressions" to learn more about the required pattern format.

Product Search AttributeThe extracted part of the filename will be searched in this product attribute.
Assign identified Files toThe MAM reference attribute the file should be attached to.
Import languageOnly available for language-dependent file reference attributes. You can select one or more languages to link the founded file.
Mode

Appears for multi-reference target attributes only. Defines how to merge the hot file with existing files. Possible values are:

  • Attach to the end of existing references
  • Attach at the beginning of existing references
  • Replace existing references
Moved unidentified Files toTarget folder where a file is moved to when no product can be found.
Move identified Files toTarget folder where a file is moved to when a product can be found.
Assign ClassesSelected Classes will be applied to the Hotfile
Move to Sub Folder

The file will be moved to a sub-hierarchy in the target folder according to the hierarchy of the first product found.

A custom Path Extension can be added, that is then appended to the sub-hierarchy. Also, classes can be assigned to the target folder, similar to the classes that can be added to the files themselves.

Overwrite existing FilesHow to deal with existing MAM files that already exist in the target directory. If activated the file content of existing files will be overwritten.
Dry Run onlyIf activated the script logs all steps and information it would do, but actually does not execute them. This can be used for testing and debug purposes.

Example

The files imported have the syntax:

  • X14063-031_1.jpg
  • X14063-031_2.jpg
  • X14063-031_3.jpg
  • etc.

and should be attached to the attribute "Alternative Images" of the product identified by the external key "X14063-031".

The search pattern would be

/([A-Z]\d{5}-\d{3})_\d+\.jpg/

The round brackets grep out the part "X14063-031", which can be used as $1 in the product search pattern, which would be simply /{1}/

In the user interface the configuration would look like this: