Call-back icon  Sales: Call 800.374.8146 (N America)|757.278.0920 (International)

Magento

Open Source eCommerce Evolved

Product API

Last modified by Refugnic on Mon, August 11, 2008 04:37
Source|Old Revisions  

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:

  • 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.     'name'              => 'name of product',
  10. //A possible value is also 1 for the base website. Base didn't work for me.
  11. //  'websites'          => array(1),
  12.     'websites'          => array('base'),
  13.     'short_description' => 'short description',
  14.     'description'       => 'description',
  15.     'price'             => 12.05
  16. );
  17.  
  18. // Create new product
  19. $proxy->call($sessionId, 'product.create', array('simple', $set['set_id'], 'sku_of_product', $newProductData));
  20.  
  21. // Get info of created product
  22. var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  23.  
  24. // Update product name on german store view
  25. $proxy->call($sessionId, 'product.update', array('sku_of_product', array('name'=>'new name of product'), 'german'));
  26.  
  27. // Get info for default values
  28. var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  29. // Get info for german store view
  30. var_dump($proxy->call($sessionId, 'product.info', array('sku_of_product', 'german')));
  31.  
  32. // Delete product
  33. $proxy->call($sessionId, 'product.delete', 'sku_of_product');
  34.  
  35. try {
  36.     // Ensure that product deleted
  37.     var_dump($proxy->call($sessionId, 'product.info', 'sku_of_product'));
  38. } catch (SoapFault $e) {
  39.     echo "Product already deleted";
  40. }



 

Popular Wiki Tags  |  View all

 observer   model   clienti magazin   pdf   video   image   upload   CRM   vtiger   diagram   schema   CGI   pages   registration   security 

Professional Services from the Magento Team

Professional Installation from the Magento Team

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs
Sales: Call 800.374.8146 (North America) 757.278.0920 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
33649 users|434 users currently online|74620 forum posts