我正在嘗試使用Magento Enterprise 1.10 XML-RPC API來處理Magento安裝以外的購物車/目錄功能。我遇到的問題是當我加入購物車時。我可以很好地連接到API端點,登錄和檢索數據。以下是我用來發現Magento API的工作原理的代碼。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);
輸出:
[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
不過,我只是調用使用相同的上述會議
<?php
$pInfo = $proxy->call('call', array($sess, 'catalog_product.info', '5'));
print_r($pInfo);
下面我得到關於產品的下列信息:
[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
最後,API se這個項目的價格實際上是10美元,但是當通過API添加到購物車時,價格沒有被適當反映。
解決方案,http://www.magentocommerce.com/boards/viewthread/227044/我花了兩天時間尋找這個,今天拿出一個難以理解的搜索詞來嘗試找到解決方案。 – Justin 2011-05-27 14:29:04
你可以回答你自己的問題並關閉它,FYI。 – B00MER 2011-05-27 15:46:08
我沒有足夠高的貢獻,無法回覆4個小時。= \ – Justin 2011-05-27 19:11:12