[TYPO3-mvc] Import Script Problems

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Jun 17 10:33:45 CEST 2010


Hi,

> One thing:
> Keeping track of removed/disable objects in regular full imports is a bit
> tricky (I.e. Rows have been removed from the csv file by the foreign
> system).
>
> I do it by flagging all objects as "hidden" prior to the import and setting
> the hidden filed to false within the import.
>
> Don't use the deleted field since you will get in trouble due to the
> "special handling"(RemoveAll<->  set deleted=true) of this field.
>
> If you decide to use the hidden field make sure you use your own find
> function for the import having:
> "$query->getQuerySettings()->setRespectEnableFields(FALSE);"

Thanks for the hint.

> If you need to create relations during the import, it's a good idea to make
> use of some first level caching within the import domain service. In order
> to reduced the database load and increase overall performance.

What do you mean with first level caching? That I first should import 
all "base" objects storing their uids in a intermediate table/array and 
after that create the related objects?

>> Reason why I'm asking is, that I intended to make the CSV files
>> mappable
>> to the object properties and thus would have to dynamically build the
>> setter-names (which is of course not a problem, but a bit more work).
> Interessting...not sure if i fully got what you are planning to do, could
> you provide some additional information?.

Unfortunately the structure and column naming of the source of my import 
script is not entirely fixed - so I need a way to read the headers of 
the CSV file and map them to my object properties. Of course I could 
still populate my object using setters (or via 
objectAccess->setProperty) then, but I'm not in favor of writing code 
over and over again for stuff like "if field in import data is not 
empty, set it, but only if the current import is allowed to overwrite 
existing data...". So I decided to define a mapping array with 
additional meta information (like when I need to check up TCA for the 
correct value) and iterate over it to dynamically populate the object. 
So it's some sort of basic importer script that I could easily adopt to 
other objects etc.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list