2012-03-27 123 views

回答

0

您可以通過Web服務API發送圖像。

我用下面就我們的項目的一個片段:

 
    $image_entry = ... 
    $imagePath = $dir.$image_entry['nimi']; 
    if(file_exists($imagePath)){ 
     //$sku = microtime();//$result['kood']; 
     $newImage = array(
      'file' => array(
       'name' => $image_entry['nimi'], 
       'content' => base64_encode(file_get_contents($imagePath)), 
       'mime' => 'image/jpeg' 
      ), 
      'label' => $image_entry['nimi'], 
      'position' => 0, 
      'types' => array('image', 'small_image', 'thumbnail'), 
      'exclude' => 0 
     ); 
     try { 
      $imageFilename = $proxy->call($sessionId, 'product_media.create', array($sku, $newImage));  
     } 
     catch(Exception $e) { 
      print("Error assigning image to $sku: " . $e->getMessage() . "\n"); 
     } 
    } 

另一種選擇是覆蓋Magento的默認行爲直接從另一臺主機鏈接文件 - 非常糟糕的選擇。

還有一個選項 - 使用PHP下載圖像,但您需要更改導入模塊的行爲以下載圖像。