如何使用magento api中的产品ID在购物车中添加可配置产品

时间:2017-04-10 07:26:53

标签: magento

我已经为我的应用创建了webservices但问题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);

但我收到错误请指明产品的选项。

1 个答案:

答案 0 :(得分: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));