【问题标题】:Magento api giving problem if image not exist如果图像不存在,Magento api 给出问题
【发布时间】:2010-09-17 13:51:03
【问题描述】:

我正在使用 magento api .. 在其中我使用了“catalog_product_attribute_media.create” ..如果它没有在该图像存在的服务器上获取图像,那会出现问题。 问题是..它阻止我的脚本进一步运行 我已经检查过 URL 是否不存在.. 但是我该如何处理这种情况,它正在获取 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));
}

【问题讨论】:

    标签: api magento


    【解决方案1】:

    您是否尝试过检查空字符串?

    if($products[$counter]->small_image_url && $products[$counter]->small_image_url != '')
    

    【讨论】:

    • 我已经检查了 url 是否存在..但是当下载它的服务器上不存在相同 url 图像的名称时,它会出现问题..
    猜你喜欢
    • 2014-10-06
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多