BlackbitDigitalCommerce / pimcore-data-director

Import Bundle for Pimcore
16 stars 3 forks source link

Removing import file after import #13

Closed betterapp closed 2 years ago

betterapp commented 2 years ago

I can not find in documentation anything about removing import file after import. Is it possible ?

BlackbitDevs commented 2 years ago

Yes. This is in the How to import data to objects section:

  • via CLI by executing one of these scripts:
    • bin/console data-director:extract <Dataport-ID> [--rm] - Parse source resource (e.g. file or URL) and write data to a flat database table (replace with the real ID). If --rm is set, the imported file will get deleted after raw data import. For cronjob imports the --rm flag has to be set because otherwise the importer always imports from the same file.

Currently it is not possible to delete import files when starting the dataport manually from Pimcore backend.

betterapp commented 2 years ago

Hmmm

But one thing is not clear to me: From your youtube video I learned that: If we setup 2 dataport we can setup dependent import. The dependent import (second) will run when first is finished. But the same video says that Dependent import defined in Result callback function is started for every records.

Why am I writing about this?

I was thinking about to use dependent import functionality and instead running dependent import I could remove those file via PHP functions under result callback function.

Will it work ? @BlackbitNeueMedien

This is related with https://github.com/BlackbitDigitalCommerce/pimcore-data-director/issues/17

BlackbitDevs commented 2 years ago

The dependent import (second) will run when first is finished. This is not necessarily true. You can also call a dependent import for each raw data item of the first dataport. Or even implement some logic to trigger dependent dataport for some raw items and for some others not. A bit shortened the callback function template for starting dependent imports looks like this:


$parameters = {{ DEPENDENT DATAPORT PARAMETERS }};

if(($parameters || $params['lastCall']) && $dataportId) { // start import }


`$parameters` refers to a virtual field where you can provide a key-value-array which the dependent import can use to individualize import resource (you can access those parameters via `{{ parameterName }}` in import resource field. If you do not have parameters then it is assumed that you do not want to start dependent import for every raw data item but only after the first import has completely finished. Only on this last raw item `$params['lastCall']` will be `true`.
betterapp commented 2 years ago

I have done it with Callback function