Magento Cart API 未显示价格 [英] Magento Cart API not showing prices

查看:51
本文介绍了Magento Cart API 未显示价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Magento Enterprise 1.10 XML-RPC API 来处理 Magento 安装之外的购物车/目录功能.我遇到的问题是当我添加到购物车时.我可以很好地连接到 API 端点、登录和检索数据.以下是我用来发现 Magento API 工作原理的代码.

call('login', array($user, $pass));$cartId = $proxy->call( 'call', array( $sess, 'cart.create', array( 1 ) ) );$pList = $proxy->call( 'call', array( $sess, 'product.list', array() ) );$cList = $proxy->call( 'call', array( $sess, 'customer.list', array() ) );$cList[0]['mode'] = '客户';$setCart = $proxy->call( 'call', array( $sess,'cart_customer.set',数组( $cartId, $cList[0] ) ) );foreach( $pList 作为 $prod){if( $prod['product_id'] == 5 ){$prod['qty'] = 5;$addCart = $proxy->call('call', array( $sess,'cart_product.add',数组( $cartId, $pAdd ) ) );}}$cList = $proxy->call( 'call', array( $sess, 'cart.info', array( $cartId ) ) );打印_r( $cList );

输出:

[store_id] =>1[created_at] =>2011-05-27 13:30:57[updated_at] =>2011-05-27 13:31:00[converted_at] =>0000-00-00 00:00:00[is_active] =>0[is_virtual] =>0[is_multi_shipping] =>0[items_count] =>1[items_qty] =>5.0000[orig_order_id] =>0[store_to_base_rate] =>1.0000[store_to_quote_rate] =>1.0000[base_currency_code] =>美元[store_currency_code] =>美元[quote_currency_code] =>美元[grand_total] =>0.0000[base_grand_total] =>0.0000[结帐方法] =>顾客...[项目] =>大批([0] =>大批([item_id] =>93[quote_id] =>119[created_at] =>2011-05-27 13:31:00[updated_at] =>2011-05-27 13:31:00[product_id] =>5[store_id] =>1[parent_item_id] =>[is_virtual] =>1[sku] =>产品1[名称] =>产品[说明] =>[applied_rule_ids] =>[additional_data] =>[免费送货] =>0[is_qty_decimal] =>0[no_discount] =>0[重量] =>[数量] =>5[价格] =>0.0000[base_price] =>0.0000[custom_price] =>[discount_percent] =>0.0000[折扣金额] =>0.0000[base_discount_amount] =>0.0000

但是,我只是使用上述相同的会话调用以下内容

call( 'call', array( $sess, 'catalog_product.info', '5' ) );打印_r($pInfo);

我获得了有关产品的以下信息:

[product_id] =>5[sku] =>产品1[设置] =>9[类型] =>虚拟的[类别] =>大批()[网站] =>大批([0] =>1)[type_id] =>虚拟的[名称] =>产品[说明] =>测试[short_description] =>测试[news_from_date] =>[old_id] =>[news_to_date] =>[状态] =>1[能见度] =>4...[created_at] =>2011-05-25 15:11:34[updated_at] =>2011-05-25 15:11:34...[价格] =>10.0000

最后,API 看到该商品的价格实际上是 10.00 美元,但是当通过 API 将其添加到购物车时,价格并未正确反映.

解决方案

只是为了正式回答问题,这里是找到的解决方案,http://magentocommerce.com/boards/viewthread/227044我花了两天时间搜索这个,今天想出了一个晦涩的搜索词来尝试找到解决方案

I am attempting to use the Magento Enterprise 1.10 XML-RPC API to handle cart/catalog functions outside of the Magento installation. The issue that I am having is when I add to cart. I can connect just fine to the API endpoint, login, and retrieve data. The following is the code that I am using to discover the workings of the Magento API.

<?php    
   require $_SERVER['DOCUMENT_ROOT'].'/Zend/XmlRpc/Client.php';

   $url = 'http://mymagento.com/api/xmlrpc';
   $user = 'apiuser';
   $pass = 'apipass';

   $proxy = new Zend_XmlRpc_Client( $url );
   $sess = $proxy->call( 'login', array( $user, $pass ) );
   $cartId = $proxy->call( 'call', array( $sess, 'cart.create', array( 1 ) ) );

   $pList = $proxy->call( 'call', array( $sess, 'product.list', array() ) );
   $cList = $proxy->call( 'call', array( $sess, 'customer.list', array() ) );

   $cList[0]['mode'] = 'customer';

   $setCart = $proxy->call( 'call', array( $sess,
      'cart_customer.set',
      array( $cartId, $cList[0] ) ) );

   foreach( $pList as $prod)
   {
      if( $prod['product_id'] == 5 )
      {
          $prod['qty'] = 5;
          $addCart = $proxy->call( 'call', array( $sess, 
              'cart_product.add',
              array( $cartId, $pAdd ) ) );
      }
   }

   $cList = $proxy->call( 'call', array( $sess, 'cart.info', array( $cartId ) ) );
   print_r( $cList );

Outputs:

[store_id] => 1
[created_at] => 2011-05-27 13:30:57
[updated_at] => 2011-05-27 13:31:00
[converted_at] => 0000-00-00 00:00:00
[is_active] => 0
[is_virtual] => 0
[is_multi_shipping] => 0
[items_count] => 1
[items_qty] => 5.0000
[orig_order_id] => 0
[store_to_base_rate] => 1.0000
[store_to_quote_rate] => 1.0000
[base_currency_code] => USD
[store_currency_code] => USD
[quote_currency_code] => USD
[grand_total] => 0.0000
[base_grand_total] => 0.0000
[checkout_method] => customer
...
[items] => Array
(
    [0] => Array
        (
            [item_id] => 93
            [quote_id] => 119
            [created_at] => 2011-05-27 13:31:00
            [updated_at] => 2011-05-27 13:31:00
            [product_id] => 5
            [store_id] => 1
            [parent_item_id] => 
            [is_virtual] => 1
            [sku] => product1
            [name] => product
            [description] => 
            [applied_rule_ids] => 
            [additional_data] => 
            [free_shipping] => 0
            [is_qty_decimal] => 0
            [no_discount] => 0
            [weight] => 
            [qty] => 5
            [price] => 0.0000
            [base_price] => 0.0000
            [custom_price] => 
            [discount_percent] => 0.0000
            [discount_amount] => 0.0000
            [base_discount_amount] => 0.0000

However, I am to just call the following using the same above session

<?php
    $pInfo = $proxy->call( 'call', array( $sess, 'catalog_product.info', '5' ) );
    print_r( $pInfo );

I get the following information about the product:

[product_id] => 5
[sku] => product1
[set] => 9
[type] => virtual
[categories] => Array
    (
    )

[websites] => Array
    (
        [0] => 1
    )

[type_id] => virtual
[name] => product
[description] => Test
[short_description] => Test
[news_from_date] => 
[old_id] => 
[news_to_date] => 
[status] => 1
[visibility] => 4
...
[created_at] => 2011-05-25 15:11:34
[updated_at] => 2011-05-25 15:11:34
...
[price] => 10.0000

In the end, the API sees that the price of the item is in fact $10.00, but when added to the cart via API the prices are not properly reflected.

解决方案

Just so it can be an officially answered question, here is the solution found, http://magentocommerce.com/boards/viewthread/227044 I spent two days searching for this, and today come up with an obscure search term to try and find the solution

这篇关于Magento Cart API 未显示价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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