cobwebch / external_import

Other
20 stars 16 forks source link

Question: Handle import of 1:m (single select) table relation if record in foreign table is missing #332

Open bh-teufels opened 4 months ago

bh-teufels commented 4 months ago

Is there a function in the base that creates a record when mapping to another table (1:m single select) if it is not found?

e.g.:

my Import:

<ad>
   [...]
    <vehicleClass>Car</vehicleClass>
   [...]
</ad>

my mapping:

'field' => 'vehicleClass',
        'transformations' => [
            10 => [
                'mapping' => [
                    'table' => 'tx_myext_domain_model_vehicleclass',
                    'referenceField' => 'external_id',
                ]
            ]

it is working if i create record and set the external_id to 'Car' but if no record with external_id 'Car' is existing then logically not

Is there a basic function that creates the record on the fly in this case? or would an import configuration have to be made in advance for the table 'tx_myext_domain_model_vehicleclass? An alternative would probably be to handle it yourself via UserFunction

Thank you

fsuter commented 4 months ago

The usual of doing this with External Import is to run 2 imports: first import the vehicle classes, then the vehicles. That's why the priority and groupproperties exists: you can group configurations to run them all in one go, and the configurations are run from smaller priority to higher priority. Thus you can ensure that classes are imported before vehicles.