1

如何Multiple Select通过 API 创建/更新具有属性的产品?插入产品 (catalog_product.create) 的 API 文件的路径是什么?

谢谢

4

2 回答 2

1

我正在使用 SOAP API 在 magento 商店中输入产品。这是完整的代码

在多选自定义属性的情况下。

            $arrProductTime = explode(',', '136,139');

            $result = $client->catalogProductCreate($session, 'simple', $attributeSet->set_id, 'product_sku1234', array(

                'categories' => array(36),
                'websites' => array(1),
                'name' => 'my_pdt1008',
                'description' => 'my_pdt1',
                'short_description' => 'my_pdt1000',
                'weight' => '11',
                'status' => '1',
                'url_key' => 'product-url-key1',
                'url_path' => 'product-url-path1',
                'visibility' => '4',
                'price' => '100',
                'tax_class_id' => 1,
                'meta_title' => 'Product meta title1',
                'meta_keyword' => 'Product meta keyword1',
                'meta_description' => 'Product meta description1',
                'stock_data' => array('qty'=>'100','is_in_stock'=>1,'manage_stock'=>1),
                'additional_attributes' => array('multi_data' => array(array('key' => 'product_time', 'value' => $arrProductTime)))
            ));
于 2014-06-06T07:53:36.810 回答
0

肥皂 V1

$client = new SoapClient('http://magentohost/api/soap/?wsdl');
// If some stuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
// get attribute set
$attributeSets = $client->call($session, 'product_attribute_set.list');
$attributeSet = current($attributeSets);
$result = $client->call($session, 'catalog_product.create', array('simple', $attributeSet['set_id'], 'product_sku', 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'
)));
var_dump ($result);

SOAP V2

$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

// If some stuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

// get attribute set
$attributeSets = $client->catalogProductAttributeSetList($session);
$attributeSet = current($attributeSets);

$result = $client->catalogProductCreate($session, 'simple', $attributeSet->set_id, 'product_sku', 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'
));

var_dump ($result);

您可以通过以下方式获取附加属性列表:

肥皂 V1

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$listAttributes = $proxy->call(
    $sessionId,
    'product.listOfAdditionalAttributes',
    array(
        'simple',
        13
    )
);

SOAP V2

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy->catalogProductListOfAdditionalAttributes($sessionId, 'simple', '13');
var_dump($result);

回应是

array
  0 =>
    array
      'attribute_id' => string '89' (length=2)
      'code' => string 'old_id' (length=6)
      'type' => string 'text' (length=4)
      'required' => string '0' (length=1)
      'scope' => string 'global' (length=6)
  1 =>
    array
      'attribute_id' => string '93' (length=2)
      'code' => string 'news_from_date' (length=14)
      'type' => string 'date' (length=4)
      'required' => string '0' (length=1)
      'scope' => string 'website' (length=7)
  2 =>
    array
      ...

我希望它能帮助你解决问题。

资源

创建一个新产品

获取附加属性列表。

于 2012-08-10T16:52:09.770 回答