加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 13:37:14 所属栏目:PHP教程 来源:网络整理
导读:我试图通过SOAP api获得magento产品的自定义属性的价值. BUt我只能获得标准属性值.我正在尝试下面的代码,但它似乎没有工作. $user = 'user';$password = 'pass';$proxy = new SoapClient('http://asd.com.au/api/v2_soap?wsdl');$sessionId = $proxy-login($
我试图通过SOAP api获得magento产品的自定义属性的价值. BUt我只能获得标准属性值.我正在尝试下面的代码,但它似乎没有工作.
$user = 'user';
$password = 'pass';
$proxy = new SoapClient('http://asd.com.au/api/v2_soap?wsdl');
$sessionId = $proxy->login($user,$password);

   //method 1 I tried
    $ebayStock = new stdClass();
    $ebayStock->key = 'ebay_available_qty';
    $additionalAttributes['single_data'][] = $ebayStock ;
    $ebay = $proxy->catalogProductInfo($sessionId,$sku,1,$additionalAttributes);
    var_dump($ebay);

//output

object(stdClass)[4]
  public 'product_id' => string '3230' (length=4)
  public 'sku' => string 'test101' (length=7)
  public 'set' => string '9' (length=1)
  public 'type' => string 'simple' (length=6)
  public 'categories' => 
    array (size=0)
      empty
  public 'websites' => 
    array (size=1)
      0 => string '1' (length=1)
  public 'created_at' => string '2013-05-12 23:07:33' (length=19)
  public 'updated_at' => string '2013-05-13 04:54:50' (length=19)
  public 'type_id' => string 'simple' (length=6)
  public 'name' => string 'test' (length=4)
  public 'description' => string 'asd' (length=3)
  public 'short_description' => string 'asd' (length=3)
  public 'weight' => string '123.0000' (length=8)
  public 'status' => string '1' (length=1)
  public 'url_key' => string 'test' (length=4)
  public 'url_path' => string 'test.html' (length=9)
  public 'visibility' => string '3' (length=1)
  public 'category_ids' => 
    array (size=0)
      empty
  public 'has_options' => string '0' (length=1)
  public 'price' => string '11.0000' (length=7)
  public 'tax_class_id' => string '0' (length=1)
  public 'tier_price' => 
    array (size=0)
      empty
  public 'options_container' => string 'container2' (length=10)
  public 'enable_googlecheckout' => string '1' (length=1)

06002

$ebay = $proxy->catalogProductInfo($sessionId,array('ebay_available_qty'));
var_dump($ebay);

//gives same output

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

问候
Abnab

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

$ebay = $proxy->catalogProductInfo($sessionId,null,$ebayStock);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读