tags:

views:

47

answers:

1

hello all

I am using magento api .. in which i have used "catalog_product_attribute_media.create" ..thats giving problem if it doesn't get image on server where this image exist. problem is that ..it stoping my script to run further I have checked if URL is none.. but how can i handle this situation that is it getting url ...but image not exist

here is my code...

  if($products[$counter]->small_image_url){//check if url exists
    $newImage = array(
     'file' => array(
       'name' => 'file_name',
         'content' => base64_encode(file_get_contents($products[$counter]->small_image_url)),
         'mime'    => 'image/jpeg'),
         'label'    => $products[$counter]->product_name,
         'position' => 2,
         'types'    => array('thumbnail_image'),
         'exclude'  => 0
         );
 $imageFilename = $proxy->call($sessionId, 'product_media.create', array($sku, $newImage));
}
A: 

Have you tried checking for an empty string?

if($products[$counter]->small_image_url && $products[$counter]->small_image_url != '')
Jonathan Day
i have checked url exist or not ..but its giving problem when with the name of same url image is not existing on server from where it is downloaded ..
Richa