Possible configuration types

Override priority for user-defined values:
  1. Values set on the command line with --params will override values defined in the configuration file

  2. Values specified under a separate file set with the --params-file option in the configuration file will override values set on the command line

As configuration snippets

The import:products command uses and executes only the operations specified by the given shortcut, e.g., add-update.

The command-line options can specify the database configuration.

It is necessary to provide a custom configuration snippet that enables the flags and containing the paths to the image files:

This custom snippet requires the JSON format and can be named with any name, e.g., images.json, and must get placed in the predefined custom location.

Example

It is possible to create a snippet with params, e.g. <custom-configuration-dir>/params.json, which contains values as follows:
{
  "params": {
    "my-website-country-mapping": { (1)
      "DE": [ "de_DE", "de_AT", "de_CH" ],
      "EN": [ "en_US", "en_UK" ]
    }
  }
}
1 Defining the custom option my-website-country-mapping
User-defined parameters can then get used wherever access to the configuration object is possible, e.g., in an observer such as:
<?php

namespace My\Project;

use TechDivision\Import\Observers\AbstractObserver;

/**
 * A custom observer implementation.
 */
class MyObserver extends AbstractObserver
{

    /**
     * Return's the global param with the passed name.
     *
     * @param string $name The name of the param to return
     * @param mixed $defaultValue The default value if the param doesn't exist
     *
     * @return string The requested param
     * @throws \Exception Is thrown, if the requested param is not available
     */
    public function getGlobalParam($name, $defaultValue = null)
    {
        return $this->getSubject()->getConfiguration()->getConfiguration()->getParam($name, $defaultValue);
    }

    /**
     * Will be invoked by the action on the events the listener has been registered.
     *
     * @param \TechDivision\Import\Subjects\SubjectInterface $subject The subject instance
     *
     * @return array The modified row
     */
    public function handle(SubjectInterface $subject)
    {

        // load the params from the configuration
        $myWebsiteMapping = $this->getGlobalParam('my-website-country-mapping'); (1)

        // do something with the configuration value
    }
}
1 The custom option my-website-country-mapping gets called in a observer method

As command-line option

In addition to the parameters defined in the configuration file, it is possible to specify parameters via the command line as an option as well.

CLI based call to set the custom configuration option my-website-country-mapping
bin/import-cli-simple.phar import:products \ (1)
--params='{ "params": { "my-website-country-mapping": { "DE": [ "de_LI" ] } } }' (2)
1 Add additional --params to the CLI command import:products
2 set the configuration option my-website-country-mapping with predefined values

As file based defined option

It is possible to refer to a separate configuration file containing JSON encoded parameters by specifying a path.

Override priority for user-defined values:
  1. Values set on the command line with --params will override values defined in the configuration file

  2. Values specified under a separate file set with the --params-file option in the configuration file will override values set on the command line

The file must follow the following format:
File based configuration
{
  "params": {
    "my-website-country-mapping": {
      "DE": [ "de_LI" ]
    }
  }
}