Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Mage_Catalog

The Mage_Catalog module allows you to manage categories and products.

Product Images

Allows you to manage product images.

Resource Name: catalog_product_attribute_media

Aliases:

  • product_attribute_media
  • product_media

Methods:

Faults

Fault CodeFault Message
100Requested store view not found.
101Product not exists.
102Invalid data given. Details in error message.
103Requested image not exists in product images’ gallery.
104Image creation failed. Details in error message.
105Image not updated. Details in error message.
106Image not removed. Details in error message.
107Requested product doesn’t support images

Examples

Example 1. Working with product images
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$newImage = array(
    'file' => array(
        'name' => 'file_name',
        'content' => base64_encode(file_get_contents('product.jpg')),
        'mime'    => 'image/jpeg'
    ),
    'label'    => 'Cool Image Through Soap',
    'position' => 2,
    'types'    => array('small_image'),
    'exclude'  => 0
);

$imageFilename = $proxy->call($sessionId, 'product_media.create', array('Sku', $newImage));


var_dump($imageFilename);

// Newly created image file
var_dump($proxy->call($sessionId, 'product_media.list', 'Sku'));

$proxy->call($sessionId, 'product_media.update', array(
    'Sku',
    $imageFilename,
    array('position' => 2, 'types' => array('image') /* Lets do it main image for product */)
));

// Updated image file
var_dump($proxy->call($sessionId, 'product_media.list', 'Sku'));

// Remove image file
$proxy->call($sessionId, 'product_media.remove', array('Sku', $imageFilename));

// Images without our file
var_dump($proxy->call($sessionId, 'product_media.list', 'Sku'));

Create the Magento file system owner


Table of contents