heimrichhannot / contao-entity-import-bundle

2 stars 2 forks source link

Modify data while import #9

Open raum51 opened 2 years ago

raum51 commented 2 years ago

In the JSON file I want to import dates are formatted as strings (e.g. 2023-12-31T00:00:00+00:00), but in the tl-table the date has to get saved as integer.

Is there a possibility to modify data threw import process?

koertho commented 2 years ago

If there is no option in the backend (sorry, I'm not very familar with this bundle), then there are plenty php events, I think this should not be a problem: https://github.com/heimrichhannot/contao-entity-import-bundle#events

vvohh commented 2 years ago

Exactly, the 'BeforeItemImportEvent' will be a good fit for your purpose, you can then use the methods 'getItem()' or 'getMappedItem()' from the event to get to the values from your source, process it as you would prefer then ultimately 'setMappedItem($array)' to continue the process.