Search code examples
imagemagentomagento-soap-api

Is it possible to link to an existing product image using the Magento Soap API V2?


I am using Magento to offer class registrations. I am using the SOAP API V2 to 'clone' classes to a new date.

I would like to re-use the existing class image, as it seems silly to re-upload the same image hundreds of times.

Is it possible to link to an existing image via the API V2?

catalogProductAttributeMediaCreate() doesn't appear to want to do it with how I've tried. catalogProductAttributeMediaUpdate() doesn't work either, as an image hasn't been created for that product.


Solution

  • try this.

    $proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
    $sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary
    
    $result = $proxy->catalogProductAttributeMediaInfo($sessionId, '2', '/b/l/blackberry8100_2.jpg');
    var_dump($result);
    

    the response :

    array
      'file' => string '/b/l/blackberry8100_2.jpg' (length=25)
      'label' => string '' (length=0)
      'position' => string '1' (length=1)
      'exclude' => string '0' (length=1)
      'url' => string 'http://magentohost/media/catalog/product/b/l/blackberry8100_2.jpg' (length=71)
      'types' =>
        array
          0 => string 'image' (length=5)
          1 => string 'small_image' (length=11)
          2 => string 'thumbnail' (length=9)