如果图像不存在,Magento api 会出现问题
我正在使用 magento api .. 其中我使用了“catalog_product_attribute_media.create”..如果它没有在存在该图像的服务器上获取图像,则会出现问题。 问题是..它阻止我的脚本进一步运行 我已经检查过 URL 是否为 None..但是我该如何处理这种情况,即它获取 url ...但图像不存在,
这是我的代码...
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));
}
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));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过检查空字符串?
Have you tried checking for an empty string?