--- layout: m1x_soap title: Catalog Product Attribute Media ---
The Mage_Catalog module allows you to manage categories and products.
Allows you to manage product images.
Resource Name: catalog_product_attribute_media
Aliases:
Methods:
| 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 |
$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'));