|
I’m doing this. I use curl to obtain the external image, and keep rewriting to the same file (xqrft).
This is part of a routine that imports many hundreds of products at a time, including their image files. To keep if from timing out, I run my php script from the command line.
Here is some partial code:
print “$sku \n”;
fwrite($thandle, “$sku \n");
print “$imageloc \n”;
fwrite($thandle, “$imageloc \n");
$got_image = 0;
for ($ik = 0; $ik < 3; $ik++) {
$ch = curl_init();
//$timeout = 15; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $imageloc);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
$html = curl_exec($ch);
print “\ncurl error (if any) = “ . curl_error($ch) . “\n\n”;
fwrite($thandle, “\ncurl error (if any) = “ . curl_error($ch) . “\n\n");
$cerror = curl_error($ch);
curl_close($ch);
if( $cerror == ‘’) {break;}
}
$handle = fopen(’/usr/home/xxxx/sec-pic-images/xqrft’,’w’);
fwrite($handle,$html);
fclose($handle);
usleep(500000); // give file time to close
$imagetype = image_type_to_mime_type(exif_imagetype(’/usr/home/xxxxxx/sec-pic-images/xqrft’));
print “image type = $imagetype\n\n”;
fwrite($thandle, “image type = $imagetype\n\n");
$newImage = array(
‘file’ => array(
‘content’ => base64_encode(file_get_contents(’/usr/home/xxxxxxxx/sec-pic-images/xqrft’)),’mime’ => $imagetype),
‘types’ => array(’image’,’small_image’,’thumbnail’),
‘exclude’ => 0);
try{
$imageFilename = $proxy->call($sessionId, ‘product_media.create’, array($sku, $newImage));
}
catch (SoapFault $e) {
print “$e\nimage error for SKU “ . $sku . “\n”;
fwrite($thandle, “$e\nimage error for SKU “ . $sku . “\n");}
}
Azim - 30 September 2009 12:28 PM Hello,
This has been posted so many times, But no good help is available to this issue.
Some say do this and some say do that. And most of them don’t work.
I need a real help here. I am importing over 12000 products to magento, I get everything to work fine except for images from external link.
I need to import images for all products from external links and have them imported to my magento server.
Some posts say that add a slash before images and put your images in media/import folder and it will work. But how can you remove the rl from the image and just add a slash to 12000 products.
So i need some easy to do steps.
Please help. Thanks
|