2012-02-19 55 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

相关问题