importing a file and setting up the relationships through code
I am trying to import a pod with a multi-pick column. The basic structure is a flower product can have one or more colours. I have created a "colour" pod and populated this with all the colours I need to import the flower product.
Reading the doc http://podscms.org/codex/api#import , I have written my code to import as :
$data = array(
0 => array(
'name' => 'test import12345',
'price' => '5.55',
'caption' => 'this is a test'
,'colour' => array('grey','yellow')
)
);
$podOb = new PodAPI('flowers');
$podOb->import($data);
I get an error 'Cannot add relationships; SQL: INSERT INTO wp_pod_rel (pod_id, sister_pod_id, field_id, tbl_row_id, weight) VALUES (29, 0, 21, grey, 0); Response: Unknown column 'grey' in 'field list''
What I have tried :
- Re-adding the colour "grey"
- Just having one colour
- double check that "colour" is a multi-pick column in my flower pod
edited Sep 3 '10 at 9:12
3 Answers
I have the same problem. Did you have found a solution?
Does using this work? <pre> ,'colour.name' => array('grey','yellow') </pre>
What version of Pods are you guys using?
'colour.name' => array(....) won't work, but you have two options:
'colour' => array(1,4,6) // reference by ID and use $api->import($data, true); to run in numeric mode (using IDs not 'name' for reference)
'colour' => array('grey','red') // reference by 'name' and use $api->import($data); to run in normal mode
Something to note is that this is case-sensitive, so you'll need to ensure the name matches exactly. Also, it won't add items for you on the PICK, it only references existing items.
