【问题标题】:Error adding products to cart magento soap将产品添加到购物车 magento soap 时出错
【发布时间】:2013-01-15 09:30:15
【问题描述】:

当我尝试通过 soap API 将产品添加到 Magento 中的购物车时,我收到此错误: SoapFault:在非对象上调用成员函数 setFinalPrice()

我采取以下步骤:

  • 创建cart($this->call($this->_session, 'cart.create', array($store));)
  • 设置客户地址和信息(cart_customer.set、cart_customer.addresses)

calling(cart.info) 时会产生以下数组:

Array
(
    [store_id] => 0
    [created_at] => 2013-01-15 09:19:49
    [updated_at] => 2013-01-15 09:19:51
    [converted_at] => 
    [is_active] => 0
    [is_virtual] => 0
    [is_multi_shipping] => 0
    [items_count] => 0
    [items_qty] => 0.0000
    [orig_order_id] => 0
    [store_to_base_rate] => 1.0000
    [store_to_quote_rate] => 1.0000
    [base_currency_code] => EUR
    [store_currency_code] => EUR
    [quote_currency_code] => EUR
    [grand_total] => 0.0000
    [base_grand_total] => 0.0000
    [checkout_method] => guest
    [customer_id] => 
    [customer_tax_class_id] => 3
    [customer_group_id] => 1
    [customer_email] => test@test.nl
    [customer_prefix] => 
    [customer_firstname] => Test
    [customer_middlename] => 
    [customer_lastname] =>  TestLasname
    [customer_suffix] => 
    [customer_dob] => 
    [customer_note] => 
    [customer_note_notify] => 1
    [customer_is_guest] => 0
    [remote_ip] => 
    [applied_rule_ids] => 
    [reserved_order_id] => 
    [password_hash] => GkV4mSKHqgQ=
    [coupon_code] => 
    [global_currency_code] => EUR
    [base_to_global_rate] => 1.0000
    [base_to_quote_rate] => 1.0000
    [customer_taxvat] => 
    [customer_gender] => 0
    [subtotal] => 0.0000
    [base_subtotal] => 0.0000
    [subtotal_with_discount] => 0.0000
    [base_subtotal_with_discount] => 0.0000
    [is_changed] => 1
    [trigger_recollect] => 0
    [ext_shipping_info] => 
    [gift_message_id] => 
    [is_persistent] => 0
    [quote_id] => 4506
    [shipping_address] => Array
    (
        [address_id] => 
        [quote_id] => 4506
        [created_at] => 2013-01-15 09:19:51
        [updated_at] => 2013-01-15 09:19:51
        [customer_id] => 
        [save_in_address_book] => 0
        [customer_address_id] => 
        [address_type] => shipping
        [email] => 
        [prefix] => 
        [firstname] => Test
        [middlename] => 
        [lastname] =>  TestLastname
        [suffix] => 
        [company] => 
        [street] => street 24
        [city] => Amsterdam
        [region] => 
        [region_id] => 
        [postcode] => 3454 BM
        [country_id] => NL
        [telephone] => 565765765765
        [fax] => 
        [same_as_billing] => 0
        [free_shipping] => 0
        [collect_shipping_rates] => 1
        [shipping_method] => 
        [shipping_description] => 
        [weight] => 0.0000
        [subtotal] => 0.0000
        [base_subtotal] => 0.0000
        [subtotal_with_discount] => 0.0000
        [base_subtotal_with_discount] => 0.0000
        [tax_amount] => 0.0000
        [base_tax_amount] => 0.0000
        [shipping_amount] => 0.0000
        [base_shipping_amount] => 0.0000
        [shipping_tax_amount] => 0.0000
        [base_shipping_tax_amount] => 0.0000
        [discount_amount] => 0.0000
        [base_discount_amount] => 0.0000
        [grand_total] => 0.0000
        [base_grand_total] => 0.0000
        [customer_notes] => 
        [applied_taxes] => a:0:{}
        [discount_description] => 
        [shipping_discount_amount] => 
        [base_shipping_discount_amount] => 
        [subtotal_incl_tax] => 0.0000
        [base_subtotal_total_incl_tax] => 
        [gift_message_id] => 
        [hidden_tax_amount] => 
        [base_hidden_tax_amount] => 
        [shipping_hidden_tax_amount] => 
        [base_shipping_hidden_tax_amnt] => 
        [shipping_incl_tax] => 0.0000
        [base_shipping_incl_tax] => 0.0000
    )

[billing_address] => Array
    (
        [address_id] => 
        [quote_id] => 4506
        [created_at] => 2013-01-15 09:19:51
        [updated_at] => 2013-01-15 09:19:51
        [customer_id] => 
        [save_in_address_book] => 0
        [customer_address_id] => 
        [address_type] => billing
        [email] => 
        [prefix] => 
        [firstname] => Test
        [middlename] => 
        [lastname] =>  TestLastname
        [suffix] => 
        [company] => 
        [street] => street 24
        [city] => Amsterdam
        [region] => 
        [region_id] => 
        [postcode] => 3454 BM
        [country_id] => NL
        [telephone] => 565765765765
        [fax] => 
        [same_as_billing] => 0
        [free_shipping] => 0
        [collect_shipping_rates] => 0
        [shipping_method] => 
        [shipping_description] => 
        [weight] => 0.0000
        [subtotal] => 0.0000
        [base_subtotal] => 0.0000
        [subtotal_with_discount] => 0.0000
        [base_subtotal_with_discount] => 0.0000
        [tax_amount] => 0.0000
        [base_tax_amount] => 0.0000
        [shipping_amount] => 0.0000
        [base_shipping_amount] => 0.0000
        [shipping_tax_amount] => 0.0000
        [base_shipping_tax_amount] => 0.0000
        [discount_amount] => 0.0000
        [base_discount_amount] => 0.0000
        [grand_total] => 0.0000
        [base_grand_total] => 0.0000
        [customer_notes] => 
        [applied_taxes] => a:0:{}
        [discount_description] => 
        [shipping_discount_amount] => 
        [base_shipping_discount_amount] => 
        [subtotal_incl_tax] => 0.0000
        [base_subtotal_total_incl_tax] => 
        [gift_message_id] => 
        [hidden_tax_amount] => 
        [base_hidden_tax_amount] => 
        [shipping_hidden_tax_amount] => 
        [base_shipping_hidden_tax_amnt] => 
        [shipping_incl_tax] => 0.0000
        [base_shipping_incl_tax] => 0.0000
    )

[items] => Array
    (
    )

[payment] => Array
    (
        [quote_id] => 4506
        [payment_id] => 
    )
)

