[英]how to add custom option on magento api?
如何在magento api肥皂上添加自定义选项,例如颜色和大小? 这是我的代码:
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 );
}
/ * *通过一个参数创建产品,该参数是包含新产品数据的数组* /
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 );
}
}
当您想通过API向产品添加自定义选项时。 您需要创建此产品。 方法catalogProductCreate返回(int)$ productId
http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.create.html
然后,您需要使用以下代码: http : //www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/catalogProductCustomOption.html将任意数量的自定义选项添加到您的产品中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.