我正在尝试创建一个可配置产品及其相关产品,使用magento soap api.Product成功创建但可配置产品链接与相关产品无法正常工作吗?这是我的代码
<?php
$client = new SoapClient('https://sample.com/api/v2_soap?wsdl=1');
// If some stuff requires api authentification,
// then get a session token
$session = $client->login('username', 'Password');
// get attribute set
$attributeSets = $client->catalogProductAttributeSetList($session);
$attributeSet = current($attributeSets);
print_r($attributeSet);
$result = $client->catalogProductCreate($session, 'simple',72, 'product_sku0002', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'additional_attributes' => array(
'single_data' => array(
array(
'key' => 'color',
'value' => 'Red', // Id or label of color, attribute that will be used to configure product
)
),
),
));
var_dump ($result);
$result = $client->catalogProductCreate($session, 'configurable',72, 'Configurable_product_sku0001', array(
'categories' => array(2),
'websites' => array(1),
'name' => 'Confihurable Product name',
'description' => 'Product description',
'short_description' => 'Product short description',
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => '100',
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description',
'associated_skus' => array('product_sku0002'),
'price_changes' => array(
array(
'color' => array(
'Red' => '0'
)
),
),
));
var_dump ($result);
?>
答案 0 :(得分:0)