如何在 magento api 上添加自定义选项?

how to add custom option on magento api?

如何在 magento api soap 上添加颜色和大小等自定义选项?这是我的代码:

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 returns (int)$productId

http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.create.html

那么你需要使用这个:http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/catalogProductCustomOption.html 向您的产品添加任意数量的自定义选项。