2011-04-08 118 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一次導入的可用方法。

相關問題