2011-04-08 115 views
0

我需要通过Magento Soap API创建一个新的可配置产品并向其添加相关产品。使用Soap API将Magento属性设置为可配置产品

我使用此代码创建2个产品(一个简单的和一个配置),然后我尝试将简单的一个链接到配置...这不工作.. 有一个教程做这个?? 任何帮助? 非常感谢。

// Magento login information 
    $mage_url = 'http://test.de/api/?wsdl'; 
    $mage_user = 'admin'; 
    $mage_api_key = 'admin'; 
    // Initialize the SOAP client 
    $soap = new SoapClient($mage_url); 
    // Login to Magento 
    $session = $soap->login($mage_user, $mage_api_key); 



    $attributeSets = $soap->call($session,'product_attribute_set.list'); 
    $set = current($attributeSets); 

    $sku = 'iphone-12345'; 

    //configurable 

    $newProductData = array(
     'name'    => 'iPhone', 
     'websites'   => array(1), 
     'short_description' => 'short description', 
     'description'  => 'description', 
     'price'    => 150, 
     'status'   => '1', 
     'categories' => array(138), 
    ); 



    $newProductRelated = array(

     'name'    => 'iPhone', 
     'websites'   => array(1), 
     'short_description' => 'short description', 
     'description'  => 'description', 
     'price'    => 150, 
     'status'   => '1', 
     'sku'    => '2551464' 
      ); 



    $productId = $soap->call($session,'product.create',array('configurable', $set['set_id'], $sku ,$newProductData)); 
    $productId2 = $soap->call($session,'product.create',array('simple', $set['set_id'], $newProductRelated['sku'] ,$newProductRelated)); 




    $soap->call($session, 'product_link.assign', array('configurable', $sku, $newProductRelated['sku'], array('position'=>0, 'colore'=> 21, 'qty'=>6))); 

再次ma th thx。

回答

1

处理类似问题并使用CSV导入来创建从API导入的产品的关系。这可能是通过生成的CSV一次导入的可用方法。

相关问题