Product API

Last modified by Igor Kuzyk on Fri, July 4, 2008 12:37
Source|Old Revisions  

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
  • array productData - array of attributes values

Aliases:

  • product.create

catalog_product.update

Update product

Return: boolean

Arguments:

  • mixed product - product ID or Sku
  • 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

  1. $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sessionId = $proxy->login('apiUser', 'apiKey');
  3.  
  4. $filters = array(
  5.     'sku' => array('like'=>'zol%')
  6. );
  7.  
  8. $products = $proxy->call($sessionId, 'product.list', array($filters));
  9.  
  10. var_dump($products);

Example 2. Product create/view/update/delete

  1. $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sessionId = $proxy->login('apiUser', 'apiKey');
  3.  
  4. $attributeSets = $proxy->call($sessionId, 'product_attribute_set.list');
  5. $set = current($attributeSets);
  6.  
  7.  
  8. $newProductData = array(
  9.     'sku'               => 'sku_of_product',
  10.     'name'              => 'name of product',
  11.     'websites'          => array('base'),
  12.     'short_description' => 'short description',
  13.     'description'       => 'description',
  14.     'price'             => 12.05
  15. );
  16.  
  17. // Create new product
  18. $proxy->call($sessionId, 'product.create', array('simple', $set['set_id'], $newProductData));
  19.  
  20. // Get info of created product
  21. var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  22.  
  23. // Update product name on german store view
  24. $proxy->call($sessionId, 'product.update', array('sku_of_product', array('name'=>'new name of product'), 'german'));
  25.  
  26. // Get info for default values
  27. var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  28. // Get info for german store view
  29. var_dump($proxy->call($sessionId, 'product.info', array('sku_of_product', 'german')));
  30.  
  31. // Delete product
  32. $proxy->call($sessionId, 'product.delete', 'sku_of_product');
  33.  
  34. try {
  35.     // Ensure that product deleted
  36.     var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  37. } catch (SoapFault $e) {
  38.     echo "Product already deleted";
  39. }



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs