首页 文章

使用Soap API将Magento属性设置为可配置产品

提问于
浏览
0

我需要通过Magento Soap API创建一个新的可配置产品,并为其添加相关产品 .

我使用这个代码创建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)));

再来一次 .

1 回答

  • 1

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

相关问题