但是当我尝试使用以下数组 execute(cart_product.add) 时:

Array
(
     'sku' => '44567788855',
     'quantity' => 1
 )

我收到关于 setFinalPrice 的错误。

问题是,我无权访问此 Magento 安装(仅限 API 帐户)。我使用网站 (http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html) 获取所有示例代码。

使用 product_id 代替 sku 有效。不知何故,这不起作用,但记录在他们的 API 中

【问题讨论】:

    标签: magento soap


    【解决方案1】:

    请参考linkhere

    它可能会对你有所帮助..我也厌倦了我的 magento,用 product_id 代替了 execute(cart_product.add) 的 sku。它工作正常。

    请检查我的请求

     <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <soapenv:Header/>
       <soapenv:Body>
          <urn:shoppingCartProductAdd soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <sessionId xsi:type="xsd:string">d77fdb68c787871ce1373001120b1520</sessionId>
             <quoteId xsi:type="xsd:int">1</quoteId>
             <products xsi:type="urn:shoppingCartProductEntityArray" soapenc:arrayType="urn:shoppingCartProductEntity[]">
    <product_id xsi:type="xsd:string">2</product_id>
    </products>
             <storeId xsi:type="xsd:string">0</storeId>
          </urn:shoppingCartProductAdd>
       </soapenv:Body>
    </soapenv:Envelope>
    

    我的回答是

        <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
       <SOAP-ENV:Body>
          <ns1:shoppingCartProductAddResponse>
             <result xsi:type="xsd:boolean">true</result>
          </ns1:shoppingCartProductAddResponse>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    我正在使用 SOAP 客户端来测试肥皂。

    祝你好运

    【讨论】:

    • 您链接到的链接已失效。你可以在这里发布答案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多