2017-02-28 54 views
0

我正在嘗試爲Magento SOAP v2(Magento 1)使用過濾器,但我的代碼似乎不起作用。我嘗試了幾種構建數組的方法,但是它們都沒有影響返回的結果。Magento使用Node JS/soap包過濾SOAP v2

任何人都可以解釋我正確的方式來做到這一點嗎?

我想要做的是拉入所有發票,但例如使用特定的發票編號或日期。

鏈接到官方Magento的文檔: http://devdocs.magento.com/guides/m1x/api/soap/sales/salesOrderInvoice/sales_order_invoice.list.html

這是我當前的代碼:

const filter = { 
     'complex_filter': [ 
       { 
        key: 'invoice_id', 
        value: { 
         key: 'eq', 
         value: '94' 
        } 
       } 
      ] 
     }; 


    client.salesOrderInvoiceList(res, filter, function(error, result) { 
     console.log(result.result) 
    }); 

在上面的例子中,我只是試圖使用過濾器發票ID,但我也試圖與日期,但也沒有解決。

在此先感謝。

回答

0

對我來說,最簡單的解決方案就是完全映射到XML文檔的樣子,如果這是由PHP SoapClient完成的。

const args = { 
    sessionId: session_id, 
    storeView: store_id, 
    filters: { 
     complex_filter: { 
      complexObjectArray: { 
       key: 'created_at', 
       value: { 
        key: 'from', 
        value: '2017-01-01' 
       } 
      } 
     } 
    } 
}; 

client.catalogProductList(args, (err, result) => { ... }