m openmage

OpenMage LTS Developer Documentation

Catalog Product Attribute Media

Edit this page on GitHub

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:

Methods:

Faults

Fault Code Fault Message
100 Requested store view not found.
101 Product not exists.
102 Invalid data given. Details in error message.
103 Requested image not exists in product images’ gallery.
104 Image creation failed. Details in error message.
105 Image not updated. Details in error message.
106 Image not removed. Details in error message.
107 Requested 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