How to create configurable product using magento api?

后端 未结 4 1934
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 03:08

How can I create a configurable product using the Magento api?

4条回答
  •  粉色の甜心
    2021-02-02 03:38

    Copy/pasted from http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product#example_2._product_createviewupdatedelete

    $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
    $sessionId = $proxy->login('apiUser', 'apiKey');
    
    // default attribute set in my install is 4
    $attribute_set_id = 4;
    
    // configurable product to create
    $product_sku = 123456789012;
    
    $newProductData = array(
       'name'              => 'name of product',
       // websites - Array of website ids to which you want to assign a new product
      'websites'          => array(1), // array(1,2,3,...)
      'short_description' => 'short description',
      'description'       => 'description',
      'price'             => 12.05
    );
    
    $proxy->call($sessionId, 'product.create', array(
      'configurable', 
      $attribute_set_id, 
      $product_sku, 
      $newProductData
    ));
    

    The hard part is assigning simple products to your configurables (not supported via the api). Here's a method for assigning simples to configurables directly

提交回复
热议问题