Mass create assets from a CSV


(autjoe) #1

I am trying to mass create assets using a .csv file from a database containing all the metadata value. I was using csv_to_xml_actions.php and successfully to create all the assets with its metadata values. However, by using this script, it didn’t create the bodycopy div for the asset. Just wondering if it is possible to use this script or other script  (import_asset_csv_to_matrix.php) to do this task and how, as it is a bit confuse in Squiz manuals.

Thanks.


(Edison Wang) #2

This is indeed a problem of this legacy script.

 

The import/export from xml script assumes every assets including every sub assets to be created and set value explicitly.

But the csv_to_xml_actions.php will only create the main assets. It's ok for folders, but not ok for dependent children assets of standard pages.

 

To workaround it,  you might be able to temporarily change the code of import_from_xml.php, 

$GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_OPEN);

to

$GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);

 

which will allow it to create all sub assets automatically. This should get your import working. (i haven't tested, but in theory it should)

 

But in the long term, we should add an option to the import script, to allow user to specify if sub assets should be automatically created. In most case, we don't really want it to create sub assets automatically.