2017-04-10 65 views
0

我已經爲我的應用創建webservices,但問題ID我無法在cart中添加可配置產品。請查找我的代碼。任何幫助將不勝感激。如何使用magento api中的產品ID添加購物車中的可配置產品

$ customer_id ='id_of_customer';

$cart_id = 'cart_id';   
$quantity = 'quantity'; 
$store_id = 1; 
if ($cart_id != '' AND $customer_id != '') {   

    $arrProducts = array(array(
      "product_id" => '1887', 
      "sku" => 'sku_of_product', 
      "super_attribute" => array(151 => 3), 
      "qty" => 2, 
    )); 

    $result = $proxy->shoppingCartProductAdd($sessionId, $cart_id, $arrProducts); 

但是我收到錯誤請指定產品的選項。

回答

0

請使用此代碼:

$product = array(
      'product_id' => 19, // config product id 
      'sku' => 'H001', 
      'qty' => '1', 

      'super_attribute' => array(
       0 => array(
       'key' => 92,  //attribute id 
       'value' => 10  //value 
       ), 
       1 => array(
       'key' => 134, 
       'value' => 3 
       ) 
      ) 
     ); 

$result = $proxy->shoppingCartProductAdd($session,$cartId, array($product)); 
+0

還是得到了同樣的錯誤.... – Akhil

相關問題