Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Mage_Catalog

Resource: catalog_product

Aliases:

  • product
Method:
  • catalog_product.create (SOAP V1)
  • catalogProductCreate (SOAP V2)

Allows you to create a new product and return ID of the created product.

Aliases:

  • product.create

Note:

Although the API accepts up to four digits of precision for all price arguments, Magento strongly recommends you pass in two digits to reduce inaccuracy in the tax calculation process. (That is, use a price like 12.35 and not 12.3487).

Arguments:

TypeNameDescription
stringsessionIdSession ID
stringtypeProduct type
stringsetID of the product attribute set
stringskuProduct SKU
arrayproductDataArray of catalogProductCreateEntity
stringstoreViewStore view ID or code

Returns:

TypeNameDescription
intresultID of the created product

The catalogProductCreateEntity content is as follows:

TypeNameDescription
ArrayOfStringcategoriesArray of categories
ArrayOfStringwebsitesArray of websites
stringnameProduct name
stringdescriptionProduct description
stringshort_descriptionProduct short description
stringweightProduct weight
stringstatusProduct status
stringurl_keyURL key
stringurl_pathURL path
stringvisibilityProduct visibility on the frontend
ArrayOfStringcategory_idsArray of category IDs
ArrayOfStringwebsite_idsArray of website IDs
stringhas_optionsDefines whether the product has options
stringgift_message_availableDefines whether the gift message is available for the product
stringpriceProduct price
stringspecial_priceProduct special price
stringspecial_from_dateDate starting from which the special price will be applied to the product
stringspecial_to_dateDate till which the special price will be applied to the product
stringtax_class_idTax class ID
arraytier_priceArray of catalogProductTierPriceEntity
stringmeta_titleMeta title
stringmeta_keywordMeta keyword
stringmeta_descriptionMeta description
stringcustom_designCustom design
stringcustom_layout_updateCustom layout update
stringoptions_containerOptions container
arrayadditional_attributesArray of catalogProductAdditionalAttributesEntity
arraystock_dataArray of catalogInventoryStockItemUpdateEntity

Notes: The “websites” and “website_ids” or “categories” and “category_ids” parameters are interchangeable. In other words, you can specify an array of website IDs (int) and then you don’t need to specify the array of website codes (string) and vice versa.

The catalogProductTierPriceEntity content is as follows:

TypeNameDescription
stringcustomer_group_idCustomer group ID
stringwebsiteWebsite
intqtyQuantity
doublepriceTier price

The catalogInventoryStockItemUpdateEntity content is as follows:

TypeNameDescription
stringqtyQuantity of items
intis_in_stockDefines whether the item is in stock
intmanage_stockManage stock
intuse_config_manage_stockUse config manage stock
intmin_qtyMinimum quantity for items to be in stock
intuse_config_min_qtyUse config settings flag (value defined in the Inventory System Configuration)
intmin_sale_qtyMinimum quantity allowed in the shopping cart
intuse_config_min_sale_qtyUse config settings flag
intmax_sale_qtyMaximum quantity allowed in the shopping cart
intuse_config_max_sale_qtyUse config settings flag
intis_qty_decimalDefines whether the quantity is decimal
intbackordersBackorders status
intuse_config_backordersUse config settings flag (for backorders)
intnotify_stock_qtyStock quantity below which a notification will appear
intuse_config_notify_stock_qtyUse config settings flag (for stock quantity)

The catalogProductAdditionalAttributesEntity content is as follows:

TypeName
associativeMultiArraymulti_data
associativeArraysingle_data

Single Data: array of attributes with only single value
Multi Data: array of attributes which could contain several values

Faults:

Fault CodeFault Message
100Requested store view not found.
102Invalid data given. Details in error message.
104Product type is not in allowed types.
105Product attribute set is not existed
106Product attribute set is not belong catalog product entity type

Examples

Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

// get attribute set
$attributeSets = $client->call($session, 'product_attribute_set.list');
$attributeSet = current($attributeSets);


$result = $client->call($session, 'catalog_product.create', array('simple', $attributeSet['set_id'], 'product_sku', array(
    'categories' => array(2),
    'websites' => array(1),
    'name' => 'Product name',
    'description' => 'Product description',
    'short_description' => 'Product short description',
    'weight' => '10',
    'status' => '1',
    'url_key' => 'product-url-key',
    'url_path' => 'product-url-path',
    'visibility' => '4',
    'price' => '100',
    'tax_class_id' => 1,
    'meta_title' => 'Product meta title',
    'meta_keyword' => 'Product meta keyword',
    'meta_description' => 'Product meta description'
)));

var_dump ($result);
Request Example SOAP V2
$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

// get attribute set
$attributeSets = $client->catalogProductAttributeSetList($session);
$attributeSet = current($attributeSets);

$result = $client->catalogProductCreate($session, 'simple', $attributeSet->set_id, 'product_sku', array(
    'categories' => array(2),
    'websites' => array(1),
    'name' => 'Product name',
    'description' => 'Product description',
    'short_description' => 'Product short description',
    'weight' => '10',
    'status' => '1',
    'url_key' => 'product-url-key',
    'url_path' => 'product-url-path',
    'visibility' => '4',
    'price' => '100',
    'tax_class_id' => 1,
    'meta_title' => 'Product meta title',
    'meta_keyword' => 'Product meta keyword',
    'meta_description' => 'Product meta description'
));

var_dump ($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));

$result = $proxy->catalogProductCreate((object)array('sessionId' => $sessionId->result, 'type' => 'simple', 'set' => '4', 'sku' => 'simple_sku',
'productData' => ((object)array(
    'name' => 'Product name',
    'description' => 'Product description',
    'short_description' => 'Product short description',
    'weight' => '10',
    'status' => '1',
    'visibility' => '4',
    'price' => '100',
    'tax_class_id' => 1,
))));

var_dump($result->result);