2

I'm trying to show a cart icon in Drupal with the number of items in the cart of our sister Magento site.

I'm using the Magento Core API to look up information on customers and use it in Drupal. I'm trying to load the contents of the cart for a specific Magento Customer ID, but I don't see any way to do this. The cart info API method only supports look ups by quote ID. Quote ID appears to be the primary key for a cart.

Is it possible to look up cart information by customer ID with a Magento API?

4

2 に答える 2

3

Magento Core API や新しい REST Api を使用してこの情報を取得することはできません。この情報が必要な場合は、独自の Magento 拡張機能を作成し、対象のシステムにインストールする必要があります。

Magento の「カート」オブジェクトは、特定のユーザー アカウントを特定の Magento の「見積もり」オブジェクトに関連付けます。見積もりは、注文オブジェクトである前に注文です。Magento の「PHP API」(つまり、Magento 開発者がシステムを操作するために使用するネイティブ PHP オブジェクト) では、これはsales/quoteオブジェクトです。

$quote = Mage::getModel('sales/quote');

このオブジェクトのデータはsales_flat_quoteテーブルに保存され、customer_id必要な情報を取得できるように列があります。

于 2013-09-30T19:17:35.963 に答える
0

ドキュメントによると、customer.info メソッドは顧客のアクティブな見積もり ID を返さないため、デフォルトでは返せないようです。ただし、コア API をカスタム モジュールで拡張して見積もり ID を提供するのは非常に簡単です。または、チェックアウト モジュールを拡張し、代わりに顧客 ID によるルックアップを実行する新しい API メソッドを作成して、customer.info リクエストをまとめて回避することもできます。これを行う方法のガイドについては、 http://www.magentocommerce.com/wiki/doc/webservices-api/custom-apiをお読みください。カスタム API メソッドを持つ利点は、それを最適化できることです (完全な見積もりオブジェクトをロードする代わりに、必要なデータ (つまり、見積もりの​​製品数のみ) だけを提供するクエリを実行することもできます)。

PS drupal サイトのリクエストは AJAX で行っていますか? API が遅く、ルックアップ中に drupal サイトが数秒間ハングしたくないので、私はそうします。

于 2013-09-30T18:41:37.517 に答える