how to add custom option like color and size on magento api soap? this is my code:
public function addProduct($data)
{
$newProductData = array(
'name' => $data['name'],
'websites' => array( 1 ),
'short_description' => $data['short_description'],
'description' => $data['description'],
'status' => 1,
'weight' => 0,
'tax_class_id' => 1,
'categories' => array( 3 ),
'price' => $data['price'],
);
return $this->APIcreateNewProduct( $newProductData );
}
/* * Creates product by one parameter which is array with new product data */
public function APIcreateNewProduct( $newProductData ) {
$error = array();
if( empty( $newProductData ) ) {
$error[] = 'Empty product data';
}
if( empty( $error ) ) {
$token = $this->_getToken();
$client = $this->_getClient();
$set = $this->_APIgetAttributeSets();
$productId = $client->call($token, self::CREATE_PRODUCT, array('simple', $set['set_id'], rand().'sku_of_product', $newProductData));
return $productId;
} else {
return $this->_apiJsonResult( $error );
}
}
When you want to add custom options to product by API. You need to create this product. Method catalogProductCreate returns (int)$productId
http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.create.html
Then you need to use this: http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/catalogProductCustomOption.html to add to your product any number of custom options.