I am using Drupal-6. I Created CCK Field with Select Box with content type name as list_porducts.
i am fetching products from external url . Here is my code
$key=array();
$flowervalue=array();
for($i=2;$i<=150; $i++) {
$url="http://testurl.com/test/node/".$i.".jsonp";
$timeout=0;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
$jdata=json_decode($data);
if($jdata->type=='product') {
$key[]=$jdata->nid;
$flowervalue[]=$jdata->title." ".$jdata->field_petals_code[0]->value;
}
}
$res=array_combine($key, $flowervalue);
return $res;
which is running properly. Now Problem is this is Quite slow. and i guess it is running for all page load.
Any Idea how to do this.
Thanks