【问题标题】:Magento Cart_Product.Add Custom Options File Upload via Soap APIMagento Cart_Product.Add 自定义选项文件通过 Soap API 上传
【发布时间】:2014-01-04 13:17:53
【问题描述】:

无法实现通过soap api上传文件到购物车。我希望用户使用所需的自定义选项(即图像)将产品添加到购物车。

花了好几个小时,在任何地方都找不到任何资源/文档/相同的问题,但实际上发现,soap api 需要数组(好的,但是参数是什么?)如果出现问题,它不会抛出任何错误(奇怪?)

所以在实践中我愿意实现的目标:

// Prepare image
$newImage = array(
    'file' => array(
        'name' => $_FILES['uploadedfile']['name'],
        'content' => base64_encode(file_get_contents($_FILES['uploadedfile']['tmp_name'])),
        'mime'    => 'image/png'
        ),
    'label'    => $_FILES['uploadedfile']['name']
);

// Prepare product & Custom options
$arrProducts = array(
    array(
        'product_id'     => '7',
        'qty'             => 1,
        'options'        => array ( '30' => $newImage ) // optionId_1 => optionValue_1
    )
);

// lets do adding
$resultCartProductAdd = $client->call(
    $session,
    'cart_product.add',
    array(
        $quoteId,
        $arrProducts
    )
);

问题是,图像没有上传到应该属于的 /media/custom_options/quote 文件夹,并且订单完成时看不到任何地方。正如我所提到的,在这个过程中没有抛出任何错误..

感谢您帮助我。

【问题讨论】:

  • 你找到解决办法了吗?

标签: php magento soap


【解决方案1】:

请试试这个....

 $arrProducts = array(
        array(
            'product_id'     => '7',
            'qty'             => 1,
            'options'        => array ( 'options_30_file' => $newImage,'options_30_file_action'=>'save_new' ) 
        )
    );

 $arrProducts = array(
            array(
                'product_id'     => '7',
                'qty'             => 1,
               'options_30_file' => $newImage,
              'options_30_file_action'=>'save_new'  
            )
        );

如果有任何问题,请告诉我

【讨论】:

  • 感谢您的回复,但两种方法都会引发此错误:未捕获的 SoapFault 异常:[1022] 请指定产品所需的选项。
  • 顺便说一句,magento 版本。 1.8.0
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多