2012-02-19 28 views
0

我安裝了服務模塊和REST服務器以獲取產品和詳細信息列表。我只能得到產品展示節點和產品ID,如何使用服務模塊獲取Drupal Commerce中產品的價格?

但是如何從Drupal Commerce獲得產品價格和可用性信息。所有節點的

清單(包括產品展示節點)

http://drupalcommerce.myappdemo.com/services/node

獲取單個產品展示節點 http://drupalcommerce.myappdemo.com/services/node/37

但它確實給產品ID,而不是產品的價格。

請給我一個想法如何得到一個。

+1

有一個沙箱模塊稱爲[商務服務](http://drupal.org/sandbox/drupalista-br/1283494),該服務集成了Commerce和Services。這是目前你自己寫的最親密的方法 – Clive 2012-02-19 22:00:17

回答

0

檢查這個API是它會幫助你

$order = commerce_cart_order_load($uid); 
    // Get the order for user just logged in. 
    $order_authenticated = reset(commerce_order_load_multiple(array(), array('uid' => $this->store_customer->uid, 'status' => 'cart'), TRUE)); 
    //update the order status 
    $form_state['order'] = commerce_order_status_update($order, 'checkout_checkout', TRUE); 
    // Load the order status object for the current order. 
    $order_status = commerce_order_status_load($order->status); 
    $profile = commerce_customer_profile_load($order->data['profiles'][$checkout_pane['pane_id']]); 
    $order = commerce_order_load($order->order_id); 
    // Give other modules a chance to alter the order statuses. 
    drupal_alter('commerce_order_status_info', $order_statuses); 
    $order_state = commerce_order_state_load($order_status['state']); 
     // Load the line items for temporary storage in the form array. 
    $line_items = commerce_line_item_load_multiple($line_item_ids); 
    // load line item 
    commerce_line_item_load($line_item_id) 
    //load the commerce product 
    $product = commerce_product_load($product_id) 
    // Load the referenced products. 
    $products = commerce_product_load_multiple($product_ids); 
0
  1. 安裝Commerce Services模塊。

  2. 啓用「產品展示 - >檢索」和「產品 - >檢索的資源爲你的服務端點。

  3. 請在?Q A GET = my_service_endpoint /產品展示/ 123.json,這將讓節點123產品展示信息這也將包含引用的產品(第)的IDS通過該節點(例如產品456)以及產品的價格。

  4. 可選,做?Q A GET = my_service_endpoint /產品/ 456.json,這將讓該產品更完整的產品信息,ID爲456

相關問題