php – 如何通过SOAP API获取magento中自定义属性的值

前端之家收集整理的这篇文章主要介绍了php – 如何通过SOAP API获取magento中自定义属性的值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图通过SOAP api获得magento产品的自定义属性的价值. BUt我只能获得标准属性值.我正在尝试下面的代码,但它似乎没有工作.
  1. $user = 'user';
  2. $password = 'pass';
  3. $proxy = new SoapClient('http://asd.com.au/api/v2_soap?wsdl');
  4. $sessionId = $proxy->login($user,$password);
  5.  
  6. //method 1 I tried
  7. $ebayStock = new stdClass();
  8. $ebayStock->key = 'ebay_available_qty';
  9. $additionalAttributes['single_data'][] = $ebayStock ;
  10. $ebay = $proxy->catalogProductInfo($sessionId,$sku,1,$additionalAttributes);
  11. var_dump($ebay);

//output

  1. object(stdClass)[4]
  2. public 'product_id' => string '3230' (length=4)
  3. public 'sku' => string 'test101' (length=7)
  4. public 'set' => string '9' (length=1)
  5. public 'type' => string 'simple' (length=6)
  6. public 'categories' =>
  7. array (size=0)
  8. empty
  9. public 'websites' =>
  10. array (size=1)
  11. 0 => string '1' (length=1)
  12. public 'created_at' => string '2013-05-12 23:07:33' (length=19)
  13. public 'updated_at' => string '2013-05-13 04:54:50' (length=19)
  14. public 'type_id' => string 'simple' (length=6)
  15. public 'name' => string 'test' (length=4)
  16. public 'description' => string 'asd' (length=3)
  17. public 'short_description' => string 'asd' (length=3)
  18. public 'weight' => string '123.0000' (length=8)
  19. public 'status' => string '1' (length=1)
  20. public 'url_key' => string 'test' (length=4)
  21. public 'url_path' => string 'test.html' (length=9)
  22. public 'visibility' => string '3' (length=1)
  23. public 'category_ids' =>
  24. array (size=0)
  25. empty
  26. public 'has_options' => string '0' (length=1)
  27. public 'price' => string '11.0000' (length=7)
  28. public 'tax_class_id' => string '0' (length=1)
  29. public 'tier_price' =>
  30. array (size=0)
  31. empty
  32. public 'options_container' => string 'container2' (length=10)
  33. public 'enable_googlecheckout' => string '1' (length=1)

06002

  1. $ebay = $proxy->catalogProductInfo($sessionId,array('ebay_available_qty'));
  2. var_dump($ebay);
  3.  
  4. //gives same output

我试图获取属性“ebay_available_qty”的值.

问候
Abnab

终于修好了我自己.刚刚创建了一个新的stdClass()并将我想要的属性放入一个数组中.它工作了!!!
  1. $ebayStock = new stdClass();
  2. $ebayStock->additional_attributes = array('ebay_available_qty');
  3.  
  4. $ebay = $proxy->catalogProductInfo($sessionId,null,$ebayStock);

猜你在找的PHP相关文章