Magento SOAP v1 cart_product.add-需要在SKU的选项数组中设置价格 [英] Magento SOAP v1 cart_product.add - need to set price in options array for sku

查看:50
本文介绍了Magento SOAP v1 cart_product.add-需要在SKU的选项数组中设置价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$arrProducts = array(
    array(
        "sku" => "sku1",
        "qty" => 1,
        "options" => array(
            99 => '.50' // 99 is the price attribute id, I want to set this sku to $0.50
        )
    ),
    array(
        "sku" => "sku2",
        "quantity" => 1
    )
);

$resultCartProductAdd = $client->call($session, "cart_product.add", array($shoppingCartId, $arrProducts));

在sku1的选项数组中,如何设置要添加到购物车并计算出结账总额的价格?

In the options array for sku1, how do I set the price to be added to the cart and calculated in totals for checkout?

以上选项不会改变价格. sku的原始价格仍在添加到购物车中,而不是$ 0.50.查看如何通过Soap/Java在Magento中创建具有其他属性的产品,我仍然不了解.

The above options are not changing the price. The original price for the sku is still being added to the cart instead of $0.50. Looking at How do I create a product with additional attributes in Magento via Soap/Java I am still not understanding something.

我正在使用SOAP V1调用使用Magento EE 1.13

I am on Magento EE 1.13 using SOAP V1 call

推荐答案

要即时设置价格,您可以扩展将商品添加到购物车的API调用.需要扩展模型文件Mage_Checkout_Model_Cart_Product_Api,并重写add方法以适应price属性.看起来像这样

To set the price on the fly you could extend the API call for adding a product to the cart. The model file Mage_Checkout_Model_Cart_Product_Api would need to be extended and the add method overridden to cater for a price attribute. It would look something like this

class Namespace_Module_Model_Cart_Product_Api extends Mage_Checkout_Model_Cart_Product_Api
{
    public function add($quoteId, $productsData, $store=null)
    {
       ...
       $result = $quote->addProduct($productByItem, $productRequest);
       if(isset($productItem['price']) && $productItem['price'] != null) {
           $result->setOriginalCustomPrice($productItem['price']);
       }
       ...
    }
}

然后您可以像这样将价格添加到API调用中的数据数组中.

You could then add price into the array of data in your API call like this.

array(
    "sku" => "sku1",
    "qty" => 1,
    "price" => 0.50,
)

add调用的确对报价发出了collectTotals()调用,因此它应根据自定义价格重新计算税金和货币等.您可能需要修改wsdl文件以接受新的price属性.未经测试,但理论上应该可以.

The add call does issue a collectTotals() call on the quote so it should recalculate tax and currency etc based upon the custom price. You may need to modify the wsdl file to accept the new price attribute. Not tested but in theory should work.

这篇关于Magento SOAP v1 cart_product.add-需要在SKU的选项数组中设置价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