Product API
This is an old revision of the document!
Allows to import/export products to/from Magento
Module: Mage_Catalog
Resource: catalog_product
Aliases:
- product
Methods |
catalog_product.currentStore |
Set/Get current store view
Return: int
Arguments:
- mixed storeView - store view ID or code (optional)
Aliases:
- product.currentStore
catalog_product.list |
Retrieve products list by filters
Return: array
Arguments:
- array filters - array of filters by attributes (optional)
- mixed storeView - store view ID or code (optional)
Aliases:
- product.list
catalog_product.info |
Retrieve product
Return: array
Arguments:
- mixed product - product ID or Sku
- mixed storeView - store view ID or code (optional)
- array attributes - list of attributes that will be loaded (optional)
Aliases:
- product.info
catalog_product.create |
Create new product and return product id
Return: int
Arguments:
- string type - product type
- int set - product attribute set ID
- string sku - product SKU
- array productData - array of attributes values
Aliases:
- product.create
catalog_product.update |
Update product
Return: boolean
Arguments:
- int product - product ID
- array productData - array of attributes values
- mixed storeView - store view ID or code (optional)
Aliases:
- product.update
catalog_product.setSpecialPrice |
Update product special price
Return: boolean
Arguments:
- mixed product - product ID or Sku
- float specialPrice - special price (optional)
- string fromDate - from date (optional)
- string toDate - to date (optional)
- mixed storeView - store view ID or code (optional)
Aliases:
- product.setSpecialPrice
catalog_product.getSpecialPrice |
Get product special price data
Return: array
Arguments:
- mixed product - product ID or Sku
- mixed storeView - store view ID or code (optional)
Aliases:
- product.getSpecialPrice
catalog_product.delete |
Delete product
Return: boolean
Arguments:
- mixed product - product ID or Sku
Aliases:
- product.delete
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. 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. Product create/view/update/delete |
- $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";
- }


