Forum
Problem Importing Asset into Collection with Imports API
Hi,
I'm building a bespoke app for a client using the new Import API in Runway.
We're importing a series of images into the assets library (this works) and then including these within the import of a CSV of product data into a collection.
The CSV is imported. The images are imported into assets. But the images are not imported with the CSV data - no errors are displayed. Here's my diag report:
Perch Runway: 3.0.4, PHP: 5.4.13, MySQL: 5.5.30, with PDO
Server OS: Linux, apache2handler
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_blog (5.5.1), lda_auction (0.1), lda_auction (2.1), perch_members (1.6.1)
App runtimes: <?php $apps_list = array( 'perch_members', 'perch_blog', 'lda_auction', );
PERCH_RESFILEPATH: /var/www/vhosts/domain/domain/files
PERCH_LOGINPATH: /admin
PERCH_PATH: /var/www/vhosts/domain/domain/admin
PERCH_CORE: /var/www/vhosts/domain/domain/admin/core
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: domain
DOCUMENT_ROOT: /var/www/vhosts/domain/domain
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Here's my import function:
try {
$CollectionImporter->add_item([
'Venue' => "$csv_array[0]",
'Sale-Lot-#' => "$csv_array[2]",
'Product-Title' => "$csv_array[6]",
'Image1_assetID' => 230, <- will be replaced with variable once working
'Image2_assetID' => 228,
]);
} catch (Exception $e) {
die('Error: '.$e->getMessage());
}
My images appear within a collection template and can be used via Collections:
<perch:content type="image" id="Image1" label="Image #1" width="1920" crop="true"/>
<perch:content type="image" id="Image2" label="Image #2" width="1920" crop="true"/>
The $csv_data[] items are imported correctly. The images are not imported - despite being imported correctly themselves (i.e. asset 230 and 228 already exist on the server).
Any ideas? Thanks!
I'll run it up here and see if I can reproduce it.
Thanks Drew - and whilst I think, is it possible to import an array of assets, to populate a repeater tag? Something like:
There's not a way to import repeaters or blocks in the current version.
Interested in reply on this. Thanks
Hi Drew - just wondering if you'd had time to look at this yet? Thanks.
Importing into repeaters?
No, sorry, that was a secondary query. Just the bit at the top - followed the Import API docs, the images are being added to the asset bucket and the ID of the asset included within the collection import but the images aren't being included in the collection record.
Ah right, no I haven't I'm afraid.