私はMagento 1.5.1.0を使用しています。 PHPスクリプトを介して製品を追加したいと考えています。 私はカスタム属性を8つのカスタム属性で設定していますが、どのようにPHP経由でカスタム属性に値を追加しますか? product.createまたはproduct.updateとSOAP経由Magentoの製品属性を追加
答えて
$host = "127.0.0.1/magento/index.php"; //our online shop url
$client = new SoapClient('http://'.$host.'/api/soap/?wsdl'); //soap handle
$apiuser= "user"; //webservice user login
$apikey = "pw"; //webservice user pass
$sess_id= $client->login($apiuser, $apikey); //we do login
$attributeSets = $client->call($sess_id, 'product_attribute_set.list');
$set = current($attributeSets);
$newProductData = array(
'name' => 'name'
// websites - Array of website ids to which you want to assign a new product
, 'websites' => array(1) // array(1,2,3,...)
, 'short_description' => 'short'
, 'description' => 'description'
, 'status' => 'status'
, 'your_attributes' => $value
, 'your_attributes2' => $value
, 'your_attributes3' => $value
and so on
);
try {
$client->call($sess_id, 'product.create', array('simple', $set['set_id'], 'sku_of_product', $newProductData));
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
}
のHf & GL:D
よろしくBoti
それはすでに
$newProductData = array('name' => 'name',
'your_attribute' => $value
,'your_attribute2' => $value
);
$proxy->call($sessionid, 'product.create', array('simple', $set['set_id'], sku, $newProductData));
その後の製品は、カスタム属性(複数可)を使用して作成されますが存在するなら。
よろしくboti
すみません、ありがとうございました。すべてのPHPファイルがどのように表示されるべきかを教えてください。私はmagentoの例で$ proxy = new SoapClient( 'http:// magentohost/api/soap /?wsdl')を見た。 $ sessionId = $ proxy-> login( 'apiUser'、 'apiKey'); $ attributeSets = $ proxy-> call($ sessionId、 'product_attribute_set.list'); $ set =現在の($ attributeSets);よろしくお願いします –
はい、これは私のためにうまくいきます。 V1 soap apiの場合にのみ有効です –
Iは、SOAP API V2の以降のバージョンで同じことを行うための私の検索では、この応答を見つけたので、私は最終的に思いついた解決策を追加しています。
V2 SOAP APIの場合、additional_attributesをmulti_dataまたはsingle_dataレイヤーにネストする必要があると思われますか?
アプリ/コード/コア/メイジ/カタログ/モデル/製品を見る/ API/V2.php#256私は、我々があることを
$manufacturer = new stdClass();
$manufacturer->key = "manufacturer";
$manufacturer->value = "20";
$additionalAttrs['single_data'][] = $manufacturer;
または
$manufacturer = new stdClass();
$manufacturer->key = "manufacturer";
$manufacturer->value = "20";
$additionalAttrs['multi_data'][] = $manufacturer;
を使用する必要があると思います以下のように使用されます:
$productData = new stdClass();
$additionalAttrs = array();
// manufacturer from one of the two above^
$productData->name = $data['name'];
$productData->description = $data['description'];
$productData->short_description = $data['short_description'];
$productData->weight = 0;
$productData->status = 2; // 1 = active
$productData->visibility = 4; //visible in search/catalog
$productData->category_ids = $data['categories'];
$productData->price = $data['price'];
$productData->tax_class_id = 2; // 2=standard
$productData->additional_attributes = $additionalAttrs;
// Create new product
try {
$proxy->catalogProductCreate($sessionId, 'virtual', 9, $sku, $productData); // 9 is courses
} catch (SoapFault $e) {
print $e->getMessage(); //Internal Error. Please see log for details.
exit();
}
- 1. Magento:すべての製品に新しい属性を追加
- 2. magentoの製品編集でカスタネットタブの属性を追加する方法admin
- 3. セットアップスクリプトを使用してMagentoでカスタム製品属性を追加する
- 4. MagentoのMagentoによるスーパー製品の属性設定
- 5. magento製品に価格ルールを追加
- 6. 追加製品の説明タブmagento
- 7. 複数の属性を持つ製品バリエーションを追加する
- 8. WooCommerceの追加情報タブから製品属性を隠す
- 9. すべての製品属性のリストをmagentoで取得
- 10. カスタム属性をWooCommerceショップループ製品タイトルに追加する
- 11. Magentoモジュールのセットアップ - 製品属性を不要に変更する
- 12. 製品ビューページの属性をmagentoで表示する方法2
- 13. Magento製品の属性セットを変更します。
- 14. Magento:製品リストページのドロップダウン属性を表示するには
- 15. Magentoカスタム属性のカスタムテーブルへの製品コレクションの結合
- 16. Magentoの製品は、属性がこのために順番
- 17. Magento製品のデフォルト属性ラベルの変更方法
- 18. magento製品属性のカスタム「カタログ所有者のカタログ入力タイプ」
- 19. Magentoの輸出製品のソース・モデル「magdoc/source_option」属性「magdoc_id」
- 20. Magentoの設定可能な製品に依存する属性
- 21. magento製品の属性とバックエンドから削除する
- 22. ポストメタ製品の属性
- 23. ワードプレスの製品属性
- 24. 製品属性のデータベーススキーマ
- 25. Magento - 'samples_title'商品属性
- 26. Magento - 計算された製品属性(プロパティ)
- 27. カスタム属性が製品リストビューに表示されないMagento
- 28. Productレポートグリッドにドロップダウン属性を追加Magento
- 29. Magento - 注文にカスタム属性を追加
- 30. Solr - スキーマヘルプ(製品属性)
ありがとうございます。唯一の問題は、自分のサーバーでSoapを有効にしていないことです。別の方法がありますか? –