2016-05-10 9 views
0

私は、このリンクを使用してMagentoの石鹸APIを使用してMagentoのデータベースから製品の完全なデータをフェッチしようとしています:http://devdocs.magento.com/guides/m1x/api/soap/catalog/catalogProduct/catalog_product.list.htmlMagento 1.9.2.2でmagento apiを使用してmagentoデータベースから製品イメージを取得するには?

と次のコードを使用して:

<?php 
$proxy = new SoapClient('http://xxxxxxx.com/api/v2_soap/?wsdl'); // TODO : change url 
$sessionId = $proxy->login('test_role', 'password'); // TODO : change login and pwd if necessary 

$result = $proxy->catalogProductList($sessionId); 
print_r($result); 
?> 

を私はすべての製品のデータを入手できますかこのような広告枠:

Array ([0] => stdClass Object ([product_id] => 24 [sku] => 123445 [name] => Burger [set] => 4 [type] => simple [category_ids] => Array ([0] => 59) [website_ids] => Array ([0] => 1)) [1] => stdClass Object ([product_id] => 25 [sku] => MG1456 [name] => Massage [set] => 4 [type] => simple [category_ids] => Array ([0] => 63) [website_ids] => Array ([0] => 1)) [2] => stdClass Object ([product_id] => 26 [sku] => 345666 [name] => Chicken Chilly [set] => 4 [type] => simple [category_ids] => Array ([0] => 59) [website_ids] => Array ([0] => 1)) [3] => stdClass Object ([product_id] => 27 [sku] => 23424 [name] => Chicken Biryani [set] => 4 [type] => simple [category_ids] => Array ([0] => 59) [website_ids] => Array ([0] => 1)) [4] => stdClass Object ([product_id] => 28 [sku] => 45567 [name] => Panner Chilly [set] => 4 [type] => simple [category_ids] => Array ([0] => 59) [website_ids] => Array ([0] => 1)) [5] => stdClass Object ([product_id] => 31 [sku] => S5GH488 [name] => Pizza [set] => 4 [type] => simple [category_ids] => Array ([0] => 59) [website_ids] => Array ([0] => 1))) 

しかし、私はそれぞれの製品の画像も必要ですので、私のアプリに表示することができます!助けてください!

+0

、それは便利ですか? –

+0

はい私は私のアプリでそれらを表示することができますようにすべての製品の画像が必要です..画像とマップする製品のentity_idを使用して連想配列は素晴らしいだろう! –

答えて

1

$resultアレイ内のすべての製品がこれをループして画像を取得できるようになりました。

あなたはofficial Magento docsあなたがそうのようなイメージを取得、あなたの現在のスクリプトに調整して見ることができるように:私は、アレイ内のすべての製品を返すことができる場合

<?php 
$proxy = new SoapClient('http://xxxxxxx.com/api/v2_soap/?wsdl'); // TODO : change url 
$sessionId = $proxy->login('test_role', 'password'); // TODO : change login and pwd if necessary 

$result = $proxy->catalogProductList($sessionId); 
$productImages = array(); 

// Getting all the product images 
foreach($result as $product) { 
    $productImages[] = $proxy->catalogProductAttributeMediaList($sessionId, $product->productId); 
} 

print_r($result); 

// Show the product images array 
print_r($productImages); 
?> 
+0

私は今これを試しています、私に数分を与えてください。 –

+0

このエラーが発生します。致命的なエラー:stdClass型のオブジェクトを配列として使用できません。 $ productImages [] = $ proxy-> catalogProductAttributeMediaList($ sessionId、$ product ['product_id']);このプロンプトでは、 –

+0

'$ product-> productId'を試してみることができます。サンプルコード – codedge

関連する問題