m openmage

OpenMage LTS Developer Documentation

Catalog Product

Edit this page on GitHub

Module: Mage_Catalog

The Mage_Catalog module allows you to manage categories and products.

Product

Allows you to manage products.

Resource Name: catalog_product

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 Product not deleted. Details in error message.

Examples

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

$filters = array(
    'sku' => array('like'=>'zol%')
);

$products = $proxy->call($sessionId, 'product.list', array($filters));

var_dump($products);
Example 2. Creating, viewing, updating, and deleting a product
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$attributeSets = $proxy->call($sessionId, 'product_attribute_set.list');
$set = current($attributeSets);


$newProductData = array(
    'name'              => 'name of product',
     // websites - Array of website ids to which you want to assign a new product
    'websites'          => array(1), // array(1,2,3,...)
    'short_description' => 'short description',
    'description'       => 'description',
    'status'            => 1,
    'weight'            => 0,
    'tax_class_id'      => 1,
    'categories'    => array(3),    //3 is the category id
    'price'             => 12.05
);

// Create new product
$proxy->call($sessionId, 'product.create', array('simple', $set['set_id'], 'sku_of_product', $newProductData));
$proxy->call($sessionId, 'product_stock.update', array('sku_of_product', array('qty'=>50, 'is_in_stock'=>1)));

// Get info of created product
var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));

// Update product name on german store view
$proxy->call($sessionId, 'product.update', array('sku_of_product', array('name'=>'new name of product'), 'german'));

// Get info for default values
var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
// Get info for german store view

var_dump($proxy->call($sessionId, 'product.info', array('sku_of_product', 'german')));

// Delete product
$proxy->call($sessionId, 'product.delete', 'sku_of_product');

try {
    // Ensure that product deleted
    var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
} catch (SoapFault $e) {
    echo "Product already deleted";
}
Create the Magento file system owner